Skip to content

Commit a02d6bf

Browse files
authored
NIFI-16591 Added Checkstyle rule FinalPatternVariable (#11928)
Signed-off-by: David Handermann <exceptionfactory@apache.org>
1 parent 7ee4e57 commit a02d6bf

21 files changed

Lines changed: 29 additions & 28 deletions

File tree

‎checkstyle.xml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,5 +153,6 @@
153153
<module name="TypecastParenPad"/>
154154
<module name="UnusedLocalVariable"/>
155155
<module name="InnerAssignment"/>
156+
<module name="FinalPatternVariable"/>
156157
</module>
157158
</module>

‎nifi-commons/nifi-record/src/main/java/org/apache/nifi/serialization/record/util/DataTypeUtils.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,11 +1295,11 @@ public static boolean isUUIDTypeCompatible(final Object value) {
12951295
return true;
12961296
}
12971297

1298-
if (value instanceof byte[] bytes) {
1298+
if (value instanceof final byte[] bytes) {
12991299
return bytes.length == 16;
13001300
}
13011301

1302-
if (value instanceof Byte[] array) {
1302+
if (value instanceof final Byte[] array) {
13031303
return array.length == 16;
13041304
}
13051305

‎nifi-commons/nifi-record/src/main/java/org/apache/nifi/serialization/record/validation/DefaultValidationError.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public boolean equals(final Object obj) {
8080
if (obj == null) {
8181
return false;
8282
}
83-
if (!(obj instanceof ValidationError other)) {
83+
if (!(obj instanceof final ValidationError other)) {
8484
return false;
8585
}
8686
return getFieldName().equals(other.getFieldName()) && getInputValue().equals(other.getInputValue()) && getExplanation().equals(other.getExplanation());

‎nifi-connector-mock-bundle/nifi-connector-mock/src/main/java/org/apache/nifi/mock/connector/migration/MockConnectorPropertyConfiguration.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ public boolean isPropertySet(final String propertyName) {
427427
if (reference == null) {
428428
return false;
429429
}
430-
if (reference instanceof StringLiteralValue literal) {
430+
if (reference instanceof final StringLiteralValue literal) {
431431
return literal.getValue() != null;
432432
}
433433
return true;
@@ -458,7 +458,7 @@ public Optional<String> getPropertyValue(final String propertyName) {
458458
return Optional.empty();
459459
}
460460
final ConnectorValueReference reference = properties.get(propertyName);
461-
if (reference instanceof StringLiteralValue literal) {
461+
if (reference instanceof final StringLiteralValue literal) {
462462
return Optional.ofNullable(literal.getValue());
463463
}
464464
return Optional.empty();
@@ -481,7 +481,7 @@ public Map<String, String> getProperties() {
481481
}
482482
final Map<String, String> literals = new HashMap<>();
483483
for (final Map.Entry<String, ConnectorValueReference> entry : properties.entrySet()) {
484-
if (entry.getValue() instanceof StringLiteralValue literal) {
484+
if (entry.getValue() instanceof final StringLiteralValue literal) {
485485
literals.put(entry.getKey(), literal.getValue());
486486
}
487487
}

‎nifi-extension-bundles/nifi-box-bundle/nifi-box-processors/src/main/java/org/apache/nifi/processors/box/CreateBoxMetadataTemplate.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ private void processRecord(final Record record,
274274

275275
if ("enum".equals(normalizedType) || "multiSelect".equals(normalizedType)) {
276276
final Object optionsObj = record.getValue("options");
277-
if (optionsObj instanceof List<?> optionsList) {
277+
if (optionsObj instanceof final List<?> optionsList) {
278278
final List<String> options = optionsList.stream()
279279
.map(obj -> {
280280
if (obj == null) {

‎nifi-extension-bundles/nifi-box-bundle/nifi-box-processors/src/main/java/org/apache/nifi/processors/box/ListBoxFile.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ private void listFolder(List<BoxFileInfo> listing, String folderId, Boolean recu
257257
.build();
258258
listing.add(boxFileInfo);
259259
}
260-
} else if (recursive && itemInfo instanceof BoxFolder.Info info) {
260+
} else if (recursive && itemInfo instanceof final BoxFolder.Info info) {
261261
listFolder(listing, info.getID(), recursive, createdAtMax);
262262
}
263263
}

‎nifi-extension-bundles/nifi-iceberg-bundle/nifi-iceberg-processors/src/main/java/org/apache/nifi/processors/iceberg/record/RecordConverter.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,9 @@ private static Object convertComplexValue(final Object value, final Type iceberg
138138
convertedValue = value;
139139
} else if (icebergType.isListType()) {
140140
convertedValue = convertListValue(value, icebergType.asListType());
141-
} else if (icebergType.isStructType() && value instanceof Record nestedRecord) {
141+
} else if (icebergType.isStructType() && value instanceof final Record nestedRecord) {
142142
convertedValue = new DelegatedRecord(nestedRecord, icebergType.asStructType());
143-
} else if (icebergType.isMapType() && value instanceof Map<?, ?> map) {
143+
} else if (icebergType.isMapType() && value instanceof final Map<?, ?> map) {
144144
convertedValue = convertMap(map, icebergType.asMapType());
145145
} else {
146146
convertedValue = convertPrimitiveValue(value, icebergType);

‎nifi-extension-bundles/nifi-kafka-bundle/nifi-kafka-3-integration/src/test/java/org/apache/nifi/kafka/processors/ConsumeKafkaMergeSchemaTypedIT.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ private static Map<String, Object> toMap(final GenericRecord record) {
175175
final Map<String, Object> values = new LinkedHashMap<>();
176176
for (final Schema.Field field : record.getSchema().getFields()) {
177177
final Object value = record.get(field.name());
178-
values.put(field.name(), value instanceof org.apache.avro.util.Utf8 utf8 ? utf8.toString() : value);
178+
values.put(field.name(), value instanceof final org.apache.avro.util.Utf8 utf8 ? utf8.toString() : value);
179179
}
180180
return values;
181181
}

‎nifi-extension-bundles/nifi-protobuf-bundle/nifi-protobuf-services/src/main/java/org/apache/nifi/services/protobuf/ProtobufSchemaDefinitionSanitizer.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ private static List<TypeElement> removeFromTypes(final List<TypeElement> types)
131131
}
132132

133133
private static TypeElement removeFromType(final TypeElement type) {
134-
if (type instanceof MessageElement message) {
134+
if (type instanceof final MessageElement message) {
135135
return new MessageElement(
136136
message.getLocation(),
137137
message.getName(),
@@ -147,7 +147,7 @@ private static TypeElement removeFromType(final TypeElement type) {
147147
);
148148
}
149149

150-
if (type instanceof EnumElement enumeration) {
150+
if (type instanceof final EnumElement enumeration) {
151151
return new EnumElement(
152152
enumeration.getLocation(),
153153
enumeration.getName(),

‎nifi-extension-bundles/nifi-smb-bundle/nifi-smb-processors/src/main/java/org/apache/nifi/processors/smb/GetSmbFile.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ public void onScheduled(final ProcessContext context) {
284284

285285
@OnStopped
286286
public void onStopped() {
287-
if (clientProvider instanceof SmbjClientProvider smbjClientProvider) {
287+
if (clientProvider instanceof final SmbjClientProvider smbjClientProvider) {
288288
smbjClientProvider.close();
289289
}
290290
clientProvider = null;

0 commit comments

Comments
 (0)