Package io.debezium.config
Class Field
java.lang.Object
io.debezium.config.Field
An immutable definition of a field that make appear within a
Configuration instance.- Author:
- Randall Hauch
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classField.EnumRecommender<T extends Enum<T>>static enumstatic classstatic classAField.Recommenderthat will look at several fields that are deemed to be exclusive, such that when the first of them has a value the others are made invisible.static classAField.Recommenderthat will look at several fields that are deemed to be exclusive, such that when the first of them has a value the others are made invisible.static classValidation logic for numeric rangesstatic interfaceA component that is able to provide recommended values for a field given a configuration.static final classA set of fields.static interfaceA functional interface that accepts validation results.static interfaceA functional interface that can be used to validate field values. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Set<?>private final Stringprivate final Stringprivate static final Stringprivate final Field.GroupEntryprivate final org.apache.kafka.common.config.ConfigDef.Importancestatic final Stringprivate final booleanprivate final Stringprivate final Field.Recommenderprivate static final CharSequenceprivate final org.apache.kafka.common.config.ConfigDef.Typeprivate final Field.Validatorprivate final org.apache.kafka.common.config.ConfigDef.Width -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedField(String name, String displayName, org.apache.kafka.common.config.ConfigDef.Type type, org.apache.kafka.common.config.ConfigDef.Width width, String description, org.apache.kafka.common.config.ConfigDef.Importance importance, Supplier<Object> defaultValueGenerator, Field.Validator validator) protectedField(String name, String displayName, org.apache.kafka.common.config.ConfigDef.Type type, org.apache.kafka.common.config.ConfigDef.Width width, String description, org.apache.kafka.common.config.ConfigDef.Importance importance, List<String> dependents, Supplier<Object> defaultValueGenerator, Field.Validator validator, Field.Recommender recommender) protectedField(String name, String displayName, org.apache.kafka.common.config.ConfigDef.Type type, org.apache.kafka.common.config.ConfigDef.Width width, String description, org.apache.kafka.common.config.ConfigDef.Importance importance, List<String> dependents, Supplier<Object> defaultValueGenerator, Field.Validator validator, Field.Recommender recommender, boolean isRequired, Field.GroupEntry group, Set<?> allowedValues) -
Method Summary
Modifier and TypeMethodDescriptionSet<?>Get the allowed values for this field.static FieldCreate an immutableFieldinstance with the given property name.static FieldCreate an immutableFieldinstance with the given property name.static FieldCreate an immutableFieldinstance with the given property name and description.static FieldCreate an immutableFieldinstance with the given property name, description, and default value.static FieldCreate an immutableFieldinstance with the given property name, description, and default value.static FieldCreate an immutableFieldinstance with the given property name, description, and default value.static FieldCreate an immutableFieldinstance with the given property name, description, and default value.static Fieldcreate(String name, String displayName, String description, BooleanSupplier defaultValueGenerator) Create an immutableFieldinstance with the given property name, description, and default value.static Fieldcreate(String name, String displayName, String description, IntSupplier defaultValueGenerator) Create an immutableFieldinstance with the given property name, description, and default value.static Fieldcreate(String name, String displayName, String description, LongSupplier defaultValueGenerator) Create an immutableFieldinstance with the given property name, description, and default value.static FieldCreate an immutableFieldinstance with the given property name, description, and default value.static Field.GroupEntrycreateGroupEntry(Field.Group group) static Field.GroupEntrycreateGroupEntry(Field.Group group, int positionInGroup) static FieldcreateInternal(String name) Create an immutable internalFieldinstance with the given property name.Get the default value of the field.Get the string representation of the default value of the field.Get the names of the fields that are or may be dependent upon this field.Get the description of the field.Get the display name of the field.booleangetEnumLiterals(Class<T> enumType) group()Get the group of this field.static org.apache.kafka.common.config.ConfigDefAdd this field to the given configuration definition.inthashCode()org.apache.kafka.common.config.ConfigDef.ImportanceGet the importance of this field.static intisBoolean(Configuration config, Field field, Field.ValidationOutput problems) static intisClassName(Configuration config, Field field, Field.ValidationOutput problems) static intisDouble(Configuration config, Field field, Field.ValidationOutput problems) static intisInteger(Configuration config, Field field, Field.ValidationOutput problems) static intisListOfRegex(Configuration config, Field field, Field.ValidationOutput problems) static intisLong(Configuration config, Field field, Field.ValidationOutput problems) static intisNonNegativeInteger(Configuration config, Field field, Field.ValidationOutput problems) static intisNonNegativeLong(Configuration config, Field field, Field.ValidationOutput problems) static intisOptional(Configuration config, Field field, Field.ValidationOutput problems) static intisPositiveInteger(Configuration config, Field field, Field.ValidationOutput problems) static intisPositiveLong(Configuration config, Field field, Field.ValidationOutput problems) static intisRegex(Configuration config, Field field, Field.ValidationOutput problems) booleanGet if the field is required/mandatory.static intisRequired(Configuration config, Field field, Field.ValidationOutput problems) static intisShort(Configuration config, Field field, Field.ValidationOutput problems) static intisZoneOffset(Configuration config, Field field, Field.ValidationOutput problems) name()Get the name of the field.static intnotContainEmptyElements(Configuration config, Field field, Field.ValidationOutput problems) static intnotContainSpaceInAnyElement(Configuration config, Field field, Field.ValidationOutput problems) optional()Get theField.Recommenderfor this field.required()static Field.SetCreate a set of fields.static Field.SetCreate a set of fields.toString()org.apache.kafka.common.config.ConfigDef.Typetype()Get the type of this field.booleanvalidate(Configuration config, Field.ValidationOutput problems) Validate the supplied value for this field, and report any problems to the designated consumer.protected voidvalidate(Configuration config, Function<String, Field> fieldSupplier, Map<String, org.apache.kafka.common.config.ConfigValue> results) Validate this field in the supplied configuration, updating theConfigValuefor the field with the results.static StringvalidationOutput(Field field, String problem) Get the validator for this field.static Field.ValidatorvalidatorForType(org.apache.kafka.common.config.ConfigDef.Type type) org.apache.kafka.common.config.ConfigDef.Widthwidth()Get the width of this field.withAllowedValues(Set<?> allowedValues) withDefault(boolean defaultValue) Create and return a new Field instance that is a copy of this field but with the given default value.withDefault(int defaultValue) Create and return a new Field instance that is a copy of this field but with the given default value.withDefault(long defaultValue) Create and return a new Field instance that is a copy of this field but with the given default value.withDefault(String defaultValue) Create and return a new Field instance that is a copy of this field but with the given default value.withDefault(BooleanSupplier defaultValueGenerator) Create and return a new Field instance that is a copy of this field but with the given default value.withDefault(IntSupplier defaultValueGenerator) Create and return a new Field instance that is a copy of this field but with the given default value.withDefault(LongSupplier defaultValueGenerator) Create and return a new Field instance that is a copy of this field but with the given default value.withDependents(String... dependents) Create and return a new Field instance that is a copy of this field but with the given display name.withDescription(String description) Create and return a new Field instance that is a copy of this field but with the given description.withDisplayName(String displayName) Create and return a new Field instance that is a copy of this field but with the given display name.Create and return a new Field instance that is a copy of this field but has atypeofSchema.Type.STRING, arecommenderthat returns a list ofEnum namesas valid values, and a validator that verifies values are valid enumeration names.Create and return a new Field instance that is a copy of this field but has atypeofSchema.Type.STRING, arecommenderthat returns a list ofEnum namesas valid values, and a validator that verifies values are valid enumeration names.withGroup(Field.GroupEntry group) withImportance(org.apache.kafka.common.config.ConfigDef.Importance importance) Create and return a new Field instance that is a copy of this field but with the given importance.Create and return a new Field instance that is a copy of this field but that uses no validation.withRecommender(Field.Recommender recommender) Create and return a new Field instance that is a copy of this field but with the given recommender.withType(org.apache.kafka.common.config.ConfigDef.Type type) Create and return a new Field instance that is a copy of this field but with the given type.withValidation(Field.Validator... validators) Create and return a new Field instance that is a copy of this field but that in addition toexisting validationthe supplied validation function(s) are also used.withWidth(org.apache.kafka.common.config.ConfigDef.Width width) Create and return a new Field instance that is a copy of this field but with the given width.
-
Field Details
-
INTERNAL_PREFIX
- See Also:
-
EMPTY_STRING
- See Also:
-
SPACE
-
name
-
displayName
-
desc
-
defaultValueGenerator
-
validator
-
width
private final org.apache.kafka.common.config.ConfigDef.Width width -
type
private final org.apache.kafka.common.config.ConfigDef.Type type -
importance
private final org.apache.kafka.common.config.ConfigDef.Importance importance -
dependents
-
recommender
-
allowedValues
-
group
-
isRequired
private final boolean isRequired
-
-
Constructor Details
-
Field
protected Field(String name, String displayName, org.apache.kafka.common.config.ConfigDef.Type type, org.apache.kafka.common.config.ConfigDef.Width width, String description, org.apache.kafka.common.config.ConfigDef.Importance importance, Supplier<Object> defaultValueGenerator, Field.Validator validator) -
Field
protected Field(String name, String displayName, org.apache.kafka.common.config.ConfigDef.Type type, org.apache.kafka.common.config.ConfigDef.Width width, String description, org.apache.kafka.common.config.ConfigDef.Importance importance, List<String> dependents, Supplier<Object> defaultValueGenerator, Field.Validator validator, Field.Recommender recommender) -
Field
protected Field(String name, String displayName, org.apache.kafka.common.config.ConfigDef.Type type, org.apache.kafka.common.config.ConfigDef.Width width, String description, org.apache.kafka.common.config.ConfigDef.Importance importance, List<String> dependents, Supplier<Object> defaultValueGenerator, Field.Validator validator, Field.Recommender recommender, boolean isRequired, Field.GroupEntry group, Set<?> allowedValues)
-
-
Method Details
-
setOf
Create a set of fields.- Parameters:
fields- the fields to include- Returns:
- the field set; never null
-
setOf
Create a set of fields.- Parameters:
fields- the fields to include- Returns:
- the field set; never null
-
createGroupEntry
-
createGroupEntry
-
create
Create an immutableFieldinstance with the given property name.- Parameters:
name- the name of the field; may not be null- Returns:
- the field; never null
-
createInternal
Create an immutable internalFieldinstance with the given property name. The name will be prefixed withinternal.prefix.- Parameters:
name- the name of the field; may not be null- Returns:
- the field; never null
-
create
Create an immutableFieldinstance with the given property name.- Parameters:
name- the name of the field; may not be nulldisplayName- the display name of the field; may not be null- Returns:
- the field; never null
-
create
Create an immutableFieldinstance with the given property name and description.- Parameters:
name- the name of the field; may not be nulldisplayName- the display name of the field; may not be nulldescription- the description- Returns:
- the field; never null
-
create
public static Field create(String name, String displayName, String description, String defaultValue) Create an immutableFieldinstance with the given property name, description, and default value.- Parameters:
name- the name of the field; may not be nulldisplayName- the display name of the field; may not be nulldescription- the descriptiondefaultValue- the default value for the field- Returns:
- the field; never null
-
create
Create an immutableFieldinstance with the given property name, description, and default value.- Parameters:
name- the name of the field; may not be nulldisplayName- the display name of the field; may not be nulldescription- the descriptiondefaultValue- the default value for the field- Returns:
- the field; never null
-
create
Create an immutableFieldinstance with the given property name, description, and default value.- Parameters:
name- the name of the field; may not be nulldisplayName- the display name of the field; may not be nulldescription- the descriptiondefaultValue- the default value for the field- Returns:
- the field; never null
-
create
public static Field create(String name, String displayName, String description, boolean defaultValue) Create an immutableFieldinstance with the given property name, description, and default value.- Parameters:
name- the name of the field; may not be nulldisplayName- the display name of the field; may not be nulldescription- the descriptiondefaultValue- the default value for the field- Returns:
- the field; never null
-
create
public static Field create(String name, String displayName, String description, Supplier<Object> defaultValueGenerator) Create an immutableFieldinstance with the given property name, description, and default value.- Parameters:
name- the name of the field; may not be nulldisplayName- the display name of the field; may not be nulldescription- the descriptiondefaultValueGenerator- the generator for the default value for the field- Returns:
- the field; never null
-
create
public static Field create(String name, String displayName, String description, BooleanSupplier defaultValueGenerator) Create an immutableFieldinstance with the given property name, description, and default value.- Parameters:
name- the name of the field; may not be nulldisplayName- the display name of the field; may not be nulldescription- the descriptiondefaultValueGenerator- the generator for the default value for the field- Returns:
- the field; never null
-
create
public static Field create(String name, String displayName, String description, IntSupplier defaultValueGenerator) Create an immutableFieldinstance with the given property name, description, and default value.- Parameters:
name- the name of the field; may not be nulldisplayName- the display name of the field; may not be nulldescription- the descriptiondefaultValueGenerator- the generator for the default value for the field- Returns:
- the field; never null
-
create
public static Field create(String name, String displayName, String description, LongSupplier defaultValueGenerator) Create an immutableFieldinstance with the given property name, description, and default value.- Parameters:
name- the name of the field; may not be nulldisplayName- the display name of the field; may not be nulldescription- the descriptiondefaultValueGenerator- the generator for the default value for the field- Returns:
- the field; never null
-
group
public static org.apache.kafka.common.config.ConfigDef group(org.apache.kafka.common.config.ConfigDef configDef, String groupName, Field... fields) Add this field to the given configuration definition.- Parameters:
configDef- the definition of the configuration; may be null if none of the fields are to be addedgroupName- the name of the group; may be nullfields- the fields to be added as a group to the definition of the configuration- Returns:
- the updated configuration; never null
-
name
Get the name of the field.- Returns:
- the name; never null
-
defaultValue
Get the default value of the field.- Returns:
- the default value, or
nullif there is no default value
-
defaultValueAsString
Get the string representation of the default value of the field.- Returns:
- the default value, or
nullif there is no default value
-
description
Get the description of the field.- Returns:
- the description; never null
-
displayName
Get the display name of the field.- Returns:
- the display name; never null
-
width
public org.apache.kafka.common.config.ConfigDef.Width width()Get the width of this field.- Returns:
- the width; never null
-
type
public org.apache.kafka.common.config.ConfigDef.Type type()Get the type of this field.- Returns:
- the type; never null
-
importance
public org.apache.kafka.common.config.ConfigDef.Importance importance()Get the importance of this field.- Returns:
- the importance; never null
-
dependents
Get the names of the fields that are or may be dependent upon this field.- Returns:
- the list of dependents; never null but possibly empty
-
validator
Get the validator for this field.- Returns:
- the validator; may be null if there is no validator
-
recommender
Get theField.Recommenderfor this field.- Returns:
- the recommender; may be null if there is no recommender
-
isRequired
public boolean isRequired()Get if the field is required/mandatory.- Returns:
- if the field is required; true or false
-
group
Get the group of this field.- Returns:
- the group
-
allowedValues
Get the allowed values for this field.- Returns:
- the java.util.Set of allowed values; may be null if there's no set of specific values
-
validate
Validate the supplied value for this field, and report any problems to the designated consumer.- Parameters:
config- the field values keyed by their name; may not be nullproblems- the consumer to be called with each problem; never null- Returns:
trueif the value is considered valid, orfalseif it is not valid
-
validate
protected void validate(Configuration config, Function<String, Field> fieldSupplier, Map<String, org.apache.kafka.common.config.ConfigValue> results) Validate this field in the supplied configuration, updating theConfigValuefor the field with the results.- Parameters:
config- the configuration to be validated; may not be nullfieldSupplier- the supplier for dependent fields by name; may not be nullresults- the set of configuration results keyed by field name; may not be null
-
withDescription
Create and return a new Field instance that is a copy of this field but with the given description.- Parameters:
description- the new description for the new field- Returns:
- the new field; never null
-
withDisplayName
Create and return a new Field instance that is a copy of this field but with the given display name.- Parameters:
displayName- the new display name for the field- Returns:
- the new field; never null
-
withWidth
Create and return a new Field instance that is a copy of this field but with the given width.- Parameters:
width- the new width for the field- Returns:
- the new field; never null
-
withType
Create and return a new Field instance that is a copy of this field but with the given type.- Parameters:
type- the new type for the field- Returns:
- the new field; never null
-
withEnum
Create and return a new Field instance that is a copy of this field but has atypeofSchema.Type.STRING, arecommenderthat returns a list ofEnum namesas valid values, and a validator that verifies values are valid enumeration names.- Parameters:
enumType- the enumeration type for the field- Returns:
- the new field; never null
-
withEnum
Create and return a new Field instance that is a copy of this field but has atypeofSchema.Type.STRING, arecommenderthat returns a list ofEnum namesas valid values, and a validator that verifies values are valid enumeration names.- Parameters:
enumType- the enumeration type for the fielddefaultOption- the default enumeration value; may be null- Returns:
- the new field; never null
-
required
-
optional
-
withGroup
-
withAllowedValues
-
withImportance
Create and return a new Field instance that is a copy of this field but with the given importance.- Parameters:
importance- the new importance for the field- Returns:
- the new field; never null
-
withDependents
Create and return a new Field instance that is a copy of this field but with the given display name.- Parameters:
dependents- the names of the fields that depend on this field- Returns:
- the new field; never null
-
withDefault
Create and return a new Field instance that is a copy of this field but with the given default value.- Parameters:
defaultValue- the new default value for the new field- Returns:
- the new field; never null
-
withDefault
Create and return a new Field instance that is a copy of this field but with the given default value.- Parameters:
defaultValue- the new default value for the new field- Returns:
- the new field; never null
-
withDefault
Create and return a new Field instance that is a copy of this field but with the given default value.- Parameters:
defaultValue- the new default value for the new field- Returns:
- the new field; never null
-
withDefault
Create and return a new Field instance that is a copy of this field but with the given default value.- Parameters:
defaultValue- the new default value for the new field- Returns:
- the new field; never null
-
withDefault
Create and return a new Field instance that is a copy of this field but with the given default value.- Parameters:
defaultValueGenerator- the supplier for the new default value for the new field, called whenever a default value is needed- Returns:
- the new field; never null
-
withDefault
Create and return a new Field instance that is a copy of this field but with the given default value.- Parameters:
defaultValueGenerator- the supplier for the new default value for the new field, called whenever a default value is needed- Returns:
- the new field; never null
-
withDefault
Create and return a new Field instance that is a copy of this field but with the given default value.- Parameters:
defaultValueGenerator- the supplier for the new default value for the new field, called whenever a default value is needed- Returns:
- the new field; never null
-
withRecommender
Create and return a new Field instance that is a copy of this field but with the given recommender.- Parameters:
recommender- the recommender; may be null- Returns:
- the new field; never null
-
withInvisibleRecommender
-
withNoValidation
Create and return a new Field instance that is a copy of this field but that uses no validation.- Returns:
- the new field; never null
-
withValidation
Create and return a new Field instance that is a copy of this field but that in addition toexisting validationthe supplied validation function(s) are also used.- Parameters:
validators- the additional validation function(s); may be null- Returns:
- the new field; never null
-
hashCode
public int hashCode() -
equals
-
toString
-
getEnumLiterals
-
validatorForType
-
isListOfRegex
-
isRegex
-
isClassName
-
isRequired
-
isOptional
-
isBoolean
-
isInteger
-
isPositiveInteger
public static int isPositiveInteger(Configuration config, Field field, Field.ValidationOutput problems) -
isNonNegativeInteger
public static int isNonNegativeInteger(Configuration config, Field field, Field.ValidationOutput problems) -
isLong
-
isPositiveLong
public static int isPositiveLong(Configuration config, Field field, Field.ValidationOutput problems) -
isNonNegativeLong
public static int isNonNegativeLong(Configuration config, Field field, Field.ValidationOutput problems) -
isShort
-
isDouble
-
isZoneOffset
-
notContainEmptyElements
public static int notContainEmptyElements(Configuration config, Field field, Field.ValidationOutput problems) -
notContainSpaceInAnyElement
public static int notContainSpaceInAnyElement(Configuration config, Field field, Field.ValidationOutput problems) -
validationOutput
-