Class ValueDescriptorFactory
- java.lang.Object
-
- de.xima.fc.workflow.processor.value.ValueDescriptorFactory
-
- All Implemented Interfaces:
IValueDescriptorFactory,Serializable
@Immutable public final class ValueDescriptorFactory extends Object implements IValueDescriptorFactory, Serializable
Default implementation of theIValueDescriptorFactory.- Since:
- 7.0.0
- Author:
- XIMA MEDIA GmbH
- See Also:
- Serialized Form
-
-
Method Summary
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.xima.fc.interfaces.workflow.value.IValueDescriptorFactory
any, bool, bool, bool, constant, constant, constant, constant, constant, floating, floating, floating, integer, integer, integer, largeString, largeString, largeString, list, list, listOfLargeStrings, listOfLargeStrings, listOfStrings, listOfStrings, map, map, mapToLargeStrings, mapToLargeStrings, mapToStrings, mapToStrings, nullish, nullish, record, requiredString, requiredString, requiredStringBuilder, string, string, string, tuple, tuple, tuple, tupleOfSame, tupleOfSame, unionBuilder, unionEmpty, unionEnumBuilder, unionOfEnumConst, unionOfEnumConst, unionOfEnumConstBuilder, unionOfEnumConstBuilder, unionOfStringConst, unionOfStringConst, unionOfStringConst, unionOfStringConstBuilder, unionOfStringConstBuilder, unionOfStringConstBuilder, unionStringBuilder, unionWithNull, unionWithNullBuilder
-
-
-
-
Method Detail
-
accessAtPath
public List<?> accessAtPath(Object base, String path)
Description copied from interface:IValueDescriptorFactoryAccess a nested property in an object at a given JSON path.- Specified by:
accessAtPathin interfaceIValueDescriptorFactory- Parameters:
base- Base object with data to access.path- JSON path to the data to access.- Returns:
- The data at the given path in the base object.
-
any
public IAnyValueDescriptor any()
Description copied from interface:IValueDescriptorFactoryGets a value descriptor that allows any type of value. When no value is provided, defaults tonull(i.e. like aINullValueDescriptor).- Specified by:
anyin interfaceIValueDescriptorFactory- Returns:
- A descriptor for an any value that defaults to the given value. The description uses the default i18n key determined from the root class and the path to this property.
-
anyBuilder
public IAnyValueDescriptorBuilder anyBuilder()
- Specified by:
anyBuilderin interfaceIValueDescriptorFactory- Returns:
- A descriptor builder for an any value.
-
boolBuilder
public IBooleanValueDescriptorBuilder boolBuilder()
- Specified by:
boolBuilderin interfaceIValueDescriptorFactory- Returns:
- A descriptor builder for a boolean value.
-
constant
public IValueDescriptor<?,?> constant(Object value)
Description copied from interface:IValueDescriptorFactoryCreates a value descriptor that only admits the given constant value. The given value must be a JSON-like value, i.e. null, aBoolean, aNumber, aStringorLargeString, aListof JSON values, or aMapfrom strings to JSON values.- Specified by:
constantin interfaceIValueDescriptorFactory- Parameters:
value- The constant value that the descriptor should allow.- Returns:
- A descriptor for a value that only admits the given constant boolean value.
-
constant
public IValueDescriptor<?,?> constant(Object target, IValueStructureAccessor adapter)
Description copied from interface:IValueDescriptorFactoryCreates a value descriptor that only admits the given constant value.- Specified by:
constantin interfaceIValueDescriptorFactory- Parameters:
target- The constant value that the descriptor should allow.adapter- The adapter to access the structure of the value.- Returns:
- A descriptor for a value that only admits the given constant boolean value.
-
constantBuilder
public IConstValueDescriptorBuilder<Boolean> constantBuilder(boolean value)
- Specified by:
constantBuilderin interfaceIValueDescriptorFactory- Parameters:
value- The constant value that the descriptor should allow.- Returns:
- A descriptor builder for a boolean value that only admits a constant instance.
-
constantBuilder
public IConstValueDescriptorBuilder<Double> constantBuilder(double value)
- Specified by:
constantBuilderin interfaceIValueDescriptorFactory- Parameters:
value- The constant value that the descriptor should allow.- Returns:
- A descriptor builder for a floating point value that only admits a constant instance.
-
normalizeUnion
public IValueDescriptor<?,?> normalizeUnion(IUnionValueDescriptor descriptor)
Description copied from interface:IValueDescriptorFactoryNormalizes a union value descriptor by removing duplicate types, flattening nested unions, and merging types that can be merged (e.g. integer and float become float). If a union only has a single member after normalization, that type is returned instead of a union. If a union has no members after normalization,voidis returned.- Specified by:
normalizeUnionin interfaceIValueDescriptorFactory- Parameters:
descriptor- The union descriptor to normalize.- Returns:
- A normalized union descriptor.
-
constantBuilder
public IConstValueDescriptorBuilder<LargeString> constantBuilder(LargeString value)
- Specified by:
constantBuilderin interfaceIValueDescriptorFactory- Parameters:
value- The constant value that the descriptor should allow.- Returns:
- A descriptor builder for a large string value that only admits a constant instance.
-
constantBuilder
public IConstValueDescriptorBuilder<Long> constantBuilder(long value)
- Specified by:
constantBuilderin interfaceIValueDescriptorFactory- Parameters:
value- The constant value that the descriptor should allow.- Returns:
- A descriptor builder for an integer value that only admits a constant instance.
-
constantBuilder
public IConstValueDescriptorBuilder<String> constantBuilder(String value)
- Specified by:
constantBuilderin interfaceIValueDescriptorFactory- Parameters:
value- The constant value that the descriptor should allow.- Returns:
- A descriptor builder for a string value that only admits a constant instance.
-
floatingBuilder
public IFloatValueDescriptorBuilder floatingBuilder()
- Specified by:
floatingBuilderin interfaceIValueDescriptorFactory- Returns:
- A descriptor builder for a floating point value.
-
integerBuilder
public IIntegerValueDescriptorBuilder integerBuilder()
- Specified by:
integerBuilderin interfaceIValueDescriptorFactory- Returns:
- A descriptor builder for an integer value.
-
intersect
public IValueDescriptor<?,?> intersect(IValueDescriptor<?,?> first, IValueDescriptor<?,?> second)
Description copied from interface:IValueDescriptorFactoryIntersects two value descriptors with each other. The intersection is the value descriptor that is compatible with both given descriptors, i.e. letcbeintersect(first, second), then for all valuesv:c.
If the descriptors are incompatible with each other,acceptsValue(v) <=> first.acceptsValue(v) & second.acceptsValue(v)IVoidValueDescriptoris returned, which does not accept any values.When there are conflicts, the
default valueand theattributesof the second descriptor are used. Disregarding the default value and the attributes, this is a symmetric operation, i.e.intersect(a,b) = intersect(b,a)
For example:intersect(null, void) = void intersect(string, string) = string intersect(string, boolean) = void intersect(string, null) = void intersect(string, void) = void intersect(string, "foo") = "foo" intersect(string, "foo" | "bar") = "foo" intersect(float, float) = float intersect(float, integer) = integer intersect(float[1,6], float[3,8]) = float[3,6] intersect(float[1,6), float(3,8]) = float(3,6) intersect(integer[1,6], integer[3,8]) = integer[3,6] // A union with a single string intersect(string, string | boolean) = string intersect(float | string | boolean, boolean | string) = string intersect(List[string], List[number]) = void intersect(List[string], List[string | number]) = List[string] intersect([string, string], List[string]) = [string, string] intersect([string, number], List[string]) = void intersect(Map[string], Map[number]) = void intersect(Map[string], Map[string]) = Map[string] intersect(Map[string|number], Map[string|number]) = Map[string] intersect({a=string|boolean,b=number}, Map[string|number]) = {a=string,b=number} intersect({a:string,b:number}, Map[string]) = void intersect({a:string}, {b:string}) = void intersect({a:string, b?:string}, {b:string}) = void intersect({a:string, b?:string}, {a?:string, b:string}) = {a:string, b:string} intersect({a:string, b:number}, {a:string, b:string}) = void intersect({type:"foo" | "bar"}, {type:"foo"}) = {type:"foo"} intersect( {type:"number", value:number} | {type:"string", value:string, optional?:boolean}, {type:"string", value:string} ) = {type:"string", value:string}- Specified by:
intersectin interfaceIValueDescriptorFactory- Parameters:
first- A descriptor to intersect with the other.second- A descriptor to intersect with the other.- Returns:
- The intersection of the two given value descriptors. If either is
null, the other is returned. If both arenull,IValueDescriptorFactory.voidish()is returned.
-
intersectAll
public IValueDescriptor<?,?> intersectAll(Iterable<? extends IValueDescriptor<?,?>> descriptors)
Description copied from interface:IValueDescriptorFactoryIntersects all value descriptors, returning a descriptor that represents their intersection. If no descriptors are given, returnsIValueDescriptorFactory.any(). Seeintersect(first, second)for more details on the intersection of two value descriptors. This is a convenience method that is functionally equivalent to:var result = any(); for (var descriptor : descriptors) { result = result.intersect(descriptor); } return result;- Specified by:
intersectAllin interfaceIValueDescriptorFactory- Parameters:
descriptors- Value descriptors to intersect.- Returns:
- The intersected value descriptor.
- See Also:
IValueDescriptorFactory.intersect(IValueDescriptor, IValueDescriptor)
-
intersectDescriptorMap
public Map<String,IValueDescriptor<?,?>> intersectDescriptorMap(Map<String,IValueDescriptor<?,?>> firstMap, Map<String,IValueDescriptor<?,?>> secondMap)
Description copied from interface:IValueDescriptorFactoryIntersects two maps of value descriptors with each other. The intersection is the map that contains only those entries that are present in both maps, and where the value descriptors are intersected usingintersect(first, second). If the descriptors are incompatible with each other, the entry is omitted from the result.- Specified by:
intersectDescriptorMapin interfaceIValueDescriptorFactory- Parameters:
firstMap- The first map of descriptors.secondMap- The second map of descriptors.- Returns:
- The intersection of the two given maps of value descriptors.
-
largeStringBuilder
public ILargeStringValueDescriptorBuilder largeStringBuilder()
- Specified by:
largeStringBuilderin interfaceIValueDescriptorFactory- Returns:
- A descriptor builder for a large string value.
-
listBuilder
public <V> IListValueDescriptorBuilder<V> listBuilder(IValueDescriptor<V,? extends IValueBuilder<V>> descriptor)
- Specified by:
listBuilderin interfaceIValueDescriptorFactory- Type Parameters:
V- Type of the elements contained in the list.- Parameters:
descriptor- Descriptor for the elements contained in the list.- Returns:
- A descriptor builder for a list value (
List<V>).
-
listBuilder
public IListValueDescriptorBuilder<?> listBuilder(IValueDescriptorCreator elementType)
- Specified by:
listBuilderin interfaceIValueDescriptorFactory- Parameters:
elementType- Creates the descriptor for the type of the list elements.- Returns:
- A descriptor builder for a list value (
List<V>).
-
mapBuilder
public <V> IMapValueDescriptorBuilder<V> mapBuilder(IValueDescriptor<V,? extends IValueBuilder<V>> descriptor)
- Specified by:
mapBuilderin interfaceIValueDescriptorFactory- Type Parameters:
V- Type of the mapped values.- Parameters:
descriptor- Descriptor for the type of the mapped values.- Returns:
- A descriptor builder for a map value (
Map<String, V>).
-
mapBuilder
public IMapValueDescriptorBuilder<?> mapBuilder(IValueDescriptorCreator elementType)
- Specified by:
mapBuilderin interfaceIValueDescriptorFactory- Parameters:
elementType- Creates the descriptor for the type of the mapped values.- Returns:
- A descriptor builder for a map value (
Map<String, V>).
-
nullishBuilder
public INullValueDescriptorBuilder nullishBuilder()
- Specified by:
nullishBuilderin interfaceIValueDescriptorFactory- Returns:
- A descriptor builder for a value that can only be
null.
-
recordBuilder
public IRecordValueDescriptorBuilder recordBuilder()
- Specified by:
recordBuilderin interfaceIValueDescriptorFactory- Returns:
- A descriptor builder for a record value.
-
stringBuilder
public IStringValueDescriptorBuilder stringBuilder()
- Specified by:
stringBuilderin interfaceIValueDescriptorFactory- Returns:
- A descriptor builder for a string value.
-
tupleBuilder
public ITupleValueDescriptorBuilder tupleBuilder()
- Specified by:
tupleBuilderin interfaceIValueDescriptorFactory- Returns:
- A descriptor builder for a tuple value with a fixed length and where each element has the same type. Each tuple element defaults to the default value of the given descriptor.
-
unionBuilder
public IUnionValueDescriptorBuilder unionBuilder()
Description copied from interface:IValueDescriptorFactoryCreates a new union descriptor builder.- Specified by:
unionBuilderin interfaceIValueDescriptorFactory- Returns:
- A descriptor builder for a union value that uses instances of the given type as discriminators.
-
voidish
public IVoidValueDescriptor voidish()
- Specified by:
voidishin interfaceIValueDescriptorFactory- Returns:
- A value descriptor for a void result. This is valid only as a root value for the return value of a method.
-
getInstance
public static IValueDescriptorFactory getInstance()
- Returns:
- The immutable instance of the factory.
-
-