A value declaration.
Getting a model requires applying type arguments to the
value declaration with apply()
in order to be able to read that value. For example, here is how you would
obtain a value model that you can read from a toplevel attribute declaration:
String foo = "Hello"; void test(){ // We need to apply the the foo declaration in order to get the foo value model Value<String> valueModel = `value foo`.apply<String>(); // This will print: Hello print(valueModel.get()); }
For attributes it is a bit longer, because attributes need to be applied the containing type, so you should
use memberApply()
and start by giving the containing closed type:
class Outer(){ shared String foo => "Hello"; } void test(){ // Apply the containing closed type `Outer` to the attribute declaration `Outer.foo` Attribute<Outer,String> valueModel = `value Outer.foo`.memberApply<Outer,String>(`Outer`); // We now have an Attribute, which needs to be applied to a containing instance in order to become a // readable value: Value<String> boundValueModel = valueModel(Outer()); // This will print: Hello print(boundValueModel.get()); }
no type hierarchy
no subtypes hierarchy
Attributes | |
late | Source Codeshared formal Boolean late True if this declaration is annotated with late. Since 1.2.0 |
objectClass | Source Codeshared formal ClassDeclaration? objectClass This value's anonymous class declaration if this value is an object declaration. Since 1.1.0 |
objectValue | Source Codeshared formal Boolean objectValue True if this declaration is an Since 1.1.0 |
setter | Source Codeshared formal SetterDeclaration? setter Returns the setter declaration for this variable if there is one, |
variable | Source Codeshared formal Boolean variable True if this declaration is annotated with variable. |
Inherited Attributes |
Attributes inherited from: Object |
Attributes inherited from: Declaration |
Attributes inherited from: FunctionOrValueDeclaration |
Attributes inherited from: NestableDeclaration |
Attributes inherited from: TypedDeclaration |
Methods | |
apply | Source Codeshared formal Value<Get,Set> apply<Get = Anything, Set = Nothing>() Applies this value declaration in order to obtain a value model. See this code sample for an example on how to use this. Throws
|
get | Source Codeshared actual default Anything get() Reads the current value of this toplevel value. Refines GettableDeclaration.get |
memberApply | Source Codeshared formal Attribute<Container,Get,Set> memberApply<Container = Nothing, Get = Anything, Set = Nothing>(AppliedType<Object> containerType) Applies the given closed container type to this attribute declaration in order to obtain an attribute model. See this code sample for an example on how to use this. Throws
|
memberGet | Source Codeshared actual default Anything memberGet(Object container) Reads the current value of this attribute on the given container instance. Throws
Refines GettableDeclaration.memberGet |
memberSet | Source Codeshared formal void memberSet(Object container, Anything newValue) Sets the current value of this attribute on the given container instance. Throws
|
set | Source Codeshared default void set(Anything newValue) Sets the current value of this toplevel value. |
staticApply | Source Codeshared formal Value<Get,Set> staticApply<Get = Anything, Set = Nothing>(AppliedType<Object> containerType) Applies this Throws
|
staticGet | Source Codeshared actual default Anything staticGet(AppliedType<Object> containerType) Reads the current value of this Throws
Refines GettableDeclaration.staticGet |
Inherited Methods |
Methods inherited from: Object |
Methods inherited from: Annotated |
Methods inherited from: AnnotatedDeclaration |
Methods inherited from: GettableDeclaration |