-
- Type Parameters:
V- the value type
- All Known Subinterfaces:
AnonymousValue,ArrayValue,BooleanValue,EnumValue,InvocationValue,NullValue,NumberValue,ReferenceValue,TextValue
public interface Value<V> extends HasCopy<Value<V>>
A model that represents any kind of value declared in code.- Since:
- 2.0.0
- Author:
- Emil Forslund
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description VgetValue()Returns the inner value of this model.static AnonymousValueofAnonymous(Type implementedType)Returns a newAnonymousValuerepresenting the anonymous implementation of a class or interface as the value of a field.static ArrayValueofArray()Returns a newArrayValuewith no values set.static ArrayValueofArray(List<Value<?>> values)Returns a newArrayValuewith the specified values set.static BooleanValueofBoolean(Boolean val)Returns a newBooleanValuewith the specified value.static EnumValueofEnum(Type type, String constant)Returns a newEnumValuewith the specified constant selected.static InvocationValueofInvocation(Type owner, String method, Value<?>... args)Returns a newInvocationValuerepresenting a call to the specified static method in the specified class with the specified arguments.static InvocationValueofInvocation(String method, Value<?>... args)Returns a newInvocationValuerepresenting a call to the specified local method with the specified arguments.static NullValueofNull()Returns a newNullValuerepresentingnull.static NumberValueofNumber(Number num)Returns a newNumberValue.static ReferenceValueofReference(String reference)Returns a newReferenceValuerepresenting a reference to an object.static TextValueofText(String text)Returns a newTextValuerepresenting a string text.Value<V>setValue(V value)Sets the inner value of this.
-
-
-
Method Detail
-
setValue
Value<V> setValue(V value)
Sets the inner value of this.- Parameters:
value- the new value- Returns:
- a reference to this model
-
getValue
V getValue()
Returns the inner value of this model.- Returns:
- the inner value
-
ofArray
static ArrayValue ofArray()
Returns a newArrayValuewith no values set.- Returns:
- an
ArrayValue
-
ofArray
static ArrayValue ofArray(List<Value<?>> values)
Returns a newArrayValuewith the specified values set.- Parameters:
values- the values to initialize the array with- Returns:
- an
ArrayValue
-
ofBoolean
static BooleanValue ofBoolean(Boolean val)
Returns a newBooleanValuewith the specified value.- Parameters:
val- the boolean- Returns:
- the boolean value
-
ofEnum
static EnumValue ofEnum(Type type, String constant)
Returns a newEnumValuewith the specified constant selected.- Parameters:
type- the enum typeconstant- the selected constant- Returns:
- the boolean value
-
ofNull
static NullValue ofNull()
Returns a newNullValuerepresentingnull.- Returns:
- a
NullValue
-
ofNumber
static NumberValue ofNumber(Number num)
Returns a newNumberValue.- Parameters:
num- the represented number- Returns:
- the created number value
-
ofReference
static ReferenceValue ofReference(String reference)
Returns a newReferenceValuerepresenting a reference to an object.- Parameters:
reference- the code to show- Returns:
- the reference value
-
ofText
static TextValue ofText(String text)
Returns a newTextValuerepresenting a string text.- Parameters:
text- the text- Returns:
- the text value
-
ofAnonymous
static AnonymousValue ofAnonymous(Type implementedType)
Returns a newAnonymousValuerepresenting the anonymous implementation of a class or interface as the value of a field.- Parameters:
implementedType- the class or interface to implement- Returns:
- the anonymous value
-
ofInvocation
static InvocationValue ofInvocation(String method, Value<?>... args)
Returns a newInvocationValuerepresenting a call to the specified local method with the specified arguments.- Parameters:
method- the local method to invokeargs- the arguments to pass to it- Returns:
- the created invocation
-
ofInvocation
static InvocationValue ofInvocation(Type owner, String method, Value<?>... args)
Returns a newInvocationValuerepresenting a call to the specified static method in the specified class with the specified arguments.- Parameters:
owner- the class where the static method is locatedmethod- the static method to invokeargs- the arguments to pass to it- Returns:
- the created invocation
-
-