Package dev.cel.checker
Class Env.DeclGroup
- java.lang.Object
-
- dev.cel.checker.Env.DeclGroup
-
- Enclosing class:
- Env
public static class Env.DeclGroup extends java.lang.ObjectObject for managing a group of declarations within a scope.Identifiers and functions can share the same declaration name, so a simple map will not suffice for tracking declaration overloads.
Whether a given
DeclGroupis mutable or immutable depends on whether the maps supplied as input to the group are standardMapimplementations orImmutableMapimplementations. The {DeclGroup#immutableCopy} method is provided as a convenience to make it easy to create an instance of the group which will honor the developer's intent.
-
-
Constructor Summary
Constructors Constructor Description DeclGroup()Construct an emptyDeclGroup.DeclGroup(java.util.Map<java.lang.String,CelIdentDecl> idents, java.util.Map<java.lang.String,CelFunctionDecl> functions)Construct a newDeclGroupfrom the inputidentsandfunctions.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @Nullable CelFunctionDeclgetFunction(java.lang.String name)Get a function declaration byname.java.util.Map<java.lang.String,CelFunctionDecl>getFunctions()Get an immutable map of the functions in theDeclGroupkeyed by declaration name.@Nullable CelIdentDeclgetIdent(java.lang.String name)Get an identifier declaration byname.java.util.Map<java.lang.String,CelIdentDecl>getIdents()Get an immutable map of the identifiers in theDeclGroupkeyed by declaration name.Env.DeclGroupimmutableCopy()Create a copy of theDeclGroupwith immutable identifier and function maps.voidputFunction(CelFunctionDecl function)Put a function declaration into theDeclGroup.voidputIdent(CelIdentDecl ident)Put an identifier declaration into theDeclGroup.
-
-
-
Constructor Detail
-
DeclGroup
public DeclGroup()
Construct an emptyDeclGroup.
-
DeclGroup
public DeclGroup(java.util.Map<java.lang.String,CelIdentDecl> idents, java.util.Map<java.lang.String,CelFunctionDecl> functions)
Construct a newDeclGroupfrom the inputidentsandfunctions.
-
-
Method Detail
-
getIdents
public java.util.Map<java.lang.String,CelIdentDecl> getIdents()
Get an immutable map of the identifiers in theDeclGroupkeyed by declaration name.
-
getFunctions
public java.util.Map<java.lang.String,CelFunctionDecl> getFunctions()
Get an immutable map of the functions in theDeclGroupkeyed by declaration name.
-
getIdent
public @Nullable CelIdentDecl getIdent(java.lang.String name)
Get an identifier declaration byname. Returnsnullif absent.
-
putIdent
public void putIdent(CelIdentDecl ident)
Put an identifier declaration into theDeclGroup.
-
getFunction
public @Nullable CelFunctionDecl getFunction(java.lang.String name)
Get a function declaration byname. Returnsnullif absent.
-
putFunction
public void putFunction(CelFunctionDecl function)
Put a function declaration into theDeclGroup.
-
immutableCopy
public Env.DeclGroup immutableCopy()
Create a copy of theDeclGroupwith immutable identifier and function maps.
-
-