Package org.jboss.errai.codegen.exception

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


        if (classAliases.contains(from.getFullyQualifiedName()) && classAliases.contains(to.getFullyQualifiedName())) {
          // handle convertibility between MetaClass API and java Class reference.
          return;
        }

        throw new InvalidTypeException(to.getFullyQualifiedName() + " is not assignable from "
            + from.getFullyQualifiedName());
      }
    }
  }
View Full Code Here


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

          // handle convertability between MetaClass API and java Class reference.
          return;
        }


        throw new InvalidTypeException(to.getFullyQualifiedName() + " is not assignable from "
                + from.getFullyQualifiedName());
      }
    }
  }
View Full Code Here

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

  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.isPrimitive() && !toType.isAssignableFrom(statement.getType()) && !toType.isAssignableTo(statement.getType())) {
      throw new InvalidTypeException(statement.getType() + " cannot be cast to " + toType);
    }
    else if (toType.isAssignableFrom(statement.getType())) {
      return stmt;
    }
    else {
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));
          }
        }
        catch (GenerationException e) {
View Full Code Here

 
      final VariableReference ref = context.getVariable(variableName);
 
      if (idx.length > 0) {
        if (!ref.getType().isArray()) {
          throw new InvalidTypeException("attempt to use indexed accessor on non-array type: " + ref);
        }
      }
 
      final Statement stmt = new VariableReference() {
        @Override
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

TOP

Related Classes of org.jboss.errai.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.