Esempio n. 1
0
 public static Statement generate(final Context context, final Object o) {
   if (o instanceof VariableReference) {
     return context.getVariable(((VariableReference) o).getName());
   } else if (o instanceof Variable) {
     final Variable v = (Variable) o;
     if (context.isScoped(v)) {
       return v.getReference();
     } else {
       if (context.isPermissiveMode()) {
         return v.getReference();
       } else {
         throw new OutOfScopeException(
             "variable cannot be referenced from this scope: " + v.getName());
       }
     }
   } else if (o instanceof Statement) {
     ((Statement) o).generate(context);
     return (Statement) o;
   } else {
     return LiteralFactory.getLiteral(context, o);
   }
 }
Esempio n. 2
0
  public static void assertIsIterable(final Statement statement) {
    final Class<?> cls = statement.getType().asClass();

    if (!cls.isArray() && !Iterable.class.isAssignableFrom(cls))
      throw new TypeNotIterableException(statement.generate(Context.create()));
  }