Class Value
- java.lang.Object
-
- org.opencastproject.assetmanager.api.Value
-
- Direct Known Subclasses:
Value.TypedValue
@ParametersAreNonnullByDefault public abstract class Value extends Object
A property value.The wrapped type is not exposed as a generic type parameter since
The value type is a sum type made up fromValues 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, useget(ValueType). If the type is not known, safely decompose the value withdecompose(Fn, Fn, Fn, Fn, Fn).Use one of the various
mk(..)constructors to create a newValue.- See Also:
Property
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classValue.BooleanTypestatic classValue.BooleanValueA value of typeBoolean.static classValue.DateTypestatic classValue.DateValueA value of typeDate.static classValue.LongTypestatic classValue.LongValueA value of typeLong.static classValue.StringTypestatic classValue.StringValueA value of typeString.static classValue.TypedValue<A>Helper type to reduce boilerplate code.static classValue.UntypedTypestatic classValue.ValueType<A>ValueType gives evidence that typeAis suitable for the creation of aValue.static classValue.VersionTypestatic classValue.VersionValueA value of typeVersion.
-
Field Summary
Fields Modifier and Type Field Description static Value.BooleanTypeBOOLEANstatic Value.DateTypeDATEstatic Value.LongTypeLONGstatic Value.StringTypeSTRINGstatic Value.UntypedTypeUNTYPEDstatic Value.VersionTypeVERSION
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description <A> Adecompose(com.entwinemedia.fn.Fn<? super String,? extends A> stringValue, com.entwinemedia.fn.Fn<? super Date,? extends A> dateValue, com.entwinemedia.fn.Fn<? super Long,? extends A> longValue, com.entwinemedia.fn.Fn<? super Boolean,? extends A> booleanValue, com.entwinemedia.fn.Fn<? super Version,? extends A> versionValue)Decompose (or pattern match) the value instance.static <B> com.entwinemedia.fn.Fn<Object,B>doNotMatch()Use as a placeholder that yields anPrelude.unexhaustiveMatch()error in value decomposition.abstract Objectget()Get the wrapped value.<A> Aget(Value.ValueType<A> ev)Get the wrapped value in a type safe way.Value.ValueType<?>getType()static Value.BooleanValuemk(Boolean value)Create a new value of typeBoolean.static Value.LongValuemk(Long value)Create a new value of typeLong.static Value.StringValuemk(String value)Create a new value of typeString.static Value.DateValuemk(Date value)Create a new value of typeDate.static <A> Value.TypedValue<A>mk(Value.ValueType<A> mk, A a)Generic constructor.static Value.VersionValuemk(Version value)Create a new value of typeVersion.
-
-
-
Field Detail
-
STRING
public static final Value.StringType STRING
-
DATE
public static final Value.DateType DATE
-
LONG
public static final Value.LongType LONG
-
BOOLEAN
public static final Value.BooleanType BOOLEAN
-
VERSION
public static final Value.VersionType VERSION
-
UNTYPED
public static final Value.UntypedType UNTYPED
-
-
Method Detail
-
get
public abstract Object get()
Get the wrapped value.
-
get
public final <A> A get(Value.ValueType<A> ev)
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
public final Value.ValueType<?> getType()
-
decompose
public final <A> A decompose(com.entwinemedia.fn.Fn<? super String,? extends A> stringValue, com.entwinemedia.fn.Fn<? super Date,? extends A> dateValue, com.entwinemedia.fn.Fn<? super Long,? extends A> longValue, com.entwinemedia.fn.Fn<? super Boolean,? extends A> booleanValue, com.entwinemedia.fn.Fn<? 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 anPrelude.unexhaustiveMatch()error.
-
doNotMatch
public static <B> com.entwinemedia.fn.Fn<Object,B> doNotMatch()
Use as a placeholder that yields anPrelude.unexhaustiveMatch()error in value decomposition.- See Also:
decompose(Fn, Fn, Fn, Fn, Fn)
-
mk
public static Value.StringValue mk(String value)
Create a new value of typeString.
-
mk
public static Value.DateValue mk(Date value)
Create a new value of typeDate.
-
mk
public static Value.LongValue mk(Long value)
Create a new value of typeLong.
-
mk
public static Value.BooleanValue mk(Boolean value)
Create a new value of typeBoolean.
-
mk
public static Value.VersionValue mk(Version value)
Create a new value of typeVersion.
-
mk
public static <A> Value.TypedValue<A> mk(Value.ValueType<A> mk, A a)
Generic constructor. Creates a value for any existing ValueType.
-
-