Class Scope<T>
- java.lang.Object
- 
- software.amazon.smithy.rulesengine.language.evaluation.Scope<T>
 
- 
- Type Parameters:
- T- The type of values in scope.
 
 public final class Scope<T> extends java.lang.ObjectScope is a stack for tracking facts for named values of the given type.
- 
- 
Constructor SummaryConstructors Constructor Description Scope()Crates a new, empty scope with a single layer.
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description TexpectValue(Identifier name)Gets the first value in scope for the specified identifier, throwingInnerParseErrorif the identifier is undefined in all the scope.static Scope<Value>fromNode(Node node)Creates aScopeinstance from the given Node information.java.util.Optional<java.util.Map.Entry<Identifier,T>>getDeclaration(Identifier name)Gets the first declaration in scope for the specified identifier.java.util.Optional<T>getValue(Identifier name)Gets the first value in scope for the specified identifier.<U> UinScope(java.util.function.Supplier<U> supplier)Assesses a value supplier in the current scope.voidinsert(java.lang.String name, T value)Inserts a named value into the current scope.voidinsert(Identifier name, T value)Inserts a named value into the current scope.booleanisNonNull(Reference reference)Gets if a reference is non-null in the current scope.voidpop()Pops the most recentScopeLayerout of the current scope.voidpush()Pushes an emptyScopeLayerinto the current scope.voidsetNonNull(Reference name)Inserts a non-null reference into the current scope.java.lang.StringtoString()
 
- 
- 
- 
Method Detail- 
fromNodepublic static Scope<Value> fromNode(Node node) Creates aScopeinstance from the given Node information.- Parameters:
- node- the node to deserialize.
- Returns:
- the created Scope.
 
 - 
inScopepublic <U> U inScope(java.util.function.Supplier<U> supplier) Assesses a value supplier in the current scope.- Type Parameters:
- U- the type of the value returned by the supplier.
- Parameters:
- supplier- the value supplier to assess.
- Returns:
- the value returned by the supplier.
 
 - 
pushpublic void push() Pushes an emptyScopeLayerinto the current scope.
 - 
poppublic void pop() Pops the most recentScopeLayerout of the current scope.
 - 
insertpublic void insert(java.lang.String name, T value)Inserts a named value into the current scope.- Parameters:
- name- the name of the value to insert.
- value- the value to insert.
 
 - 
insertpublic void insert(Identifier name, T value) Inserts a named value into the current scope.- Parameters:
- name- the name of the value to insert.
- value- the value to insert.
 
 - 
setNonNullpublic void setNonNull(Reference name) Inserts a non-null reference into the current scope.- Parameters:
- name- the name of the reference to insert.
 
 - 
isNonNullpublic boolean isNonNull(Reference reference) Gets if a reference is non-null in the current scope.- Parameters:
- reference- the reference to check nullability for.
- Returns:
- true if the reference is non-null, false otherwise.
 
 - 
getDeclarationpublic java.util.Optional<java.util.Map.Entry<Identifier,T>> getDeclaration(Identifier name) Gets the first declaration in scope for the specified identifier.- Parameters:
- name- the identifier to retrieve a declaration for.
- Returns:
- an optional of the declaration for the identifier, or empty otherwise.
 
 - 
expectValuepublic T expectValue(Identifier name) throws InnerParseError Gets the first value in scope for the specified identifier, throwingInnerParseErrorif the identifier is undefined in all the scope.- Parameters:
- name- the identifier to retrieve a declaration for.
- Returns:
- the value for the identifier.
- Throws:
- InnerParseError- when the identifier has no value in the scope.
 
 - 
getValuepublic java.util.Optional<T> getValue(Identifier name) Gets the first value in scope for the specified identifier.- Parameters:
- name- the identifier to retrieve a value for.
- Returns:
- an optional of the value for the identifier, or empty otherwise.
 
 - 
toStringpublic java.lang.String toString() - Overrides:
- toStringin class- java.lang.Object
 
 
- 
 
-