Skip to content

Commit

Permalink
Make constructors of abstract classes protected
Browse files Browse the repository at this point in the history
  • Loading branch information
ckittl committed Jan 6, 2022
1 parent 54c6218 commit 3e82df9
Show file tree
Hide file tree
Showing 22 changed files with 31 additions and 28 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [2.1.0] - 2022-01-05

### Fixed
- Reduced code smells
- Protected constructors for abstract classes

### Added
- added `EvcsLocationType` support in `EvcsInput` and `EvcsInputFactory` [#406](https://github.com/ie3-institute/PowerSystemDataModel/issues/406)
- Opportunity to close writer in `CsvFileSink`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
package edu.ie3.datamodel.exceptions;

public abstract class ValidationException extends RuntimeException {
public ValidationException(String s) {
protected ValidationException(String s) {
super(s);
}

public ValidationException(String s, Throwable throwable) {
protected ValidationException(String s, Throwable throwable) {
super(s, throwable);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
public abstract class FileNameMetaInformation {
private final UUID uuid;

public FileNameMetaInformation(UUID uuid) {
protected FileNameMetaInformation(UUID uuid) {
this.uuid = uuid;
}

Expand All @@ -23,8 +23,7 @@ public UUID getUuid() {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof FileNameMetaInformation)) return false;
FileNameMetaInformation that = (FileNameMetaInformation) o;
if (!(o instanceof FileNameMetaInformation that)) return false;
return uuid.equals(that.uuid);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public abstract class EntityFactory<T extends UniqueEntity, D extends EntityData
*
* @param allowedClasses exactly the classes that this factory is allowed and able to build
*/
public EntityFactory(Class<? extends T>... allowedClasses) {
protected EntityFactory(Class<? extends T>... allowedClasses) {
super(allowedClasses);
}
}
2 changes: 1 addition & 1 deletion src/main/java/edu/ie3/datamodel/io/factory/Factory.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public abstract class Factory<C, D extends FactoryData, R> {

private final List<Class<? extends C>> supportedClasses;

public Factory(Class<? extends C>... supportedClasses) {
protected Factory(Class<? extends C>... supportedClasses) {
this.supportedClasses = Arrays.asList(supportedClasses);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
public abstract class SimpleEntityFactory<T extends UniqueEntity>
extends EntityFactory<T, SimpleEntityData> {

public SimpleEntityFactory(Class<? extends T>... allowedClasses) {
protected SimpleEntityFactory(Class<? extends T>... allowedClasses) {
super(allowedClasses);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public abstract class AssetInputEntityFactory<T extends AssetInput, D extends As
private static final String OPERATES_UNTIL = "operatesuntil";
private static final String ID = "id";

public AssetInputEntityFactory(Class<? extends T>... allowedClasses) {
protected AssetInputEntityFactory(Class<? extends T>... allowedClasses) {
super(allowedClasses);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ abstract class ConnectorInputEntityFactory<
*/
protected static final String PARALLEL_DEVICES = "paralleldevices";

public ConnectorInputEntityFactory(Class<? extends T>... allowedClasses) {
protected ConnectorInputEntityFactory(Class<? extends T>... allowedClasses) {
super(allowedClasses);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public abstract class GraphicInputFactory<T extends GraphicInput, D extends Enti
private static final String GRAPHIC_LAYER = "graphiclayer";
private static final String PATH_LINE_STRING = "path";

public GraphicInputFactory(Class<? extends T>... allowedClasses) {
protected GraphicInputFactory(Class<? extends T>... allowedClasses) {
super(allowedClasses);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ abstract class SystemParticipantInputEntityFactory<

private static final String Q_CHARACTERISTICS = "qcharacteristics";

public SystemParticipantInputEntityFactory(Class<? extends T>... allowedClasses) {
protected SystemParticipantInputEntityFactory(Class<? extends T>... allowedClasses) {
super(allowedClasses);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ abstract class ResultEntityFactory<T extends ResultEntity> extends SimpleEntityF

protected final TimeUtil timeUtil;

public ResultEntityFactory(Class<? extends T>... allowedClasses) {
protected ResultEntityFactory(Class<? extends T>... allowedClasses) {
super(allowedClasses);
timeUtil = TimeUtil.withDefaults;
}

public ResultEntityFactory(String dtfPattern, Class<? extends T>... allowedClasses) {
protected ResultEntityFactory(String dtfPattern, Class<? extends T>... allowedClasses) {
super(allowedClasses);
timeUtil = new TimeUtil(ZoneId.of("UTC"), Locale.GERMANY, dtfPattern);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public abstract class TimeBasedValueData<V extends Value> extends FactoryData {
* @param fieldsToAttributes attribute map: field name to value
* @param valueClass Class of the underlying value
*/
public TimeBasedValueData(Map<String, String> fieldsToAttributes, Class<V> valueClass) {
protected TimeBasedValueData(Map<String, String> fieldsToAttributes, Class<V> valueClass) {
super(fieldsToAttributes, valueClass);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
public abstract class TimeBasedValueFactory<D extends TimeBasedValueData<V>, V extends Value>
extends Factory<V, D, TimeBasedValue<V>> {
public TimeBasedValueFactory(Class<? extends V>... valueClasses) {
protected TimeBasedValueFactory(Class<? extends V>... valueClasses) {
super(valueClasses);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ abstract class AssetTypeInputEntityFactory<T extends AssetTypeInput>
protected static final String ENTITY_UUID = "uuid";
protected static final String ENTITY_ID = "id";

public AssetTypeInputEntityFactory(Class<? extends T>... allowedClasses) {
protected AssetTypeInputEntityFactory(Class<? extends T>... allowedClasses) {
super(allowedClasses);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public abstract class EntityProcessor<T extends UniqueEntity> extends Processor<
*
* @param registeredClass the class the entity processor should be able to handle
*/
public EntityProcessor(Class<? extends T> registeredClass) {
protected EntityProcessor(Class<? extends T> registeredClass) {
super(registeredClass);
this.fieldNameToMethod =
mapFieldNameToGetter(registeredClass, Collections.singleton(NODE_INTERNAL));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public abstract class CsvDataSource {
*/
@Deprecated private boolean notYetLoggedWarning = true;

public CsvDataSource(String csvSep, String folderPath, FileNamingStrategy fileNamingStrategy) {
protected CsvDataSource(String csvSep, String folderPath, FileNamingStrategy fileNamingStrategy) {
this.csvSep = csvSep;
this.connector = new CsvFileConnector(folderPath, fileNamingStrategy);
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/edu/ie3/datamodel/models/UniqueEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ public abstract class UniqueEntity implements Serializable {

private final UUID uuid;

public UniqueEntity() {
protected UniqueEntity() {
uuid = UUID.randomUUID();
}

public UniqueEntity(UUID uuid) {
protected UniqueEntity(UUID uuid) {
this.uuid = uuid == null ? UUID.randomUUID() : uuid;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public abstract class AssetInput extends InputEntity implements Operable {
* @param operator Operator of the asset
* @param operationTime Operation time limitation
*/
public AssetInput(UUID uuid, String id, OperatorInput operator, OperationTime operationTime) {
protected AssetInput(UUID uuid, String id, OperatorInput operator, OperationTime operationTime) {
super(uuid);
this.operationTime = operationTime;
this.operator = operator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public abstract class AssetTypeInput extends InputEntity {
* @param uuid of the input entity
* @param id of the asset
*/
public AssetTypeInput(UUID uuid, String id) {
protected AssetTypeInput(UUID uuid, String id) {
super(uuid);
this.id = id;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/** Functionless class to describe that all subclasses are input classes */
public abstract class InputEntity extends UniqueEntity {

public InputEntity(UUID uuid) {
protected InputEntity(UUID uuid) {
super(uuid);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public abstract class ConnectorInput extends AssetInput implements HasNodes {
* @param parallelDevices overall amount of parallel devices to automatically construct (e.g.
* parallelDevices = 2 will build a total of two entities using the specified parameters)
*/
public ConnectorInput(
protected ConnectorInput(
UUID uuid,
String id,
OperatorInput operator,
Expand All @@ -57,7 +57,7 @@ public ConnectorInput(
* @param parallelDevices overall amount of parallel devices to automatically construct (e.g.
* parallelDevices = 2 will build a total of two entities using the specified parameters)
*/
public ConnectorInput(
protected ConnectorInput(
UUID uuid, String id, NodeInput nodeA, NodeInput nodeB, int parallelDevices) {
super(uuid, id);
this.nodeA = nodeA;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public abstract class TransformerInput extends ConnectorInput {
* @param tapPos Tap Position of this transformer
* @param autoTap True, if the tap position of the transformer is adapted automatically
*/
public TransformerInput(
protected TransformerInput(
UUID uuid,
OperationTime operationTime,
OperatorInput operator,
Expand All @@ -59,7 +59,7 @@ public TransformerInput(
* @param tapPos Tap Position of this transformer
* @param autoTap True, if the tap position of the transformer is adapted automatically
*/
public TransformerInput(
protected TransformerInput(
UUID uuid,
String id,
NodeInput nodeA,
Expand Down

0 comments on commit 3e82df9

Please sign in to comment.