Class Value
java.lang.Object
org.opencastproject.assetmanager.api.Value
- Direct Known Subclasses:
Value.TypedValue
A property value.
The wrapped type is not exposed as a generic type parameter since Values appear in
contexts like lists where this type information cannot be preserved.
To access the wrapped type one can choose between two options.
If the type is known, use get(ValueType).
If the type is not known, safely decompose the value with decompose(Fn, Fn, Fn, Fn, Fn).
Use one of the various mk(..) constructors to create a new Value.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classstatic final classA value of typeBoolean.static final classstatic final classA value of typeDate.static final classstatic final classA value of typeLong.static final classstatic final classA value of typeString.static classHelper type to reduce boilerplate code.static final classstatic classValueType gives evidence that typeAis suitable for the creation of aValue.static final classstatic final classA value of typeVersion. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Value.BooleanTypestatic final Value.DateTypestatic final Value.LongTypestatic final Value.StringTypestatic final Value.UntypedTypestatic final Value.VersionType -
Method Summary
Modifier and TypeMethodDescriptionfinal <A> Adecompose(Function<? super String, ? extends A> stringValue, Function<? super Date, ? extends A> dateValue, Function<? super Long, ? extends A> longValue, Function<? super Boolean, ? extends A> booleanValue, Function<? super Version, ? extends A> versionValue) Decompose (or pattern match) the value instance.Use as a placeholder that yields an error in value decomposition.abstract Objectget()Get the wrapped value.final <A> Aget(Value.ValueType<A> ev) Get the wrapped value in a type safe way.final Value.ValueType<?> getType()static Value.BooleanValueCreate a new value of typeBoolean.static Value.LongValueCreate a new value of typeLong.static Value.StringValueCreate a new value of typeString.static Value.DateValueCreate a new value of typeDate.static <A> Value.TypedValue<A> mk(Value.ValueType<A> mk, A a) Generic constructor.static Value.VersionValueCreate a new value of typeVersion.
-
Field Details
-
STRING
-
DATE
-
LONG
-
BOOLEAN
-
VERSION
-
UNTYPED
-
-
Method Details
-
get
Get the wrapped value. -
get
Get the wrapped value in a type safe way. Use this method if you are sure about the contained value type. Otherwise consider the use ofdecompose(Fn, Fn, Fn, Fn, Fn).- Parameters:
ev- Evidence type. The type parameterAof the evidence type must match the type of the wrapped value. Any other value will result in an exception being thrown.- Throws:
RuntimeException- if the passed evidenceevdoes not match the type of the wrapped value
-
getType
-
decompose
public final <A> A decompose(Function<? super String, ? extends A> stringValue, Function<? super Date, ? extends A> dateValue, Function<? super Long, ? extends A> longValue, Function<? super Boolean, ? extends A> booleanValue, Function<? super Version, ? extends A> versionValue) Decompose (or pattern match) the value instance. Provide a function to handle each possible type. UsedoNotMatch()as a placeholder that yields an error. -
doNotMatch
Use as a placeholder that yields an error in value decomposition.- See Also:
-
mk
Create a new value of typeString. -
mk
Create a new value of typeDate. -
mk
Create a new value of typeLong. -
mk
Create a new value of typeBoolean. -
mk
Create a new value of typeVersion. -
mk
Generic constructor. Creates a value for any existing ValueType.
-