MINOR: Small javadoc/code cleanups in connect api and transforms (#12558)

Reviewers: Luke Chen <showuon@gmail.com>, Divij Vaidya <diviv@amazon.com>
This commit is contained in:
Mickael Maison 2022-08-29 09:44:56 +02:00 committed by GitHub
parent f83c6f2da4
commit d606eb46ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 20 additions and 23 deletions

View File

@ -24,7 +24,7 @@ public interface Versioned {
/** /**
* Get the version of this component. * Get the version of this component.
* *
* @return the version, formatted as a String. The version may not be (@code null} or empty. * @return the version, formatted as a String. The version may not be {@code null} or empty.
*/ */
String version(); String version();
} }

View File

@ -34,7 +34,7 @@ public interface ConnectorClientConfigOverridePolicy extends Configurable, AutoC
/** /**
* Worker will invoke this while constructing the producer for the SourceConnectors, DLQ for SinkConnectors and the consumer for the * Worker will invoke this while constructing the producer for the SourceConnectors, DLQ for SinkConnectors and the consumer for the
* SinkConnectors to validate if all of the overridden client configurations are allowed per the * SinkConnectors to validate if all of the overridden client configurations are allowed per the
* policy implementation. This would also be invoked during the validate of connector configs via the Rest API. * policy implementation. This would also be invoked during the validation of connector configs via the Rest API.
* *
* If there are any policy violations, the connector will not be started. * If there are any policy violations, the connector will not be started.
* *

View File

@ -104,7 +104,7 @@ public interface Schema {
*/ */
STRUCT; STRUCT;
private String name; private final String name;
Type() { Type() {
this.name = this.name().toLowerCase(Locale.ROOT); this.name = this.name().toLowerCase(Locale.ROOT);

View File

@ -54,7 +54,7 @@ public class SchemaProjector {
* @param record the value to project from source schema to target schema * @param record the value to project from source schema to target schema
* @param target the schema to project the record to * @param target the schema to project the record to
* @return the projected value with target schema * @return the projected value with target schema
* @throws SchemaProjectorException * @throws SchemaProjectorException if the target schema is not optional and does not have a default value
*/ */
public static Object project(Schema source, Object record, Schema target) throws SchemaProjectorException { public static Object project(Schema source, Object record, Schema target) throws SchemaProjectorException {
checkMaybeCompatible(source, target); checkMaybeCompatible(source, target);

View File

@ -100,7 +100,7 @@ public class Values {
private static final Pattern TWO_BACKSLASHES = Pattern.compile("\\\\"); private static final Pattern TWO_BACKSLASHES = Pattern.compile("\\\\");
private static final Pattern DOUBLEQOUTE = Pattern.compile("\""); private static final Pattern DOUBLE_QUOTE = Pattern.compile("\"");
/** /**
* Convert the specified value to an {@link Type#BOOLEAN} value. The supplied schema is required if the value is a logical * Convert the specified value to an {@link Type#BOOLEAN} value. The supplied schema is required if the value is a logical
@ -584,8 +584,7 @@ public class Values {
break; break;
case STRUCT: case STRUCT:
if (value instanceof Struct) { if (value instanceof Struct) {
Struct struct = (Struct) value; return value;
return struct;
} }
} }
throw new DataException("Unable to convert " + value + " (" + value.getClass() + ") to " + toSchema); throw new DataException("Unable to convert " + value + " (" + value.getClass() + ") to " + toSchema);
@ -732,7 +731,7 @@ public class Values {
protected static String escape(String value) { protected static String escape(String value) {
String replace1 = TWO_BACKSLASHES.matcher(value).replaceAll("\\\\\\\\"); String replace1 = TWO_BACKSLASHES.matcher(value).replaceAll("\\\\\\\\");
return DOUBLEQOUTE.matcher(replace1).replaceAll("\\\\\""); return DOUBLE_QUOTE.matcher(replace1).replaceAll("\\\\\"");
} }
public static DateFormat dateFormatFor(java.util.Date value) { public static DateFormat dateFormatFor(java.util.Date value) {

View File

@ -48,7 +48,7 @@ public interface ConnectRestExtension extends Configurable, Versioned, Closeable
/** /**
* ConnectRestExtension implementations can register custom JAX-RS resources via the {@link #register(ConnectRestExtensionContext)} * ConnectRestExtension implementations can register custom JAX-RS resources via the {@link #register(ConnectRestExtensionContext)}
* method. The Connect framework will invoke this method after registering the default Connect resources. If the implementations attempt * method. The Connect framework will invoke this method after registering the default Connect resources. If the implementations attempt
* to re-register any of the Connect resources, it will be be ignored and will be logged. * to re-register any of the Connect resources, it will be ignored and will be logged.
* *
* @param restPluginContext The context provides access to JAX-RS {@link javax.ws.rs.core.Configurable} and {@link * @param restPluginContext The context provides access to JAX-RS {@link javax.ws.rs.core.Configurable} and {@link
* ConnectClusterState}.The custom JAX-RS resources can be registered via the {@link * ConnectClusterState}.The custom JAX-RS resources can be registered via the {@link

View File

@ -27,5 +27,5 @@ public enum ExactlyOnceSupport {
/** /**
* Signals that a connector does not support exactly-once delivery. * Signals that a connector does not support exactly-once delivery.
*/ */
UNSUPPORTED; UNSUPPORTED
} }

View File

@ -52,7 +52,7 @@ public enum ConverterType {
return NAME_TO_TYPE.get(name.toLowerCase(Locale.getDefault())); return NAME_TO_TYPE.get(name.toLowerCase(Locale.getDefault()));
} }
private String name; private final String name;
ConverterType() { ConverterType() {
this.name = this.name().toLowerCase(Locale.ROOT); this.name = this.name().toLowerCase(Locale.ROOT);

View File

@ -62,7 +62,7 @@ public class SourceRecordTest {
} }
@Test @Test
public void shouldCreateSinkRecordWithEmtpyHeaders() { public void shouldCreateSinkRecordWithEmptyHeaders() {
assertEquals(SOURCE_PARTITION, record.sourcePartition()); assertEquals(SOURCE_PARTITION, record.sourcePartition());
assertEquals(SOURCE_OFFSET, record.sourceOffset()); assertEquals(SOURCE_OFFSET, record.sourceOffset());
assertEquals(TOPIC_NAME, record.topic()); assertEquals(TOPIC_NAME, record.topic());

View File

@ -32,7 +32,7 @@ public class StringConverterTest {
private static final String TOPIC = "topic"; private static final String TOPIC = "topic";
private static final String SAMPLE_STRING = "a string"; private static final String SAMPLE_STRING = "a string";
private StringConverter converter = new StringConverter(); private final StringConverter converter = new StringConverter();
@Test @Test
public void testStringToBytes() { public void testStringToBytes() {

View File

@ -284,7 +284,7 @@ public abstract class Cast<R extends ConnectRecord<R>> implements Transformation
case STRING: case STRING:
return castToString(value); return castToString(value);
default: default:
throw new DataException(targetType.toString() + " is not supported in the Cast transformation."); throw new DataException(targetType + " is not supported in the Cast transformation.");
} }
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
throw new DataException("Value (" + value.toString() + ") was out of range for requested data type", e); throw new DataException("Value (" + value.toString() + ") was out of range for requested data type", e);

View File

@ -32,7 +32,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
public class DropHeadersTest { public class DropHeadersTest {
private DropHeaders<SourceRecord> xform = new DropHeaders<>(); private final DropHeaders<SourceRecord> xform = new DropHeaders<>();
private Map<String, ?> config(String... headers) { private Map<String, ?> config(String... headers) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
@ -109,9 +109,8 @@ public class DropHeadersTest {
Object value = "value"; Object value = "value";
Long timestamp = 0L; Long timestamp = 0L;
SourceRecord record = new SourceRecord(sourcePartition, sourceOffset, topic, partition, return new SourceRecord(sourcePartition, sourceOffset, topic, partition,
keySchema, key, valueSchema, value, timestamp, headers); keySchema, key, valueSchema, value, timestamp, headers);
return record;
} }
} }

View File

@ -36,8 +36,8 @@ import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertThrows;
public class InsertFieldTest { public class InsertFieldTest {
private InsertField<SourceRecord> xformKey = new InsertField.Key<>(); private final InsertField<SourceRecord> xformKey = new InsertField.Key<>();
private InsertField<SourceRecord> xformValue = new InsertField.Value<>(); private final InsertField<SourceRecord> xformValue = new InsertField.Value<>();
@AfterEach @AfterEach
public void teardown() { public void teardown() {

View File

@ -32,7 +32,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
public class InsertHeaderTest { public class InsertHeaderTest {
private InsertHeader<SourceRecord> xform = new InsertHeader<>(); private final InsertHeader<SourceRecord> xform = new InsertHeader<>();
private Map<String, ?> config(String header, String valueLiteral) { private Map<String, ?> config(String header, String valueLiteral) {
Map<String, String> result = new HashMap<>(); Map<String, String> result = new HashMap<>();
@ -113,9 +113,8 @@ public class InsertHeaderTest {
Object value = "value"; Object value = "value";
Long timestamp = 0L; Long timestamp = 0L;
SourceRecord record = new SourceRecord(sourcePartition, sourceOffset, topic, partition, return new SourceRecord(sourcePartition, sourceOffset, topic, partition,
keySchema, key, valueSchema, value, timestamp, headers); keySchema, key, valueSchema, value, timestamp, headers);
return record;
} }
} }

View File

@ -30,7 +30,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertNull;
public class ReplaceFieldTest { public class ReplaceFieldTest {
private ReplaceField<SinkRecord> xform = new ReplaceField.Value<>(); private final ReplaceField<SinkRecord> xform = new ReplaceField.Value<>();
@AfterEach @AfterEach
public void teardown() { public void teardown() {