Skip to content

Commit

Permalink
refactor(plc4j): fixed some Q/A issues
Browse files Browse the repository at this point in the history
  • Loading branch information
sruehl committed May 4, 2023
1 parent 4f4712f commit 724c043
Show file tree
Hide file tree
Showing 464 changed files with 641 additions and 657 deletions.
Expand Up @@ -44,9 +44,9 @@ public class GoLanguageTemplateHelper extends BaseFreemarkerLanguageTemplateHelp

// TODO: we could condense it to one import set as these can be emitted per template and are not hardcoded anymore

public SortedSet<String> requiredImports = new TreeSet<>();
public final SortedSet<String> requiredImports = new TreeSet<>();

public SortedSet<String> requiredImportsForDataIo = new TreeSet<>();
public final SortedSet<String> requiredImportsForDataIo = new TreeSet<>();

public GoLanguageTemplateHelper(TypeDefinition thisType, String protocolName, String flavorName, Map<String, TypeDefinition> types) {
super(thisType, protocolName, flavorName, types);
Expand Down
Expand Up @@ -98,7 +98,7 @@ public enum ${type.name} {
}
}

private ${helper.getLanguageTypeNameForTypeReference(type.type.orElseThrow(), true)} value;
private final ${helper.getLanguageTypeNameForTypeReference(type.type.orElseThrow(), true)} value;
</#if>
<#if type.constantNames?has_content>
<#list type.constantNames as constantName>
Expand Down
Expand Up @@ -31,7 +31,7 @@ public class DefaultArgument implements Argument {

private TypeReference type;

protected CompletableFuture<TypeReference> typeReferenceCompletionStage = new CompletableFuture<>();
protected final CompletableFuture<TypeReference> typeReferenceCompletionStage = new CompletableFuture<>();

public DefaultArgument(String name) {
this.name = Objects.requireNonNull(name);
Expand Down
Expand Up @@ -31,7 +31,7 @@ public abstract class DefaultTypedField extends DefaultField {

protected TypeReference type;

protected CompletableFuture<TypeReference> typeReferenceCompletionStage = new CompletableFuture<>();
protected final CompletableFuture<TypeReference> typeReferenceCompletionStage = new CompletableFuture<>();

public DefaultTypedField(Map<String, Term> attributes) {
super(attributes);
Expand Down
Expand Up @@ -60,9 +60,9 @@ public class MessageFormatListener extends MSpecBaseListener implements LazyType

private Deque<List<EnumValue>> enumContexts;

protected Map<String, TypeDefinition> types;
protected final Map<String, TypeDefinition> types;

protected Map<String, List<Consumer<TypeDefinition>>> typeDefinitionConsumers;
protected final Map<String, List<Consumer<TypeDefinition>>> typeDefinitionConsumers;

private final Stack<Map<String, Term>> batchSetAttributes = new Stack<>();

Expand All @@ -74,7 +74,7 @@ public Deque<List<EnumValue>> getEnumContexts() {
return enumContexts;
}

private Stack<String> currentTypeName = new Stack<>();
private final Stack<String> currentTypeName = new Stack<>();

public MessageFormatListener() {
types = new HashMap<>();
Expand Down
Expand Up @@ -32,7 +32,7 @@

class ExpressionStringParserTest {

ExpressionStringParser SUT = new ExpressionStringParser((typeRefName, setTypeDefinition) -> {}, "hurz");
final ExpressionStringParser SUT = new ExpressionStringParser((typeRefName, setTypeDefinition) -> {}, "hurz");

@Test
void parseSimple() {
Expand Down
Expand Up @@ -42,7 +42,7 @@

class MessageFormatParserTest {

MessageFormatParser SUT = new MessageFormatParser();
final MessageFormatParser SUT = new MessageFormatParser();

@Test
void parseNull() {
Expand Down
8 changes: 4 additions & 4 deletions plc4go/assets/testing/protocols/s7/DriverTestsuite.xml
Expand Up @@ -422,12 +422,12 @@
<steps>
<api-request name="Receive Read Request from application">
<TestReadRequest>
<tags isList="true">
<tags isList="true">
<tag className="org.apache.plc4x.test.driver.internal.api.TestTag">
<name>hurz</name>
<address>%Q0.0:BOOL</address>
<name>hurz</name>
<address>%Q0.0:BOOL</address>
</tag>
</tags>
</tags>
</TestReadRequest>
</api-request>
<outgoing-plc-message name="Send S7 Read Request">
Expand Down
Expand Up @@ -38,9 +38,9 @@ public class DefaultPlcDriverManager implements PlcDriverManager, PlcConnectionM

private static final Logger LOGGER = LoggerFactory.getLogger(DefaultPlcDriverManager.class);

protected ClassLoader classLoader;
protected final ClassLoader classLoader;

private Map<String, PlcDriver> driverMap;
private final Map<String, PlcDriver> driverMap;

public DefaultPlcDriverManager() {
this(Thread.currentThread().getContextClassLoader());
Expand Down
Expand Up @@ -20,10 +20,10 @@

public class PlcProtocolPayloadTooBigException extends PlcProtocolException {

private String protocolName;
private int maxSize;
private int actualSize;
private transient Object payload;
private final String protocolName;
private final int maxSize;
private final int actualSize;
private final transient Object payload;

public PlcProtocolPayloadTooBigException(String protocolName, int maxSize, int actualSize, Object payload) {
super("Payload for protocol '" + protocolName + "' with size " + actualSize +
Expand Down
Expand Up @@ -53,8 +53,8 @@ public class Plc4xAbEthProtocol extends PlcMessageToMessageCodec<CIPEncapsulatio
(short) 0x00,(short) 0x00,(short) 0x00, (short) 0x00,(short) 0x00);

private long sessionHandle;
private Map<Integer, PlcRequestContainer> requests;
private int station;
private final Map<Integer, PlcRequestContainer> requests;
private final int station;

public Plc4xAbEthProtocol(int station) {
logger.trace("Created new instance of PLC4X-AB-ETH Protocol");
Expand Down
Expand Up @@ -42,7 +42,7 @@ public enum AdsDiscoveryBlockType {
}
}

private int value;
private final int value;

AdsDiscoveryBlockType(int value) {
this.value = value;
Expand Down
Expand Up @@ -46,7 +46,7 @@ public enum AdsPortNumbers {
}
}

private int value;
private final int value;

AdsPortNumbers(int value) {
this.value = value;
Expand Down
Expand Up @@ -41,7 +41,7 @@ public enum Operation {
}
}

private long value;
private final long value;

Operation(long value) {
this.value = value;
Expand Down
Expand Up @@ -36,7 +36,7 @@ public enum Status {
}
}

private long value;
private final long value;

Status(long value) {
this.value = value;
Expand Down
Expand Up @@ -75,7 +75,7 @@ public enum AdsDataType {
}
}

private byte value;
private final byte value;
private int numBytes;
private PlcValueType plcValueType;

Expand Down
Expand Up @@ -40,7 +40,7 @@ public enum AdsTransMode {
}
}

private long value;
private final long value;

AdsTransMode(long value) {
this.value = value;
Expand Down
Expand Up @@ -43,7 +43,7 @@ public enum CommandId {
}
}

private int value;
private final int value;

CommandId(int value) {
this.value = value;
Expand Down
Expand Up @@ -88,7 +88,7 @@ public enum DefaultAmsPorts {
}
}

private int value;
private final int value;

DefaultAmsPorts(int value) {
this.value = value;
Expand Down
Expand Up @@ -64,7 +64,7 @@ public enum PlcValueType {
}
}

private short value;
private final short value;

PlcValueType(short value) {
this.value = value;
Expand Down
Expand Up @@ -70,7 +70,7 @@ public enum ReservedIndexGroups {
}
}

private long value;
private final long value;

ReservedIndexGroups(long value) {
this.value = value;
Expand Down
Expand Up @@ -155,7 +155,7 @@ public enum ReturnCode {
}
}

private long value;
private final long value;

ReturnCode(long value) {
this.value = value;
Expand Down
Expand Up @@ -49,7 +49,7 @@ public enum ApduType {
}
}

private byte value;
private final byte value;

ApduType(byte value) {
this.value = value;
Expand Down
Expand Up @@ -46,7 +46,7 @@ public enum BACnetAbortReason {
}
}

private short value;
private final short value;

BACnetAbortReason(short value) {
this.value = value;
Expand Down
Expand Up @@ -41,7 +41,7 @@ public enum BACnetAccessAuthenticationFactorDisable {
}
}

private int value;
private final int value;

BACnetAccessAuthenticationFactorDisable(int value) {
this.value = value;
Expand Down
Expand Up @@ -38,7 +38,7 @@ public enum BACnetAccessCredentialDisable {
}
}

private int value;
private final int value;

BACnetAccessCredentialDisable(int value) {
this.value = value;
Expand Down
Expand Up @@ -44,7 +44,7 @@ public enum BACnetAccessCredentialDisableReason {
}
}

private int value;
private final int value;

BACnetAccessCredentialDisableReason(int value) {
this.value = value;
Expand Down
Expand Up @@ -88,7 +88,7 @@ public enum BACnetAccessEvent {
}
}

private int value;
private final int value;

BACnetAccessEvent(int value) {
this.value = value;
Expand Down
Expand Up @@ -36,7 +36,7 @@ public enum BACnetAccessPassbackMode {
}
}

private short value;
private final short value;

BACnetAccessPassbackMode(short value) {
this.value = value;
Expand Down
Expand Up @@ -35,7 +35,7 @@ public enum BACnetAccessRuleLocationSpecifier {
}
}

private short value;
private final short value;

BACnetAccessRuleLocationSpecifier(short value) {
this.value = value;
Expand Down
Expand Up @@ -35,7 +35,7 @@ public enum BACnetAccessRuleTimeRangeSpecifier {
}
}

private short value;
private final short value;

BACnetAccessRuleTimeRangeSpecifier(short value) {
this.value = value;
Expand Down
Expand Up @@ -37,7 +37,7 @@ public enum BACnetAccessUserType {
}
}

private int value;
private final int value;

BACnetAccessUserType(int value) {
this.value = value;
Expand Down
Expand Up @@ -41,7 +41,7 @@ public enum BACnetAccessZoneOccupancyState {
}
}

private int value;
private final int value;

BACnetAccessZoneOccupancyState(int value) {
this.value = value;
Expand Down
Expand Up @@ -39,7 +39,7 @@ public enum BACnetAccumulatorRecordAccumulatorStatus {
}
}

private short value;
private final short value;

BACnetAccumulatorRecordAccumulatorStatus(short value) {
this.value = value;
Expand Down
Expand Up @@ -35,7 +35,7 @@ public enum BACnetAction {
}
}

private short value;
private final short value;

BACnetAction(short value) {
this.value = value;
Expand Down
Expand Up @@ -58,7 +58,7 @@ public enum BACnetAuthenticationFactorType {
}
}

private short value;
private final short value;

BACnetAuthenticationFactorType(short value) {
this.value = value;
Expand Down
Expand Up @@ -40,7 +40,7 @@ public enum BACnetAuthenticationStatus {
}
}

private short value;
private final short value;

BACnetAuthenticationStatus(short value) {
this.value = value;
Expand Down
Expand Up @@ -41,7 +41,7 @@ public enum BACnetAuthorizationExemption {
}
}

private short value;
private final short value;

BACnetAuthorizationExemption(short value) {
this.value = value;
Expand Down
Expand Up @@ -40,7 +40,7 @@ public enum BACnetAuthorizationMode {
}
}

private int value;
private final int value;

BACnetAuthorizationMode(int value) {
this.value = value;
Expand Down
Expand Up @@ -40,7 +40,7 @@ public enum BACnetBackupState {
}
}

private short value;
private final short value;

BACnetBackupState(short value) {
this.value = value;
Expand Down

0 comments on commit 724c043

Please sign in to comment.