Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,7 @@ protected Map<String, Collection<Object>> toCondition(final String path, final S
.withVar(path + ".length")
.withValue(String.class.isInstance(value) ? Integer.parseInt(String.valueOf(value)) : value)
.build();
case "contains":
case "contains(lowercase=true)":
case "contains", "contains(lowercase=true)":
final UiSchema.ConditionValuesBuilder in = new UiSchema.ConditionBuilder().withOperator("in");
final Object val =
strategy.endsWith("(lowercase=true)") ? String.class.cast(value).toLowerCase(ROOT) : value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
Boolean.parseBoolean(context.getProperty().getMetadata().getOrDefault("ui::datetime::useUTC", "true"));
switch (format) {
case "time": {
schema.setWidget("datetime"); // todo: move to "time" widget when existing

Check failure on line 60 in component-form/component-form-core/src/main/java/org/talend/sdk/component/form/internal/converter/impl/widget/DateTimeConverter.java

View check run for this annotation

sonar-rnd / SonarQube Code Analysis

component-form/component-form-core/src/main/java/org/talend/sdk/component/form/internal/converter/impl/widget/DateTimeConverter.java#L60

Define a constant instead of duplicating this literal "datetime" 3 times.
final Map<String, Object> options = new HashMap<>();
options.put("useSeconds", useSeconds);
schema.setOptions(options);
Expand All @@ -67,8 +67,7 @@
schema.setWidget("date");
schema.setOptions(singletonMap("dateFormat", dateFormat));
break;
case "datetime":
case "zoneddatetime": {
case "datetime", "zoneddatetime": {
schema.setWidget("datetime");
final Map<String, Object> options = new HashMap<>();
options.put("useSeconds", useSeconds);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ public Stream<ValidationResult.ValidationError> apply(final JsonValue obj) {
switch (value.getValueType()) {
case STRING:
return onString(JsonString.class.cast(value));
case TRUE:
case FALSE:
case TRUE, FALSE:
return onBoolean(JsonValue.TRUE.equals(value));
case NUMBER:
return onNumber(JsonNumber.class.cast(value));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ public class AvroRecordBuilderFactoryProvider implements RecordBuilderFactoryPro
@Override
public RecordBuilderFactory apply(final String containerId) {
switch (System.getProperty("talend.component.beam.record.factory.impl", "auto")) {
case "memory":
case "default":
case "memory", "default":
return new RecordBuilderFactoryImpl(containerId);
case "avro":
if (!hasAvroRecordBuilderFactory()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,7 @@ private Type doMapType(final Schema schema) {
}
return Type.BYTES;
// very unlikely to happen but treat all available types
case MAP:
case UNION:
case NULL:
case MAP, UNION, NULL:
log.warn("[doMapType] unmanaged avro type {}. Storing as Object.", schema.getType());
// the storage will be an object so returning record kind...
return Type.RECORD;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ private Schema guessSchema(final String recordName, final JsonValue element) {
return INT;
}
return DOUBLE;
case FALSE:
case TRUE:
case FALSE, TRUE:
return BOOLEAN;
case NULL:
return NULL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ public class RecordBuilderFactoryImpl implements RecordBuilderFactory, Serializa
@Override
public Schema.Builder newSchemaBuilder(final Schema.Type type) {
switch (type) {
case RECORD:
case ARRAY:
case RECORD, ARRAY:
return new SchemaImpl.BuilderImpl().withType(type);
default:
return Schemas.valueOf(type.name());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ private Record json2Record(final RecordBuilderFactory factory, final JsonObject
.build(), record);
break;
}
case TRUE:
case FALSE:
case TRUE, FALSE:
builder.withBoolean(key, JsonValue.TRUE.equals(value));
break;
case STRING:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ private static Map<String, String> parseQuery(final String query) {
parameterComplete = true;
pos++;
break;
case '%':
case '+':
case '%', '+':
// Decoding required
if (parsingName) {
decodeName = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,7 @@ private List<ParameterMeta> buildParametersMetas(final String name, final String
}
if (Class.class.isInstance(type)) {
switch (findType(type)) {
case ENUM:
case STRING:
case NUMBER:
case BOOLEAN:
case ENUM, STRING, NUMBER, BOOLEAN:
return singletonList(buildParameter(name, prefix, new ParameterMeta.Source() {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ private void onProperty(final String contextualPrefix, final Collection<Paramete
}
}
break;
case ENUM:
case STRING: {
case ENUM, STRING: {
final String value = config.get(newPath);
parameterVisitor.onParameter(definition, value == null ? JsonValue.NULL : jsonp.createValue(value));
ofNullable(value).ifPresent(v -> json.add(name, v));
Expand Down Expand Up @@ -186,8 +185,7 @@ private JsonValue onArrayPrimitive(final ParameterMeta itemDef, final ArrayEntry
case NUMBER:
final Double number = Double.valueOf(value.trim());
return number == number.longValue() ? jsonp.createValue(number.longValue()) : jsonp.createValue(number);
case ENUM:
case STRING:
case ENUM, STRING:
return jsonp.createValue(value);
default:
throw new IllegalArgumentException("Unsupported structure in " + "array: " + itemDef.getType());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,7 @@ public String findDefault(final Object instance, final ParameterMeta param) {
return null;
case ENUM:
return Enum.class.cast(instance).name();
case STRING:
case NUMBER:
case BOOLEAN:
case STRING, NUMBER, BOOLEAN:
return String.valueOf(instance);
case ARRAY: // can be enhanced
if (!param.getNestedParameters().isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,17 @@ protected Object toObjectImpl(final String data) {
switch (text.length()) {
case 10: // YYYY-MM-dd
return ZonedDateTime.of(LocalDate.parse(text), NO_TIME, ZoneId.of("UTC"));
case 18: // HH:mm:ss.SSSSSSSSS
case 15: // HH:mm:ss.SSSSSS
case 12: // HH:mm:ss.SSS
case 8: // HH:mm:ss
case 5: // HH:mm
case 18 // HH:mm:ss.SSSSSSSSS
, 15 // HH:mm:ss.SSSSSS
, 12 // HH:mm:ss.SSS
, 8 // HH:mm:ss
, 5: // HH:mm
return ZonedDateTime.of(NO_DATE, LocalTime.parse(text), UTC);
case 29: // YYYY-MM-dd HH:mm:ss.SSSSSSSSS
case 26: // YYYY-MM-dd HH:mm:ss.SSSSSS
case 23: // YYYY-MM-dd HH:mm:ss.SSS
case 19: // YYYY-MM-dd HH:mm:ss
case 16: // YYYY-MM-dd HH:mm
case 29 // YYYY-MM-dd HH:mm:ss.SSSSSSSSS
, 26 // YYYY-MM-dd HH:mm:ss.SSSSSS
, 23 // YYYY-MM-dd HH:mm:ss.SSS
, 19 // YYYY-MM-dd HH:mm:ss
, 16: // YYYY-MM-dd HH:mm
default: // YYYY-MM-dd HH:mm.ss+HH:mm[...]
text = text.replace(' ', 'T');
if (text.contains("+") || text.contains("[")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ public RecordBuilderFactory apply(final String containerId) {
: "org.talend.sdk.component.runtime.beam.TalendIO";

switch (System.getProperty("talend.component.beam.record.factory.impl", "auto")) {
case "memory":
case "default":
case "memory", "default":
return new RecordBuilderFactoryImpl(containerId);
case "avro":
return new FakeRecordBuilderFactory(containerId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,7 @@ private Token nextToken(final char[] buffer, final int from) {
}
final String string = new String(buffer, actualFrom, idx - actualFrom);
switch (string) {
case "AND":
case "OR":
case "AND", "OR":
return new Token(idx, TokenType.COMBINER, string);
default:
return new Token(idx, TokenType.VALUE, string);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ public String toJavaConfigType(final String root, final String pack, final Proje
return "boolean";
case "double":
return "double";
case "int":
case "integer":
case "int", "integer":
return "int";
case "uri": // todo: import
return "java.net.URI";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,7 @@ private Parameter mapParameter(final JsonObject it, final String type, final Str
getObject(it, "schema").map(this::mapJavaType).orElse("String"),
getObject(it, "schema").map(schema -> schema.get("default")).map(defaultValue -> {
switch (defaultValue.getValueType()) {
case TRUE:
case FALSE:
case NUMBER:
case TRUE, FALSE, NUMBER:
return String.valueOf(defaultValue);
case STRING:
return JsonString.class.cast(defaultValue).getString();
Expand All @@ -297,8 +295,7 @@ private String getMarkerImportForParameter(final String name, final String type)
return "org.talend.sdk.component.api.service.http.Path";
case "header":
return "org.talend.sdk.component.api.service.http.Header";
case "body":
case "formData":
case "body", "formData":
return null;
default:
throw new IllegalArgumentException("Unsupported parameter: " + type + "(" + name + ")");
Expand All @@ -313,8 +310,7 @@ private String getJavaMarkerForParameter(final String name, final String type) {
return "@Path(\"" + name + "\") ";
case "header":
return "@Header(\"" + name + "\") ";
case "body":
case "formData":
case "body", "formData":
return "";
default:
throw new IllegalArgumentException("Unsupported parameter: " + type + "(" + name + ")");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,7 @@ private void visit(final Object data) {
case StudioTypes.BYTE:
onInt(name, Byte.class.cast(raw).intValue());
break;
case StudioTypes.INTEGER:
case StudioTypes.SHORT:
case StudioTypes.INTEGER, StudioTypes.SHORT:
onInt(name, raw);
break;
case StudioTypes.LONG:
Expand Down Expand Up @@ -185,8 +184,7 @@ private void handleDynamic(final Object raw) {
// so we can pick the entry from the schema
onArray(rowStructSchema.getEntry(metaName), (Collection) value);
break;
case StudioTypes.STRING:
case StudioTypes.CHARACTER:
case StudioTypes.STRING, StudioTypes.CHARACTER:
onString(metaName, value);
break;
case StudioTypes.BYTE_ARRAY:
Expand All @@ -204,9 +202,7 @@ private void handleDynamic(final Object raw) {
}
onBytes(metaName, bytes);
break;
case StudioTypes.BYTE:
case StudioTypes.SHORT:
case StudioTypes.INTEGER:
case StudioTypes.BYTE, StudioTypes.SHORT, StudioTypes.INTEGER:
onInt(metaName, value);
break;
case StudioTypes.LONG:
Expand Down Expand Up @@ -301,9 +297,7 @@ private Schema inferSchema(final Object data, final RecordBuilderFactory factory
case StudioTypes.LIST:
schema.withEntry(toCollectionEntry(name, originalDbColumnName, raw));
break;
case StudioTypes.OBJECT:
case StudioTypes.STRING:
case StudioTypes.CHARACTER:
case StudioTypes.OBJECT, StudioTypes.STRING, StudioTypes.CHARACTER:
schema.withEntry(toEntry(name, STRING, originalDbColumnName, isNullable, comment, isKey, length,
precision, defaultValue, null, studioType));
break;
Expand All @@ -312,9 +306,7 @@ private Schema inferSchema(final Object data, final RecordBuilderFactory factory
toEntry(name, DECIMAL, originalDbColumnName, isNullable, comment, isKey, length,
precision, defaultValue, null, studioType));
break;
case StudioTypes.INTEGER:
case StudioTypes.SHORT:
case StudioTypes.BYTE:
case StudioTypes.INTEGER, StudioTypes.SHORT, StudioTypes.BYTE:
schema.withEntry(
toEntry(name, INT, originalDbColumnName, isNullable, comment, isKey, null, null,
defaultValue, null, studioType));
Expand Down Expand Up @@ -388,9 +380,7 @@ private void inferDynamicSchema(final Object raw,
case StudioTypes.LIST:
schema.withEntry(toCollectionEntry(metaName, metaOriginalName, value));
break;
case StudioTypes.OBJECT:
case StudioTypes.STRING:
case StudioTypes.CHARACTER:
case StudioTypes.OBJECT, StudioTypes.STRING, StudioTypes.CHARACTER:
schema.withEntry(
toEntry(metaName, STRING, metaOriginalName, metaIsNullable, comment,
metaIsKey, null, null, defaultValue, metaPattern, metaStudioType));
Expand All @@ -404,9 +394,7 @@ private void inferDynamicSchema(final Object raw,
schema.withEntry(toEntry(metaName, BYTES, metaOriginalName, metaIsNullable, comment,
metaIsKey, null, null, defaultValue, null, metaStudioType));
break;
case StudioTypes.BYTE:
case StudioTypes.SHORT:
case StudioTypes.INTEGER:
case StudioTypes.BYTE, StudioTypes.SHORT, StudioTypes.INTEGER:
schema.withEntry(toEntry(metaName, INT, metaOriginalName, metaIsNullable, comment,
metaIsKey, null, null, defaultValue, null, metaStudioType, logicalType));
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -869,8 +869,7 @@ public synchronized void close() {

protected String getTalendType(final JsonValue value) {
switch (value.getValueType()) {
case TRUE:
case FALSE:
case TRUE, FALSE:
return javaTypesManager.BOOLEAN.getId();
case NUMBER:
final Number number = JsonNumber.class.cast(value).numberValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,7 @@ private void configureDefaultsAttributes(final File workDir, final Log log, fina
extractResources(workDir, log);
}
switch (backend.toLowerCase(ENGLISH)) {
case "html":
case "html5":
case "html", "html5":
if (!attributes.containsKey("stylesheet")) {
attrs.attribute("stylesheet", "talend.css");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -560,10 +560,7 @@ private String findDefault(final ParameterMeta p, final DefaultValueInspector.In
}

switch (p.getType()) {
case NUMBER:
case BOOLEAN:
case STRING:
case ENUM:
case NUMBER, BOOLEAN, STRING, ENUM:
return ofNullable(instance.getValue())
.map(String::valueOf)
.map(it -> it.isEmpty() ? "<empty>" : it)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,7 @@ private Contributor loadContributor(final String token, final Client client, fin
private String normalizeLogin(final String login) {
if (login != null) {
switch (login.toLowerCase(ROOT)) {
case "jsomsanith-tlnd":
case "jso-technologies":
case "jsomsanith-tlnd", "jso-technologies":
return "jsomsanith";
case "toutpt":
return "jmfrancois";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ public JsonObject get() {
private Map.Entry<String, JsonValue> toJson(final Schema.Entry entry) {
final JsonObject schema;
switch (entry.getType()) {
case BYTES:
case STRING:
case BYTES, STRING:
schema = jsonBuilderFactory.createObjectBuilder()
.add("type", types("string", entry.isNullable()))
.build();
Expand All @@ -75,14 +74,12 @@ private Map.Entry<String, JsonValue> toJson(final Schema.Entry entry) {
.add("type", types("boolean", entry.isNullable()))
.build();
break;
case FLOAT:
case DOUBLE:
case FLOAT, DOUBLE:
schema = jsonBuilderFactory.createObjectBuilder()
.add("type", types("number", entry.isNullable()))
.build();
break;
case INT:
case LONG:
case INT, LONG:
schema = jsonBuilderFactory.createObjectBuilder()
.add("type", types("integer", entry.isNullable()))
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,7 @@ private Map<String, String> toConfig(final JsonObject object) {
return JsonString.class.cast(e.getValue()).getString();
case NUMBER:
return String.valueOf(JsonNumber.class.cast(e.getValue()).doubleValue());
case TRUE:
case FALSE:
case TRUE, FALSE:
return String.valueOf(JsonValue.TRUE.equals(e.getValue()));
default:
throw new IllegalArgumentException("Unsupported json entry: " + e);
Expand Down
Loading