Package org.jboss.errai.codegen.framework.meta

Examples of org.jboss.errai.codegen.framework.meta.MetaClass


      Class<?>[] parmTypes = method.getParameterTypes();
      Type[] genParmTypes = method.getGenericParameterTypes();
      Annotation[][] parmAnnos = method.getParameterAnnotations();

      for (int i = 0; i < parmTypes.length; i++) {
        MetaClass mcParm = MetaClassFactory.get(parmTypes[i], genParmTypes[i]);

        parmList.add(new JavaReflectionParameter(mcParm,
                parmAnnos[i], this));
      }
      parameters = parmList.toArray(new MetaParameter[parmList.size()]);
View Full Code Here


    try {
      CallParameters callParams = fromStatements(GenUtil.generateCallParameters(context, parameters));

      statement.generate(context);
     
      MetaClass callType = statement.getType();

      MetaClass[] parameterTypes = callParams.getParameterTypes();
      final MetaMethod method = (staticMethod) ? callType.getBestMatchingStaticMethod(methodName, parameterTypes)
              : callType.getBestMatchingMethod(methodName, parameterTypes);

      if (method == null) {
        callType.getBestMatchingMethod(methodName, parameterTypes);
        throw new UndefinedMethodException(statement.getType(), methodName, parameterTypes);
      }

      /**
       * If the method is within the calling scope, we can strip the qualifying reference.
View Full Code Here

    return result;
  }

  private static String _getClassReference(MetaType metaClass, Context context, boolean typeParms) {

    MetaClass erased;
    if (metaClass instanceof MetaClass) {
      erased = ((MetaClass) metaClass).getErased();
    }
    else if (metaClass instanceof MetaParameterizedType) {
      MetaParameterizedType parameterizedType = (MetaParameterizedType) metaClass;
      return parameterizedType.toString();
    }
    else if (metaClass instanceof MetaTypeVariable) {
      MetaTypeVariable parameterizedType = (MetaTypeVariable) metaClass;
      return parameterizedType.getName();
    }
    else if (metaClass instanceof MetaWildcardType) {
      MetaWildcardType wildCardType = (MetaWildcardType) metaClass;
      return wildCardType.toString();
    }
    else {
      throw new RuntimeException("unknown class reference type: " + metaClass);
    }

    String fqcn = erased.getCanonicalName();
    int idx = fqcn.lastIndexOf('.');
    if (idx != -1) {

      if ((context.isAutoImportActive() || "java.lang".equals(erased.getPackageName()))
              && !context.hasImport(erased)) {
        context.addImport(erased);
      }

      if (context.hasImport(erased)) {
View Full Code Here

      score = 0;
      if (method.getName().equals(name)) {
        if (method.getParameters().length == parmTypes.length) {
          if (parmTypes.length == 0) {
            score = 1;
            MetaClass retType = method.getReturnType();
            while ((retType = retType.getSuperClass()) != null) score++;
          }
          else {
            for (int i = 0; i < parmTypes.length; i++) {
              if (method.getParameters()[i].getType().isAssignableFrom(parmTypes[i])) {
                score++;
View Full Code Here

        c = ParseTools.getBestConstructorCandidate(parameters, cls, false);
        if (c == null) {
          return null;
        }
      }
      MetaClass metaClass = MetaClassFactory.get(cls);
      return metaClass.getConstructor(c.getParameterTypes());
    }
    else {
      return getConstructor(parameters);
    }
  }
View Full Code Here

    if (POS_ASSIGNABLE_CACHE.contains(clazz)) return true;
    if (NEG_ASSIGNABLE_CACHE.contains(clazz)) return false;

    if (!isPrimitive() && NULL_TYPE.equals(clazz)) return true;
   
    MetaClass cls;

    if (equals(cls = MetaClassFactory.get(Object.class))) {
      POS_ASSIGNABLE_CACHE.add(cls);
      return true;
    }

    cls = clazz;

    do {
      if (this.getFullyQualifiedName().equals(cls.getFullyQualifiedName())) {
        POS_ASSIGNABLE_CACHE.add(cls);
        return true;
      }
    }
    while ((cls = cls.getSuperClass()) != null);

    if (_hasInterface(clazz.getInterfaces(), this.getErased())) {
      POS_ASSIGNABLE_CACHE.add(clazz);
      return true;
    }
View Full Code Here

  @Override
  public boolean isAssignableTo(MetaClass clazz) {
    if (clazz.equals(MetaClassFactory.get(Object.class)))
      return true;

    MetaClass cls = this;
    do {
      if (cls.equals(clazz))
        return true;
    }
    while ((cls = cls.getSuperClass()) != null);

    return _hasInterface(getInterfaces(), clazz.getErased());
  }
View Full Code Here

    if (_internalNameCache != null) return _internalNameCache;

    String name = getFullyQualifiedName();

    String dimString = "";
    MetaClass type = this;
    if (isArray()) {
      type = type.getComponentType();
      int dim = 1;
      while (type.isArray()) {
        dim++;
        type = type.getComponentType();
      }

      for (int i = 0; i < dim; i++) {
        dimString += "[";
      }

      name = type.getFullyQualifiedName();
    }

    if (type.isPrimitive()) {
      name = getInternalPrimitiveNameFrom(name.trim());
    }
    else {
      name = "L" + getInternalPrimitiveNameFrom(name.trim()).replaceAll("\\.", "/") + ";";
    }
View Full Code Here

  @Override
  public MetaClass getOuterComponentType() {
    if (_outerComponentCache != null) return _outerComponentCache;

    MetaClass c = this;
    while (c.isArray()) {
      c = c.getComponentType();
    }
    return _outerComponentCache = c;
  }
View Full Code Here

    return new ContextualStatementBuilderImpl(context, callElementBuilder);
  }

  @Override
  public ContextualStatementBuilder loadClassReference(Object o) {
    MetaClass c;
    if (o instanceof MetaClass) {
      c = (MetaClass) o;
    }
    else if (o instanceof Class) {
      c = MetaClassFactory.get((Class) o);
View Full Code Here

TOP

Related Classes of org.jboss.errai.codegen.framework.meta.MetaClass

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.