Remove redundant code

This commit is contained in:
René Pfeuffer
2018-12-04 11:38:09 +01:00
parent 8952e755df
commit c39d9bdc48
4 changed files with 54 additions and 72 deletions

View File

@@ -55,41 +55,23 @@ public interface ConfigurationEntryStoreFactory {
}
}
final class TypedFloatingConfigurationEntryStoreParameters<T> implements TypedStoreParameters<T> {
private Class<T> type;
private String name;
private Repository repository;
final class TypedFloatingConfigurationEntryStoreParameters<T> {
private final TypedStoreParametersImpl<T> parameters = new TypedStoreParametersImpl<>();
private final ConfigurationEntryStoreFactory factory;
TypedFloatingConfigurationEntryStoreParameters(ConfigurationEntryStoreFactory factory) {
this.factory = factory;
}
@Override
public Class<T> getType() {
return type;
}
@Override
public String getName() {
return name;
}
@Override
public Repository getRepository() {
return repository;
}
public class Builder {
Builder(Class<T> type) {
TypedFloatingConfigurationEntryStoreParameters.this.type = type;
parameters.setType(type);
}
public OptionalRepositoryBuilder withName(String name) {
TypedFloatingConfigurationEntryStoreParameters.this.name = name;
parameters.setName(name);
return new OptionalRepositoryBuilder();
}
}
@@ -97,12 +79,12 @@ final class TypedFloatingConfigurationEntryStoreParameters<T> implements TypedSt
public class OptionalRepositoryBuilder {
public OptionalRepositoryBuilder forRepository(Repository repository) {
TypedFloatingConfigurationEntryStoreParameters.this.repository = repository;
parameters.setRepository(repository);
return this;
}
public ConfigurationEntryStore<T> build(){
return factory.getStore(TypedFloatingConfigurationEntryStoreParameters.this);
return factory.getStore(parameters);
}
}
}

View File

@@ -55,41 +55,23 @@ public interface ConfigurationStoreFactory {
}
}
final class TypedFloatingConfigurationStoreParameters<T> implements TypedStoreParameters<T> {
private Class<T> type;
private String name;
private Repository repository;
final class TypedFloatingConfigurationStoreParameters<T> {
private final TypedStoreParametersImpl<T> parameters = new TypedStoreParametersImpl<>();
private final ConfigurationStoreFactory factory;
TypedFloatingConfigurationStoreParameters(ConfigurationStoreFactory factory) {
this.factory = factory;
}
@Override
public Class<T> getType() {
return type;
}
@Override
public String getName() {
return name;
}
@Override
public Repository getRepository() {
return repository;
}
public class Builder {
Builder(Class<T> type) {
TypedFloatingConfigurationStoreParameters.this.type = type;
parameters.setType(type);
}
public OptionalRepositoryBuilder withName(String name) {
TypedFloatingConfigurationStoreParameters.this.name = name;
parameters.setName(name);
return new OptionalRepositoryBuilder();
}
}
@@ -97,12 +79,12 @@ final class TypedFloatingConfigurationStoreParameters<T> implements TypedStorePa
public class OptionalRepositoryBuilder {
public OptionalRepositoryBuilder forRepository(Repository repository) {
TypedFloatingConfigurationStoreParameters.this.repository = repository;
parameters.setRepository(repository);
return this;
}
public ConfigurationStore<T> build(){
return factory.getStore(TypedFloatingConfigurationStoreParameters.this);
return factory.getStore(parameters);
}
}
}

View File

@@ -52,41 +52,23 @@ public interface DataStoreFactory {
}
}
final class TypedFloatingDataStoreParameters<T> implements TypedStoreParameters<T> {
private Class<T> type;
private String name;
private Repository repository;
final class TypedFloatingDataStoreParameters<T> {
private final TypedStoreParametersImpl<T> parameters = new TypedStoreParametersImpl<>();
private final DataStoreFactory factory;
TypedFloatingDataStoreParameters(DataStoreFactory factory) {
this.factory = factory;
}
@Override
public Class<T> getType() {
return type;
}
@Override
public String getName() {
return name;
}
@Override
public Repository getRepository() {
return repository;
}
public class Builder {
Builder(Class<T> type) {
TypedFloatingDataStoreParameters.this.type = type;
parameters.setType(type);
}
public OptionalRepositoryBuilder withName(String name) {
TypedFloatingDataStoreParameters.this.name = name;
parameters.setName(name);
return new OptionalRepositoryBuilder();
}
}
@@ -94,12 +76,12 @@ final class TypedFloatingDataStoreParameters<T> implements TypedStoreParameters<
public class OptionalRepositoryBuilder {
public OptionalRepositoryBuilder forRepository(Repository repository) {
TypedFloatingDataStoreParameters.this.repository = repository;
parameters.setRepository(repository);
return this;
}
public DataStore<T> build(){
return factory.getStore(TypedFloatingDataStoreParameters.this);
return factory.getStore(parameters);
}
}
}

View File

@@ -0,0 +1,36 @@
package sonia.scm.store;
import sonia.scm.repository.Repository;
class TypedStoreParametersImpl<T> implements TypedStoreParameters<T> {
private Class<T> type;
private String name;
private Repository repository;
@Override
public Class<T> getType() {
return type;
}
void setType(Class<T> type) {
this.type = type;
}
@Override
public String getName() {
return name;
}
void setName(String name) {
this.name = name;
}
@Override
public Repository getRepository() {
return repository;
}
void setRepository(Repository repository) {
this.repository = repository;
}
}