Class PropertyDescriptor.Builder
- Enclosing class:
PropertyDescriptor
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate List
<AllowableValue> private Class
<? extends ControllerService> private String
private Set
<PropertyDependency> private String
private String
private boolean
private boolean
private ExpressionLanguageScope
private String
private boolean
private ResourceDefinition
private boolean
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddValidator
(Validator validator) <E extends Enum<E>>
PropertyDescriptor.BuilderallowableValues
(E[] values) Sets the Allowable Values for this Property.<E extends Enum<E>>
PropertyDescriptor.BuilderallowableValues
(Class<E> enumClass) Sets the Allowable Values for this Property.allowableValues
(String... values) Sets the Allowable Values for this Property.<E extends Enum<E>>
PropertyDescriptor.BuilderallowableValues
(EnumSet<E> enumValues) Sets the Allowable Values for this Property.allowableValues
(Set<String> values) Sets the Allowable Values for this Property.allowableValues
(DescribedValue... values) Sets the Allowable Values for this Property.build()
Clears all Allowable Values from this PropertyClears the initial value and default value from this Property.Clear all Dependencies from this PropertyClear all Validators from this PropertydefaultValue
(String value) Specifies the initial value and the default value that will be used if the user does not specify a value.defaultValue
(DescribedValue value) Specifies the initial value and the default value that will be used if the user does not specify a value.dependsOn
(PropertyDescriptor property, String firstDependentValue, String... additionalDependentValues) Establishes a relationship between this Property and the given property by declaring that this Property is only relevant if the given Property has a value equal to one of the givenString
arguments.dependsOn
(PropertyDescriptor property, AllowableValue... dependentValues) Establishes a relationship between this Property and the given property by declaring that this Property is only relevant if the given Property has a non-null value.dependsOn
(PropertyDescriptor property, DescribedValue firstDependentValue, DescribedValue... additionalDependentValues) Establishes a relationship between this Property and the given property by declaring that this Property is only relevant if the given Property has a value equal to one of the givenDescribedValue
arguments.description
(String description) displayName
(String displayName) Sets a unique id for the property.dynamic
(boolean dynamic) dynamicallyModifiesClasspath
(boolean dynamicallyModifiesClasspath) Specifies that the value of this property represents one or more resources that the framework should add to the classpath of as well as consider when looking for native libraries for the given component.expressionLanguageSupported
(ExpressionLanguageScope expressionLanguageScope) Sets the scope of the expression language evaluationfromPropertyDescriptor
(PropertyDescriptor specDescriptor) identifiesControllerService
(Class<? extends ControllerService> controllerServiceDefinition) Specifies that this property provides the identifier of a Controller Service that implements the given interfaceidentifiesExternalResource
(ResourceCardinality cardinality, ResourceType resourceType, ResourceType... additionalResourceTypes) Specifies that this property references one or more resources that are external to NiFi that the component is meant to consume.private boolean
isValueAllowed
(String value) Sets the property name.required
(boolean required) sensitive
(boolean sensitive)
-
Field Details
-
displayName
-
name
-
description
-
defaultValue
-
allowableValues
-
dependencies
-
required
private boolean required -
sensitive
private boolean sensitive -
expressionLanguageScope
-
dynamic
private boolean dynamic -
dynamicallyModifiesClasspath
private boolean dynamicallyModifiesClasspath -
controllerServiceDefinition
-
resourceDefinition
-
validators
-
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
fromPropertyDescriptor
-
displayName
Sets a unique id for the property. This field is optional and if not specified the PropertyDescriptor's name will be used as the identifying attribute. However, by supplying an id, the PropertyDescriptor's name can be changed without causing problems. This is beneficial because it allows a User Interface to represent the name differently.- Parameters:
displayName
- of the property- Returns:
- the builder
-
name
Sets the property name.- Parameters:
name
- of the property- Returns:
- the builder
-
expressionLanguageSupported
public PropertyDescriptor.Builder expressionLanguageSupported(ExpressionLanguageScope expressionLanguageScope) Sets the scope of the expression language evaluation- Parameters:
expressionLanguageScope
- scope of the expression language evaluation- Returns:
- the builder
-
description
- Parameters:
description
- of the property- Returns:
- the builder
-
defaultValue
Specifies the initial value and the default value that will be used if the user does not specify a value.When
build()
is called, if Allowable Values have been set (seeallowableValues(DescribedValue...)
and overloads) and this value is not one of those Allowable Values, an Exception will be thrown. If the Allowable Values have been set, the default value should be set to the "Value" of theDescribedValue
object (seeDescribedValue.getValue()
). There's an overload available for this (seedefaultValue(DescribedValue)
).- Parameters:
value
- default value- Returns:
- the builder
-
defaultValue
Specifies the initial value and the default value that will be used if the user does not specify a value.Sets the default value to the "Value" of the
DescribedValue
object. Whenbuild()
is called, if Allowable Values have been set (seeallowableValues(DescribedValue...)
and overloads) and this value is not one of those Allowable Values, an Exception will be thrown. In case there is not a restricted set of Allowable ValuesdefaultValue(String)
may be used.- Parameters:
value
- default value holder- Returns:
- the builder
-
clearDefaultValue
Clears the initial value and default value from this Property.- Returns:
- the builder
-
dynamic
-
dynamicallyModifiesClasspath
public PropertyDescriptor.Builder dynamicallyModifiesClasspath(boolean dynamicallyModifiesClasspath) Specifies that the value of this property represents one or more resources that the framework should add to the classpath of as well as consider when looking for native libraries for the given component. NOTE: If a component contains a PropertyDescriptor where dynamicallyModifiesClasspath is set to true, the component may also be annotated with @RequiresInstanceClassloading, in which case every class will be loaded by a separate InstanceClassLoader for each processor instance.
It also allows to load native libraries from the extra classpath. One can choose to omit the annotation. In this case the loading of native libraries from the extra classpath is not supported. Also by default, classes will be loaded by a common NarClassLoader, however it's possible to acquire an InstanceClassLoader by calling Thread.currentThread().getContextClassLoader() which can be used manually to load required classes on an instance-by-instance basis (by callingClass.forName(String, boolean, ClassLoader)
for example).Any property descriptor that dynamically modifies the classpath should also make use of the
identifiesExternalResource(ResourceCardinality, ResourceType, ResourceType...)
method to indicate that the property descriptor references external resources and optionally restrict which types of resources and how many resources the property allows.- Parameters:
dynamicallyModifiesClasspath
- whether or not this property should be used by the framework to modify the classpath- Returns:
- the builder
-
allowableValues
Sets the Allowable Values for this Property.- Parameters:
values
- constrained set of values- Returns:
- the builder
-
allowableValues
Sets the Allowable Values for this Property.Uses the
Enum.name()
of each value as "Value" for theAllowableValue
. In case the enum value is aDescribedValue
, uses the information provided instead (seeDescribedValue.getValue()
,DescribedValue.getDisplayName()
,DescribedValue.getDescription()
).- Parameters:
values
- constrained set of values- Returns:
- the builder
-
allowableValues
Sets the Allowable Values for this Property.Uses the
Enum.name()
of each value fromClass.getEnumConstants()
as "Value" for theAllowableValue
. In case the enum value is aDescribedValue
, uses the information provided instead (seeDescribedValue.getValue()
,DescribedValue.getDisplayName()
,DescribedValue.getDescription()
).- Type Parameters:
E
- generic parameter for an enum class, that may implement the DescribedValue interface- Parameters:
enumClass
- an enum class that contains a set of values and optionally implements the DescribedValue interface- Returns:
- the builder
-
allowableValues
Sets the Allowable Values for this Property.Uses the
Enum.name()
of each value of theEnumSet
as "Value" for theAllowableValue
. In case the enum value is aDescribedValue
, uses the information provided instead (seeDescribedValue.getValue()
,DescribedValue.getDisplayName()
,DescribedValue.getDescription()
).- Type Parameters:
E
- generic parameter for an enum class, that may implement the DescribedValue interface- Parameters:
enumValues
- an enum set that contains a set of values and optionally implements the DescribedValue interface- Returns:
- the builder
-
allowableValues
Sets the Allowable Values for this Property.- Parameters:
values
- constrained set of values- Returns:
- the builder
-
allowableValues
Sets the Allowable Values for this Property.Uses the information provided by each
DescribedValue
(seeDescribedValue.getValue()
,DescribedValue.getDisplayName()
,DescribedValue.getDescription()
) to populate theAllowableValue
s.- Parameters:
values
- constrained set of values- Returns:
- the builder
-
clearAllowableValues
Clears all Allowable Values from this Property- Returns:
- the builder
-
required
- Parameters:
required
- true if yes; false otherwise- Returns:
- the builder
-
sensitive
- Parameters:
sensitive
- true if sensitive; false otherwise- Returns:
- the builder
-
addValidator
- Parameters:
validator
- for the property- Returns:
- the builder
-
clearValidators
Clear all Validators from this Property- Returns:
- the builder
-
identifiesControllerService
public PropertyDescriptor.Builder identifiesControllerService(Class<? extends ControllerService> controllerServiceDefinition) Specifies that this property provides the identifier of a Controller Service that implements the given interface- Parameters:
controllerServiceDefinition
- the interface that is implemented by the Controller Service- Returns:
- the builder
-
isValueAllowed
-
identifiesExternalResource
public PropertyDescriptor.Builder identifiesExternalResource(ResourceCardinality cardinality, ResourceType resourceType, ResourceType... additionalResourceTypes) Specifies that this property references one or more resources that are external to NiFi that the component is meant to consume. Any property descriptor that identifies an external resource will be automatically validated against the following rules:- If the ResourceCardinality is SINGLE, the given property value must be a file, a directory, or a URL that uses a protocol of http/https/file.
- The given resourceTypes dictate which types of input are allowed. For example, if
identifiesExternalResource(ResourceCardinality.SINGLE, ResourceType.FILE)
is used, the input must be a regular file. IfidentifiesExternalResource(ResourceCardinality.SINGLE, ResourceType.FILE, ResourceType.DIRECTORY)
is used, then the input must be exactly one file OR directory. - If the ResourceCardinality is MULTIPLE, the given property value may consist of one or more resources, each separted by a comma and optional white space.
Generally, any property descriptor that makes use of the
dynamicallyModifiesClasspath(boolean)
method to dynamically update its classpath should also make use of this method, specifying which types of resources are allowed and how many.- Parameters:
cardinality
- specifies how many resources the property should allowresourceType
- the type of resource that is allowedadditionalResourceTypes
- if more than one type of resource is allowed, any resource type in addition to the given resource type may be provided- Returns:
- the builder
-
dependsOn
public PropertyDescriptor.Builder dependsOn(PropertyDescriptor property, AllowableValue... dependentValues) Establishes a relationship between this Property and the given property by declaring that this Property is only relevant if the given Property has a non-null value. Furthermore, if one or more explicit Allowable Values are provided, this Property will not be relevant unless the given Property's value is equal to one of the given Allowable Values. If this method is called multiple times, each with a different dependency, then a relationship is established such that this Property is relevant only if all dependencies are satisfied.In the case that this property is NOT considered to be relevant (meaning that it depends on a property whose value is not specified, or whose value does not match one of the given Allowable Values), the property will not be shown in the component's configuration in the User Interface. Additionally, this property's value will not be considered for validation. That is, if this property is configured with an invalid value and this property depends on Property Foo, and Property Foo does not have a value set, then the component will still be valid, because the value of this property is irrelevant.
If the given property is not relevant (because its dependencies are not satisfied), this property is also considered not to be valid.
- Parameters:
property
- the property that must be set in order for this property to become relevantdependentValues
- the possible values for the given property for which this Property is relevant- Returns:
- the builder
-
dependsOn
public PropertyDescriptor.Builder dependsOn(PropertyDescriptor property, String firstDependentValue, String... additionalDependentValues) Establishes a relationship between this Property and the given property by declaring that this Property is only relevant if the given Property has a value equal to one of the givenString
arguments. If this method is called multiple times, each with a different dependency, then a relationship is established such that this Property is relevant only if all dependencies are satisfied.In the case that this property is NOT considered to be relevant (meaning that it depends on a property whose value is not specified, or whose value does not match one of the given Allowable Values), the property will not be shown in the component's configuration in the User Interface. Additionally, this property's value will not be considered for validation. That is, if this property is configured with an invalid value and this property depends on Property Foo, and Property Foo does not have a value set, then the component will still be valid, because the value of this property is irrelevant.
If the given property is not relevant (because its dependencies are not satisfied), this property is also considered not to be valid.
- Parameters:
property
- the property that must be set in order for this property to become relevantfirstDependentValue
- the first value for the given property for which this Property is relevantadditionalDependentValues
- any other values for the given property for which this Property is relevant- Returns:
- the builder
-
dependsOn
public PropertyDescriptor.Builder dependsOn(PropertyDescriptor property, DescribedValue firstDependentValue, DescribedValue... additionalDependentValues) Establishes a relationship between this Property and the given property by declaring that this Property is only relevant if the given Property has a value equal to one of the givenDescribedValue
arguments. If this method is called multiple times, each with a different dependency, then a relationship is established such that this Property is relevant only if all dependencies are satisfied.In the case that this property is NOT considered to be relevant (meaning that it depends on a property whose value is not specified, or whose value does not match one of the given Described Values), the property will not be shown in the component's configuration in the User Interface. Additionally, this property's value will not be considered for validation. That is, if this property is configured with an invalid value and this property depends on Property Foo, and Property Foo does not have a value set, then the component will still be valid, because the value of this property is irrelevant.
If the given property is not relevant (because its dependencies are not satisfied), this property is also considered not to be valid.
- Parameters:
property
- the property that must be set in order for this property to become relevantfirstDependentValue
- the first value for the given property for which this Property is relevantadditionalDependentValues
- any other values for the given property for which this Property is relevant- Returns:
- the builder
-
clearDependsOn
Clear all Dependencies from this Property- Returns:
- the builder
-
build
- Returns:
- a PropertyDescriptor as configured
- Throws:
IllegalStateException
- if allowable values are configured but no default value is set, or the default value is not contained within the allowable values.
-