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, string, string, string, tuple, tuple, tuple, tupleOfSame, tupleOfSame, unionEmpty, unionEnumBuilder, unionOfEnumConst, unionOfEnumConst, unionOfEnumConstBuilder, unionOfEnumConstBuilder, unionOfStringConst, unionOfStringConst, unionOfStringConst, unionOfStringConstBuilder, unionOfStringConstBuilder, unionOfStringConstBuilder, unionStringBuilder
-
-
-
-
Method Detail
-
accessAtPath
public List<?> accessAtPath(Object base, String path)
Description copied from interface:IValueDescriptorFactory
Access a nested property in an object at a given JSON path.- Specified by:
accessAtPath
in 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.
-
anyBuilder
public IAnyValueDescriptorBuilder anyBuilder()
- Specified by:
anyBuilder
in interfaceIValueDescriptorFactory
- Returns:
- A descriptor builder for an any value.
-
boolBuilder
public IBooleanValueDescriptorBuilder boolBuilder()
- Specified by:
boolBuilder
in interfaceIValueDescriptorFactory
- Returns:
- A descriptor builder for a boolean value.
-
constantBuilder
public IConstValueDescriptorBuilder<Boolean> constantBuilder(boolean value)
- Specified by:
constantBuilder
in 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:
constantBuilder
in 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.
-
constantBuilder
public IConstValueDescriptorBuilder<LargeString> constantBuilder(LargeString value)
- Specified by:
constantBuilder
in 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:
constantBuilder
in 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:
constantBuilder
in 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:
floatingBuilder
in interfaceIValueDescriptorFactory
- Returns:
- A descriptor builder for a floating point value.
-
integerBuilder
public IIntegerValueDescriptorBuilder integerBuilder()
- Specified by:
integerBuilder
in interfaceIValueDescriptorFactory
- Returns:
- A descriptor builder for an integer value.
-
intersect
public IValueDescriptor<?,?> intersect(IValueDescriptor<?,?> first, IValueDescriptor<?,?> second)
Description copied from interface:IValueDescriptorFactory
Intersects two value descriptors with each other. The intersection is the value descriptor that is compatible with both given descriptors, i.e. letc
beintersect(first, second)
, then for all valuesv
:c.
If the descriptors are incompatible with each other,acceptsValue
(v) <=> first.acceptsValue
(v) & second.acceptsValue
(v)IVoidValueDescriptor
is returned, which does not accept any values.When there are conflicts, the
default value
and thedescription
of the second descriptor are used. Disregarding the default value and the description, 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, as the
discriminator
needs to be preserved. 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:
intersect
in 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.
-
largeStringBuilder
public ILargeStringValueDescriptorBuilder largeStringBuilder()
- Specified by:
largeStringBuilder
in interfaceIValueDescriptorFactory
- Returns:
- A descriptor builder for a large string value.
-
listBuilder
public <V> IListValueDescriptorBuilder<V> listBuilder(IValueDescriptor<V,? extends IValueBuilder<V>> descriptor)
- Specified by:
listBuilder
in 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:
listBuilder
in 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:
mapBuilder
in 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:
mapBuilder
in 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:
nullishBuilder
in interfaceIValueDescriptorFactory
- Returns:
- A descriptor builder for a value that can only be
null
.
-
recordBuilder
public IRecordValueDescriptorBuilder recordBuilder()
- Specified by:
recordBuilder
in interfaceIValueDescriptorFactory
- Returns:
- A descriptor builder for a record value.
-
stringBuilder
public IStringValueDescriptorBuilder stringBuilder()
- Specified by:
stringBuilder
in interfaceIValueDescriptorFactory
- Returns:
- A descriptor builder for a string value.
-
tupleBuilder
public ITupleValueDescriptorBuilder tupleBuilder()
- Specified by:
tupleBuilder
in 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 <D> IUnionValueDescriptorBuilder<D> unionBuilder(Class<D> discriminatorClass)
- Specified by:
unionBuilder
in interfaceIValueDescriptorFactory
- Type Parameters:
D
- Type of the objects used to discriminate between the union members.- Parameters:
discriminatorClass
- Class of the objects used to discriminate between the union members.- Returns:
- A descriptor builder for a union value that uses instances of the given type as discriminators.
-
voidish
public IVoidValueDescriptor voidish()
- Specified by:
voidish
in 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.
-
-