Package org.jboss.errai.ioc.rebind.ioc.codegen.exception

Examples of org.jboss.errai.ioc.rebind.ioc.codegen.exception.InvalidTypeException


 
  private MetaClass inferType(Context context, Object initialization) {
    Statement initStatement = GenUtil.generate(context, initialization);
    MetaClass inferredType = (initStatement != null) ? initStatement.getType() : null;
    if (inferredType == null) {
      throw new InvalidTypeException("No type specified and no initialization provided to infer the type.");
    }

    return inferredType;
  }
View Full Code Here


  @Override
  public String generate(Context context) {
    String stmt = statement.generate(context);

    if (!toType.isAssignableFrom(statement.getType()) && !toType.isAssignableTo(statement.getType()))
      throw new InvalidTypeException(statement.getType() + " cannot be cast to " + toType);

    return "(" + LoadClassReference.getClassReference(toType, context) + ") " + stmt;
  }
View Full Code Here

    MetaClass referenceType = reference.getType();
    Statement[] indexes = reference.getIndexes();
    if (indexes!=null) {
      for (Statement index : indexes) {
        if (!referenceType.isArray())
          throw new InvalidTypeException("Variable is not a " + indexes.length + "-dimensional array!");
        referenceType = referenceType.getComponentType();
      }
    }
    operator.assertCanBeApplied(referenceType);
    operator.assertCanBeApplied(statement.getType());
View Full Code Here

    checkSwitchExprType();

    if (!caseBlocks.isEmpty()) {
      for (LiteralValue<?> value : caseBlocks.keySet()) {
        if (!switchExprStmt.getType().getErased().asBoxed().isAssignableFrom(value.getType().getErased())) {
          throw new InvalidTypeException(
              value.generate(context) + " is not a valid value for " + switchExprStmt.getType().getFullyQualifiedName());
        }
        // case labels must be unqualified
        String val = value.generate(context);
        int idx = val.lastIndexOf('.');
View Full Code Here

        validType = true;
        break;
      }
    }
    if (!validType)
      throw new InvalidTypeException("Type not permitted in switch statements:" +
          switchExprStmt.getType().getFullyQualifiedName());
  }
View Full Code Here

          buf.append(ObjectBuilder.newInstanceOf(throwableType).withParameters(parameters).generate(context));
        }
        else {
          VariableReference exceptionVar = context.getVariable(exceptionVariableName);
          if (!exceptionVar.getType().isAssignableTo(Throwable.class)) {
            throw new InvalidTypeException("Variable " + exceptionVariableName + " is not a Throwable");
          }
          buf.append(exceptionVar.generate(context));
        }
        return buf.toString();
      }
View Full Code Here

      throw new TypeNotIterableException(statement.generate(Context.create()));
  }

  public static void assertAssignableTypes(MetaClass from, MetaClass to) {
    if (!to.asBoxed().isAssignableFrom(from.asBoxed())) {
      throw new InvalidTypeException(to.getFullyQualifiedName() + " is not assignable from "
              + from.getFullyQualifiedName());
    }
  }
View Full Code Here

      else {
        return generate(context, input);
      }
    }
    catch (Throwable t) {
      throw new InvalidTypeException(t);
    }
  }
View Full Code Here

TOP

Related Classes of org.jboss.errai.ioc.rebind.ioc.codegen.exception.InvalidTypeException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.