Skip to content

Commit 4a4ba72

Browse files
committed
chore(QTDI-2893): S6201 changes after rebase
1 parent ff76b94 commit 4a4ba72

86 files changed

Lines changed: 383 additions & 404 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

component-form/component-form-core/src/main/java/org/talend/sdk/component/form/internal/validation/spi/ext/TypeValidation.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ public class TypeValidation implements ValidationExtension {
3838
@Override
3939
public Optional<Function<JsonValue, Stream<ValidationError>>> create(final ValidationContext model) {
4040
final JsonValue value = model.getSchema().get("type");
41-
if (value instanceof JsonString) {
41+
if (value instanceof JsonString jsonString) {
4242
return Optional
4343
.of(new Impl(model.toPointer(), model.getValueProvider(),
44-
mapType((JsonString) value).toArray(JsonValue.ValueType[]::new)));
44+
mapType(jsonString).toArray(JsonValue.ValueType[]::new)));
4545
}
4646
if (value instanceof JsonArray) {
4747
return Optional

component-form/component-form-model/src/main/java/org/talend/sdk/component/form/model/jsonschema/PojoJsonSchemaBuilder.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public JsonSchema.Builder create(final Class<?> pojo) {
6464
private JsonSchema buildSchema(final Field field) {
6565
final Type genericType = field.getGenericType();
6666

67-
if ((genericType instanceof Class && CharSequence.class.isAssignableFrom((Class) genericType))
67+
if ((genericType instanceof Class clazz && CharSequence.class.isAssignableFrom(clazz))
6868
|| genericType == char.class || genericType == Character.class) {
6969
return schemas.computeIfAbsent((Class) genericType, k -> jsonSchema().withType("string").build());
7070
} else if (genericType == long.class || genericType == Long.class || genericType == int.class
@@ -76,15 +76,14 @@ private JsonSchema buildSchema(final Field field) {
7676
} else if (genericType == boolean.class || genericType == Boolean.class) {
7777
return schemas
7878
.computeIfAbsent((Class) genericType, k -> jsonSchema().withType("boolean").build());
79-
} else if (genericType instanceof Class) {
80-
final Class<?> clazz = (Class) genericType;
79+
} else if (genericType instanceof Class classVal) {
80+
final Class<?> clazz = classVal;
8181
return ofNullable(schemas.get(clazz)).orElseGet(() -> {
8282
final JsonSchema jsonSchema = create(clazz).build();
8383
schemas.put(clazz, jsonSchema);
8484
return jsonSchema;
8585
});
86-
} else if (genericType instanceof ParameterizedType) {
87-
final ParameterizedType pt = (ParameterizedType) genericType;
86+
} else if (genericType instanceof ParameterizedType pt) {
8887
final Type rawType = pt.getRawType();
8988
if (!(rawType instanceof Class)) {
9089
throw new IllegalArgumentException("Unsupported raw type: " + pt + ", this must be a Class");

component-runtime-beam/src/main/java/org/talend/sdk/component/runtime/beam/BaseProcessorFn.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ abstract class BaseProcessorFn<O> extends DoFn<Record, O> {
6565

6666
BaseProcessorFn(final Processor processor) {
6767
this.processor = processor;
68-
if (processor instanceof ProcessorImpl) {
69-
((ProcessorImpl) processor)
68+
if (processor instanceof ProcessorImpl processorImpl) {
69+
processorImpl
7070
.getInternalConfiguration()
7171
.entrySet()
7272
.stream()

component-runtime-beam/src/main/java/org/talend/sdk/component/runtime/beam/TalendIO.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ public static Base<PBegin, PCollection<Record>, Mapper> read(final Mapper mapper
7777
String maxRecords = null;
7878
String maxDurationMs = null;
7979
boolean hasInternalConfParams = false;
80-
if (mapper instanceof PartitionMapperImpl) {
81-
Map<String, String> conf = ((PartitionMapperImpl) mapper).getInternalConfiguration();
80+
if (mapper instanceof PartitionMapperImpl partitionMapperImpl) {
81+
Map<String, String> conf = partitionMapperImpl.getInternalConfiguration();
8282
hasInternalConfParams = conf.keySet()
8383
.stream()
8484
.filter(k -> k.equals("$maxRecords") || k.equals("$maxDurationMs"))
@@ -164,8 +164,8 @@ private static class InfiniteRead extends Base<PBegin, PCollection<Record>, Mapp
164164
private InfiniteRead(final Mapper delegate, final long maxRecordCount, final long maxDuration) {
165165
super(delegate);
166166
// ensure we consider localConfiguration
167-
final Map<String, String> internalConf = delegate instanceof PartitionMapperImpl
168-
? ((PartitionMapperImpl) delegate).getInternalConfiguration()
167+
final Map<String, String> internalConf = delegate instanceof PartitionMapperImpl partitionMapper
168+
? partitionMapper.getInternalConfiguration()
169169
: emptyMap();
170170
StopConfiguration fromLocalConf =
171171
(StopConfiguration) Streaming.loadStopStrategy(delegate.plugin(), internalConf);

component-runtime-beam/src/main/java/org/talend/sdk/component/runtime/beam/coder/JsonpJsonObjectCoder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public JsonObject decode(final InputStream inputStream) throws IOException {
7171

7272
@Override
7373
public boolean equals(final Object obj) {
74-
return obj instanceof JsonpJsonObjectCoder && ((JsonpJsonObjectCoder) obj).isValid();
74+
return obj instanceof JsonpJsonObjectCoder coder && coder.isValid();
7575
}
7676

7777
@Override

component-runtime-beam/src/main/java/org/talend/sdk/component/runtime/beam/factory/service/AutoValueFluentApiFactory.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,14 +164,13 @@ private Object createPrimitiveValue(final Object v, final Type type) {
164164
if (String.class == type) { // fast path
165165
return v;
166166
}
167-
if (type instanceof Class && ((Class) type).isInstance(v)) {
167+
if (type instanceof Class clazz && (clazz.isInstance(v))) {
168168
return v;
169169
}
170-
if (type instanceof ParameterizedType) {
171-
final ParameterizedType pt = (ParameterizedType) type;
170+
if (type instanceof ParameterizedType pt) {
172171
final Type raw = pt.getRawType();
173172
// we know what we do if we use that
174-
if (raw instanceof Class && ((Class) raw).isInstance(v)) {
173+
if (raw instanceof Class clazz && clazz.isInstance(v)) {
175174
return v;
176175
}
177176
}

component-runtime-beam/src/main/java/org/talend/sdk/component/runtime/beam/spi/BeamComponentExtension.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ public boolean isActive() {
6666
@Override
6767
public <T> T unwrap(final Class<T> type, final Object... args) {
6868
if ("org.talend.sdk.component.design.extension.flows.FlowsFactory".equals(type.getName()) && args != null
69-
&& args.length == 1 && args[0] instanceof ComponentFamilyMeta.BaseMeta) {
69+
&& args.length == 1 && args[0] instanceof ComponentFamilyMeta.BaseMeta baseMeta) {
7070
if (args[0] instanceof ComponentFamilyMeta.ProcessorMeta) {
7171
try {
72-
final FlowsFactory factory = FlowsFactory.get((ComponentFamilyMeta.BaseMeta) args[0]);
72+
final FlowsFactory factory = FlowsFactory.get(baseMeta);
7373
factory.getOutputFlows();
7474
return type.cast(factory);
7575
} catch (final Exception e) { // no @ElementListener, let's default for native transforms

component-runtime-beam/src/main/java/org/talend/sdk/component/runtime/beam/spi/BeamProducerFinder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ public Iterator<Record> find(final String familyName, final String inputName, fi
6565
} catch (Exception e) {
6666
log.warn("Component Kit Mapper instantiation failed, trying to wrap native beam mapper...");
6767
final Object delegate = ((Delegated) mapper).getDelegate();
68-
if (delegate instanceof PTransform) {
68+
if (delegate instanceof PTransform pTransform) {
6969
final UUID uuid = UUID.randomUUID();
7070
QUEUE.put(uuid, new ArrayBlockingQueue<>(QUEUE_SIZE, true));
71-
return new QueueInput(delegate, familyName, inputName, familyName, (PTransform) delegate,
71+
return new QueueInput(delegate, familyName, inputName, familyName, pTransform,
7272
uuid);
7373
}
7474
throw new IllegalStateException(e);

component-runtime-beam/src/test/java/org/talend/sdk/component/runtime/beam/factory/service/io/AutoValue_CustomJdbcIO_DataSourceConfiguration.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,7 @@ public boolean equals(final Object o) {
8686
if (o == this) {
8787
return true;
8888
}
89-
if (o instanceof CustomJdbcIO.DataSourceConfiguration) {
90-
CustomJdbcIO.DataSourceConfiguration that = (CustomJdbcIO.DataSourceConfiguration) o;
89+
if (o instanceof CustomJdbcIO.DataSourceConfiguration that) {
9190
return ((this.driverClassName == null) ? (that.getDriverClassName() == null)
9291
: this.driverClassName.equals(that.getDriverClassName()))
9392
&& ((this.url == null) ? (that.getUrl() == null) : this.url.equals(that.getUrl()))

component-runtime-beam/src/test/java/org/talend/sdk/component/runtime/beam/transformer/BeamIOTransformerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ void coderSerialization() {
148148
private Object newInstance(final Class<?> aClass, final ClassLoader validationLoader) {
149149
try {
150150
final Object instance = aClass.getConstructor().newInstance();
151-
if (instance instanceof SetValidator) {
152-
((SetValidator) instance)
151+
if (instance instanceof SetValidator setValidatorVal) {
152+
setValidatorVal
153153
.setValidator(
154154
() -> assertEquals(Thread.currentThread().getContextClassLoader(), validationLoader));
155155
}

0 commit comments

Comments
 (0)