Package io.debezium.config
Class Field
- java.lang.Object
-
- io.debezium.config.Field
-
@Immutable public final class Field extends Object
An immutable definition of a field that make appear within aConfiguration
instance.- Author:
- Randall Hauch
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Field.EnumRecommender<T extends Enum<T>>
static class
Field.Group
static class
Field.GroupEntry
static class
Field.InvisibleRecommender
AField.Recommender
that 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 class
Field.OneOfRecommender
AField.Recommender
that 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 class
Field.RangeValidator
Validation logic for numeric rangesstatic interface
Field.Recommender
A component that is able to provide recommended values for a field given a configuration.static class
Field.Set
A set of fields.static interface
Field.ValidationOutput
A functional interface that accepts validation results.static interface
Field.Validator
A functional interface that can be used to validate field values.
-
Field Summary
Fields Modifier and Type Field Description private Set<?>
allowedValues
private Supplier<Object>
defaultValueGenerator
private List<String>
dependents
private String
desc
private String
displayName
private Field.GroupEntry
group
private org.apache.kafka.common.config.ConfigDef.Importance
importance
static String
INTERNAL_PREFIX
private boolean
isRequired
private String
name
private Field.Recommender
recommender
private org.apache.kafka.common.config.ConfigDef.Type
type
private Field.Validator
validator
private org.apache.kafka.common.config.ConfigDef.Width
width
-
Constructor Summary
Constructors Modifier Constructor Description 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)
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)
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 Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Set<?>
allowedValues()
Get the allowed values for this field.static Field
create(String name)
Create an immutableField
instance with the given property name.static Field
create(String name, String displayName)
Create an immutableField
instance with the given property name.static Field
create(String name, String displayName, String description)
Create an immutableField
instance with the given property name and description.static Field
create(String name, String displayName, String description, boolean defaultValue)
Create an immutableField
instance with the given property name, description, and default value.static Field
create(String name, String displayName, String description, int defaultValue)
Create an immutableField
instance with the given property name, description, and default value.static Field
create(String name, String displayName, String description, long defaultValue)
Create an immutableField
instance with the given property name, description, and default value.static Field
create(String name, String displayName, String description, String defaultValue)
Create an immutableField
instance with the given property name, description, and default value.static Field
create(String name, String displayName, String description, BooleanSupplier defaultValueGenerator)
Create an immutableField
instance with the given property name, description, and default value.static Field
create(String name, String displayName, String description, IntSupplier defaultValueGenerator)
Create an immutableField
instance with the given property name, description, and default value.static Field
create(String name, String displayName, String description, LongSupplier defaultValueGenerator)
Create an immutableField
instance with the given property name, description, and default value.static Field
create(String name, String displayName, String description, Supplier<Object> defaultValueGenerator)
Create an immutableField
instance with the given property name, description, and default value.static Field.GroupEntry
createGroupEntry(Field.Group group)
static Field.GroupEntry
createGroupEntry(Field.Group group, int positionInGroup)
static Field
createInternal(String name)
Create an immutable internalField
instance with the given property name.Object
defaultValue()
Get the default value of the field.String
defaultValueAsString()
Get the string representation of the default value of the field.List<String>
dependents()
Get the names of the fields that are or may be dependent upon this field.String
description()
Get the description of the field.String
displayName()
Get the display name of the field.boolean
equals(Object obj)
private static <T extends Enum<T>>
Set<String>getEnumLiterals(Class<T> enumType)
Field.GroupEntry
group()
Get the group of this field.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.int
hashCode()
org.apache.kafka.common.config.ConfigDef.Importance
importance()
Get the importance of this field.static int
isBoolean(Configuration config, Field field, Field.ValidationOutput problems)
static int
isClassName(Configuration config, Field field, Field.ValidationOutput problems)
static int
isDouble(Configuration config, Field field, Field.ValidationOutput problems)
static int
isInteger(Configuration config, Field field, Field.ValidationOutput problems)
static int
isListOfRegex(Configuration config, Field field, Field.ValidationOutput problems)
static int
isLong(Configuration config, Field field, Field.ValidationOutput problems)
static int
isNonNegativeInteger(Configuration config, Field field, Field.ValidationOutput problems)
static int
isNonNegativeLong(Configuration config, Field field, Field.ValidationOutput problems)
static int
isOptional(Configuration config, Field field, Field.ValidationOutput problems)
static int
isPositiveInteger(Configuration config, Field field, Field.ValidationOutput problems)
static int
isPositiveLong(Configuration config, Field field, Field.ValidationOutput problems)
static int
isRegex(Configuration config, Field field, Field.ValidationOutput problems)
boolean
isRequired()
Get if the field is required/mandatory.static int
isRequired(Configuration config, Field field, Field.ValidationOutput problems)
static int
isShort(Configuration config, Field field, Field.ValidationOutput problems)
static int
isZoneOffset(Configuration config, Field field, Field.ValidationOutput problems)
String
name()
Get the name of the field.Field.Recommender
recommender()
Get theField.Recommender
for this field.Field
required()
static Field.Set
setOf(Field... fields)
Create a set of fields.static Field.Set
setOf(Iterable<Field> fields)
Create a set of fields.String
toString()
org.apache.kafka.common.config.ConfigDef.Type
type()
Get the type of this field.boolean
validate(Configuration config, Field.ValidationOutput problems)
Validate the supplied value for this field, and report any problems to the designated consumer.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 theConfigValue
for the field with the results.Field.Validator
validator()
Get the validator for this field.static Field.Validator
validatorForType(org.apache.kafka.common.config.ConfigDef.Type type)
org.apache.kafka.common.config.ConfigDef.Width
width()
Get the width of this field.Field
withAllowedValues(Set<?> allowedValues)
Field
withDefault(boolean defaultValue)
Create and return a new Field instance that is a copy of this field but with the given default value.Field
withDefault(int defaultValue)
Create and return a new Field instance that is a copy of this field but with the given default value.Field
withDefault(long defaultValue)
Create and return a new Field instance that is a copy of this field but with the given default value.Field
withDefault(String defaultValue)
Create and return a new Field instance that is a copy of this field but with the given default value.Field
withDefault(BooleanSupplier defaultValueGenerator)
Create and return a new Field instance that is a copy of this field but with the given default value.Field
withDefault(IntSupplier defaultValueGenerator)
Create and return a new Field instance that is a copy of this field but with the given default value.Field
withDefault(LongSupplier defaultValueGenerator)
Create and return a new Field instance that is a copy of this field but with the given default value.Field
withDependents(String... dependents)
Create and return a new Field instance that is a copy of this field but with the given display name.Field
withDescription(String description)
Create and return a new Field instance that is a copy of this field but with the given description.Field
withDisplayName(String displayName)
Create and return a new Field instance that is a copy of this field but with the given display name.<T extends Enum<T>>
FieldwithEnum(Class<T> enumType)
Create and return a new Field instance that is a copy of this field but has atype
ofSchema.Type.STRING
, arecommender
that returns a list ofEnum names
as valid values, and a validator that verifies values are valid enumeration names.<T extends Enum<T>>
FieldwithEnum(Class<T> enumType, T defaultOption)
Create and return a new Field instance that is a copy of this field but has atype
ofSchema.Type.STRING
, arecommender
that returns a list ofEnum names
as valid values, and a validator that verifies values are valid enumeration names.Field
withGroup(Field.GroupEntry group)
Field
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.Field
withInvisibleRecommender()
Field
withNoValidation()
Create and return a new Field instance that is a copy of this field but that uses no validation.Field
withRecommender(Field.Recommender recommender)
Create and return a new Field instance that is a copy of this field but with the given recommender.Field
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.Field
withValidation(Field.Validator... validators)
Create and return a new Field instance that is a copy of this field but that in addition toexisting validation
the supplied validation function(s) are also used.Field
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 Detail
-
INTERNAL_PREFIX
public static final String INTERNAL_PREFIX
- See Also:
- Constant Field Values
-
name
private final String name
-
displayName
private final String displayName
-
desc
private final String desc
-
validator
private final Field.Validator 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
-
recommender
private final Field.Recommender recommender
-
allowedValues
private final Set<?> allowedValues
-
group
private final Field.GroupEntry group
-
isRequired
private final boolean isRequired
-
-
Constructor Detail
-
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 Detail
-
setOf
public static Field.Set setOf(Field... fields)
Create a set of fields.- Parameters:
fields
- the fields to include- Returns:
- the field set; never null
-
setOf
public static Field.Set setOf(Iterable<Field> fields)
Create a set of fields.- Parameters:
fields
- the fields to include- Returns:
- the field set; never null
-
createGroupEntry
public static Field.GroupEntry createGroupEntry(Field.Group group)
-
createGroupEntry
public static Field.GroupEntry createGroupEntry(Field.Group group, int positionInGroup)
-
create
public static Field create(String name)
Create an immutableField
instance with the given property name.- Parameters:
name
- the name of the field; may not be null- Returns:
- the field; never null
-
createInternal
public static Field createInternal(String name)
Create an immutable internalField
instance 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
public static Field create(String name, String displayName)
Create an immutableField
instance 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
public static Field create(String name, String displayName, String description)
Create an immutableField
instance 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 immutableField
instance 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, int defaultValue)
Create an immutableField
instance 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, long defaultValue)
Create an immutableField
instance 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 immutableField
instance 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 immutableField
instance 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 immutableField
instance 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 immutableField
instance 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 immutableField
instance 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
public String name()
Get the name of the field.- Returns:
- the name; never null
-
defaultValue
public Object defaultValue()
Get the default value of the field.- Returns:
- the default value, or
null
if there is no default value
-
defaultValueAsString
public String defaultValueAsString()
Get the string representation of the default value of the field.- Returns:
- the default value, or
null
if there is no default value
-
description
public String description()
Get the description of the field.- Returns:
- the description; never null
-
displayName
public String 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
public List<String> 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
public Field.Validator validator()
Get the validator for this field.- Returns:
- the validator; may be null if there is no validator
-
recommender
public Field.Recommender recommender()
Get theField.Recommender
for 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
public Field.GroupEntry group()
Get the group of this field.- Returns:
- the group
-
allowedValues
public Set<?> 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
public boolean validate(Configuration config, Field.ValidationOutput problems)
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:
true
if the value is considered valid, orfalse
if 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 theConfigValue
for 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
public Field withDescription(String description)
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
public Field withDisplayName(String displayName)
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
public Field 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.- Parameters:
width
- the new width for the field- Returns:
- the new field; never null
-
withType
public Field 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.- Parameters:
type
- the new type for the field- Returns:
- the new field; never null
-
withEnum
public <T extends Enum<T>> Field withEnum(Class<T> enumType)
Create and return a new Field instance that is a copy of this field but has atype
ofSchema.Type.STRING
, arecommender
that returns a list ofEnum names
as 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
public <T extends Enum<T>> Field withEnum(Class<T> enumType, T defaultOption)
Create and return a new Field instance that is a copy of this field but has atype
ofSchema.Type.STRING
, arecommender
that returns a list ofEnum names
as 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
public Field required()
-
withGroup
public Field withGroup(Field.GroupEntry group)
-
withImportance
public Field 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.- Parameters:
importance
- the new importance for the field- Returns:
- the new field; never null
-
withDependents
public Field withDependents(String... dependents)
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
public Field withDefault(String defaultValue)
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
public Field withDefault(boolean defaultValue)
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
public Field withDefault(int defaultValue)
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
public Field withDefault(long defaultValue)
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
public Field withDefault(BooleanSupplier defaultValueGenerator)
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
public Field withDefault(IntSupplier defaultValueGenerator)
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
public Field withDefault(LongSupplier defaultValueGenerator)
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
public Field withRecommender(Field.Recommender recommender)
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
public Field withInvisibleRecommender()
-
withNoValidation
public Field 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
public Field withValidation(Field.Validator... validators)
Create and return a new Field instance that is a copy of this field but that in addition toexisting validation
the supplied validation function(s) are also used.- Parameters:
validators
- the additional validation function(s); may be null- Returns:
- the new field; never null
-
validatorForType
public static Field.Validator validatorForType(org.apache.kafka.common.config.ConfigDef.Type type)
-
isListOfRegex
public static int isListOfRegex(Configuration config, Field field, Field.ValidationOutput problems)
-
isRegex
public static int isRegex(Configuration config, Field field, Field.ValidationOutput problems)
-
isClassName
public static int isClassName(Configuration config, Field field, Field.ValidationOutput problems)
-
isRequired
public static int isRequired(Configuration config, Field field, Field.ValidationOutput problems)
-
isOptional
public static int isOptional(Configuration config, Field field, Field.ValidationOutput problems)
-
isBoolean
public static int isBoolean(Configuration config, Field field, Field.ValidationOutput problems)
-
isInteger
public static int isInteger(Configuration config, Field field, Field.ValidationOutput problems)
-
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
public static int isLong(Configuration config, Field field, Field.ValidationOutput problems)
-
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
public static int isShort(Configuration config, Field field, Field.ValidationOutput problems)
-
isDouble
public static int isDouble(Configuration config, Field field, Field.ValidationOutput problems)
-
isZoneOffset
public static int isZoneOffset(Configuration config, Field field, Field.ValidationOutput problems)
-
-