@Immutable public final class Field extends Object
Configuration instance.| Modifier and Type | Class and Description |
|---|---|
static class |
Field.EnumRecommender<T extends Enum<T>> |
static class |
Field.InvisibleRecommender
A
Field.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
A
Field.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 ranges
|
static 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.
|
| Modifier and Type | Field and Description |
|---|---|
private Supplier<Object> |
defaultValueGenerator |
private List<String> |
dependents |
private String |
desc |
private String |
displayName |
private org.apache.kafka.common.config.ConfigDef.Importance |
importance |
static String |
INTERNAL_PREFIX |
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 |
| Modifier | Constructor and 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,
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,
Supplier<Object> defaultValueGenerator,
Field.Validator validator) |
| Modifier and Type | Method and Description |
|---|---|
static Field |
create(String name)
Create an immutable
Field instance with the given property name. |
static Field |
create(String name,
String displayName)
Create an immutable
Field instance with the given property name. |
static Field |
create(String name,
String displayName,
String description)
Create an immutable
Field instance with the given property name and description. |
static Field |
create(String name,
String displayName,
String description,
boolean defaultValue)
Create an immutable
Field instance with the given property name, description, and default value. |
static Field |
create(String name,
String displayName,
String description,
BooleanSupplier defaultValueGenerator)
Create an immutable
Field instance with the given property name, description, and default value. |
static Field |
create(String name,
String displayName,
String description,
int defaultValue)
Create an immutable
Field instance with the given property name, description, and default value. |
static Field |
create(String name,
String displayName,
String description,
IntSupplier defaultValueGenerator)
Create an immutable
Field instance with the given property name, description, and default value. |
static Field |
create(String name,
String displayName,
String description,
long defaultValue)
Create an immutable
Field instance with the given property name, description, and default value. |
static Field |
create(String name,
String displayName,
String description,
LongSupplier defaultValueGenerator)
Create an immutable
Field instance with the given property name, description, and default value. |
static Field |
create(String name,
String displayName,
String description,
String defaultValue)
Create an immutable
Field instance with the given property name, description, and default value. |
static Field |
create(String name,
String displayName,
String description,
Supplier<Object> defaultValueGenerator)
Create an immutable
Field instance with the given property name, description, and default value. |
static Field |
createInternal(String name)
Create an immutable internal
Field 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) |
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) |
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 the
Field.Recommender for this field. |
static Field.Set |
setOf(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 the
ConfigValue 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 |
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(BooleanSupplier defaultValueGenerator)
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(IntSupplier defaultValueGenerator)
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(LongSupplier defaultValueGenerator)
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 |
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>> |
withEnum(Class<T> enumType)
Create and return a new Field instance that is a copy of this field but has a
type of
Schema.Type.STRING, a recommender
that returns a list of Enum names as valid values, and a validator that verifies values are valid
enumeration names. |
<T extends Enum<T>> |
withEnum(Class<T> enumType,
T defaultOption)
Create and return a new Field instance that is a copy of this field but has a
type of
Schema.Type.STRING, a recommender
that returns a list of Enum names as valid values, and a validator that verifies values are valid
enumeration names. |
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 to
existing
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.
|
public static final String INTERNAL_PREFIX
private final String name
private final String displayName
private final String desc
private final Field.Validator validator
private final org.apache.kafka.common.config.ConfigDef.Width width
private final org.apache.kafka.common.config.ConfigDef.Type type
private final org.apache.kafka.common.config.ConfigDef.Importance importance
private final 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, 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)
public static Field.Set setOf(Field... fields)
fields - the fields to includepublic static Field create(String name)
Field instance with the given property name.name - the name of the field; may not be nullpublic static Field createInternal(String name)
Field instance with the given property name.
The name will be prefixed with internal. prefix.name - the name of the field; may not be nullpublic static Field create(String name, String displayName)
Field instance with the given property name.name - the name of the field; may not be nulldisplayName - the display name of the field; may not be nullpublic static Field create(String name, String displayName, String description)
Field instance with the given property name and description.name - the name of the field; may not be nulldisplayName - the display name of the field; may not be nulldescription - the descriptionpublic static Field create(String name, String displayName, String description, String defaultValue)
Field instance with the given property name, description, and default value.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 fieldpublic static Field create(String name, String displayName, String description, int defaultValue)
Field instance with the given property name, description, and default value.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 fieldpublic static Field create(String name, String displayName, String description, long defaultValue)
Field instance with the given property name, description, and default value.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 fieldpublic static Field create(String name, String displayName, String description, boolean defaultValue)
Field instance with the given property name, description, and default value.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 fieldpublic static Field create(String name, String displayName, String description, Supplier<Object> defaultValueGenerator)
Field instance with the given property name, description, and default value.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 fieldpublic static Field create(String name, String displayName, String description, BooleanSupplier defaultValueGenerator)
Field instance with the given property name, description, and default value.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 fieldpublic static Field create(String name, String displayName, String description, IntSupplier defaultValueGenerator)
Field instance with the given property name, description, and default value.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 fieldpublic static Field create(String name, String displayName, String description, LongSupplier defaultValueGenerator)
Field instance with the given property name, description, and default value.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 fieldpublic static org.apache.kafka.common.config.ConfigDef group(org.apache.kafka.common.config.ConfigDef configDef,
String groupName,
Field... fields)
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 configurationpublic String name()
public Object defaultValue()
null if there is no default valuepublic String defaultValueAsString()
null if there is no default valuepublic String description()
public String displayName()
public org.apache.kafka.common.config.ConfigDef.Width width()
public org.apache.kafka.common.config.ConfigDef.Type type()
public org.apache.kafka.common.config.ConfigDef.Importance importance()
public List<String> dependents()
public Field.Validator validator()
public Field.Recommender recommender()
Field.Recommender for this field.public boolean validate(Configuration config, Field.ValidationOutput problems)
config - the field values keyed by their name; may not be nullproblems - the consumer to be called with each problem; never nulltrue if the value is considered valid, or false if it is not validprotected void validate(Configuration config, Function<String,Field> fieldSupplier, Map<String,org.apache.kafka.common.config.ConfigValue> results)
ConfigValue for the field with the results.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 nullpublic Field withDescription(String description)
description - the new description for the new fieldpublic Field withDisplayName(String displayName)
displayName - the new display name for the fieldpublic Field withWidth(org.apache.kafka.common.config.ConfigDef.Width width)
width - the new width for the fieldpublic Field withType(org.apache.kafka.common.config.ConfigDef.Type type)
type - the new type for the fieldpublic <T extends Enum<T>> Field withEnum(Class<T> enumType)
type of
Schema.Type.STRING, a recommender
that returns a list of Enum names as valid values, and a validator that verifies values are valid
enumeration names.enumType - the enumeration type for the fieldpublic <T extends Enum<T>> Field withEnum(Class<T> enumType, T defaultOption)
type of
Schema.Type.STRING, a recommender
that returns a list of Enum names as valid values, and a validator that verifies values are valid
enumeration names.enumType - the enumeration type for the fielddefaultOption - the default enumeration value; may be nullpublic Field withImportance(org.apache.kafka.common.config.ConfigDef.Importance importance)
importance - the new importance for the fieldpublic Field withDependents(String... dependents)
dependents - the names of the fields that depend on this fieldpublic Field withDefault(String defaultValue)
defaultValue - the new default value for the new fieldpublic Field withDefault(boolean defaultValue)
defaultValue - the new default value for the new fieldpublic Field withDefault(int defaultValue)
defaultValue - the new default value for the new fieldpublic Field withDefault(long defaultValue)
defaultValue - the new default value for the new fieldpublic Field withDefault(BooleanSupplier defaultValueGenerator)
defaultValueGenerator - the supplier for the new default value for the new field, called whenever a default value
is neededpublic Field withDefault(IntSupplier defaultValueGenerator)
defaultValueGenerator - the supplier for the new default value for the new field, called whenever a default value
is neededpublic Field withDefault(LongSupplier defaultValueGenerator)
defaultValueGenerator - the supplier for the new default value for the new field, called whenever a default value
is neededpublic Field withRecommender(Field.Recommender recommender)
recommender - the recommender; may be nullpublic Field withInvisibleRecommender()
public Field withNoValidation()
public Field withValidation(Field.Validator... validators)
existing
validation the supplied validation function(s) are also used.validators - the additional validation function(s); may be nullpublic static Field.Validator validatorForType(org.apache.kafka.common.config.ConfigDef.Type type)
public static int isListOfRegex(Configuration config, Field field, Field.ValidationOutput problems)
public static int isRegex(Configuration config, Field field, Field.ValidationOutput problems)
public static int isClassName(Configuration config, Field field, Field.ValidationOutput problems)
public static int isRequired(Configuration config, Field field, Field.ValidationOutput problems)
public static int isOptional(Configuration config, Field field, Field.ValidationOutput problems)
public static int isBoolean(Configuration config, Field field, Field.ValidationOutput problems)
public static int isInteger(Configuration config, Field field, Field.ValidationOutput problems)
public static int isPositiveInteger(Configuration config, Field field, Field.ValidationOutput problems)
public static int isNonNegativeInteger(Configuration config, Field field, Field.ValidationOutput problems)
public static int isLong(Configuration config, Field field, Field.ValidationOutput problems)
public static int isPositiveLong(Configuration config, Field field, Field.ValidationOutput problems)
public static int isNonNegativeLong(Configuration config, Field field, Field.ValidationOutput problems)
public static int isShort(Configuration config, Field field, Field.ValidationOutput problems)
public static int isDouble(Configuration config, Field field, Field.ValidationOutput problems)
public static int isZoneOffset(Configuration config, Field field, Field.ValidationOutput problems)
Copyright © 2018 JBoss by Red Hat. All rights reserved.