Nova Ordis Generic Variable and Expression System: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
(Created page with "=Internal= * NovaOrdis Utilities =Overview= The implementation of a generic variable system. Variables are scoped, typed and named pla...")
 
Line 11: Line 11:
=Example=
=Example=


<syntaxhighlight java='lang'>
<syntaxhighlight lang='java'>


Scope s = new ScopeImpl();
Scope s = new ScopeImpl();


Variable<String> v = s.declare("color", String.class, "blue");
Variable<String> v = s.declare("color", String.class, "blue");


</syntaxhighlight>
</syntaxhighlight>

Revision as of 03:20, 14 September 2017

Internal

Overview

The implementation of a generic variable system. Variables are scoped, typed and named placeholders for values. Variable instances can only be created by declaring them in a scope, with Scope.declare(). Once declared in a scope, the variable is available to all enclosed scopes.The same variable may be declared in more than one scope, and may have different values in different scopes.

Values are assigned to a variable with set() and retrieved with get(). The value of a variable may be null.

Example

Scope s = new ScopeImpl();

Variable<String> v = s.declare("color", String.class, "blue");