public static boolean isInstanceOf( Object o, Type t ) { if ( o == null ) { return false; // See FEEL specifications Table 49. } if ( t == UNKNOWN ) { return true; } return determineTypeFromInstance( o ) == t; }
@Override public boolean isAssignableValue(Object value) { if ( value == null ) { return true; // a null-value can be assigned to any type. } return isInstanceOf(value, this); } }
public BaseFEELFunction(String name) { this.name = name; this.symbol = new FunctionSymbol( name, this ); }
public static boolean isInstanceOf( Object o, String name ) { return determineTypeFromInstance( o ) == determineTypeFromName( name ); }
private void init() { // the following automatically adds the GLOBAL scope as a child to the built-in scope new ScopeImpl( Scope.GLOBAL, builtInScope ); // pre-loads all the built in functions and types Stream.of( BuiltInFunctions.getFunctions() ).forEach( f -> builtInScope.define( f.getSymbol() ) ); Stream.of(BuiltInType.values()).flatMap(b -> b.getSymbols().stream()).forEach(t -> builtInScope.define(t)); }
@Override public Type evaluate(EvaluationContext ctx) { return BuiltInType.determineTypeFromName( getText() ); }
@Override public boolean isInstanceOf(Object o) { return getType().isInstanceOf(o); }
public void defineVariable(String variable) { VariableSymbol var = new VariableSymbol( variable ); this.currentScope.define( var ); }
public void pushScope(Type type) { LOG.trace("pushScope()"); currentScope = new ScopeImpl( currentName.peek(), currentScope, type ); }
@Override public boolean isAssignableValue(Object value) { return wrapped.isAssignableValue(value); }
public void setName(String name) { this.name = name; ((FunctionSymbol) this.symbol).setId( name ); }
public String getName() { return getId(); }
public SymbolTable() { init(); }
private void initializeTokenTree() { LOG.trace("[{}]: initializeTokenTree()"); tokenTree = new TokenTree(); for( String symbol : symbols.keySet() ) { List<String> tokens = tokenize( symbol ); tokenTree.addName( tokens ); } }
@Override public boolean isInstanceOf(Object o) { return wrapped.isInstanceOf(o); }
@Override public boolean isAssignableValue(Object value) { return getType().isAssignableValue(value); }
public void defineVariable(String variable, Type type) { LOG.trace("defining custom type symbol."); VariableSymbol var = new VariableSymbol( variable, type ); this.currentScope.define( var ); }
public void pushScope() { LOG.trace("pushScope()"); currentScope = new ScopeImpl( currentName.peek(), currentScope ); }
@Override public boolean isInstanceOf(Object o) { return isInstanceOf(o, this); }