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

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


    return fieldName;
  }


  public static void addPrivateAccessStubs(boolean useJSNIStubs, ClassStructureBuilder<?> classBuilder, MetaField f) {
    MetaClass type = f.getType();
    if (type.getCanonicalName().equals("long")) {
      type = type.asBoxed();
    }

    if (useJSNIStubs) {
      classBuilder.privateMethod(void.class, getPrivateFieldInjectorName(f))
              .parameters(DefParameters.fromParameters(Parameter.of(f.getDeclaringClass(), "instance"),
View Full Code Here


    }
  }


  private static String _getReflectionFieldMethGetName(MetaField f) {
    MetaClass t = f.getType();

    if (!t.isPrimitive()) {
      return "get";
    }
    else if (t.getFullyQualifiedName().equals("int")) {
      return "getInt";
    }
    else if (t.getFullyQualifiedName().equals("short")) {
      return "getShort";
    }
    else if (t.getFullyQualifiedName().equals("boolean")) {
      return "getBoolean";
    }
    else if (t.getFullyQualifiedName().equals("double")) {
      return "getDouble";
    }
    else if (t.getFullyQualifiedName().equals("float")) {
      return "getFloat";
    }
    else if (t.getFullyQualifiedName().equals("byte")) {
      return "getByte";
    }
    else if (t.getFullyQualifiedName().equals("long")) {
      return "getLong";
    }
    else if (t.getFullyQualifiedName().equals("char")) {
      return "getChar";
    }
    return null;
  }
View Full Code Here

    return null;
  }


  private static String _getReflectionFieldMethSetName(MetaField f) {
    MetaClass t = f.getType();

    if (!t.isPrimitive()) {
      return "set";
    }
    else if (t.getFullyQualifiedName().equals("int")) {
      return "setInt";
    }
    else if (t.getFullyQualifiedName().equals("short")) {
      return "setShort";
    }
    else if (t.getFullyQualifiedName().equals("boolean")) {
      return "setBoolean";
    }
    else if (t.getFullyQualifiedName().equals("double")) {
      return "setDouble";
    }
    else if (t.getFullyQualifiedName().equals("float")) {
      return "setFloat";
    }
    else if (t.getFullyQualifiedName().equals("byte")) {
      return "setByte";
    }
    else if (t.getFullyQualifiedName().equals("long")) {
      return "setLong";
    }
    else if (t.getFullyQualifiedName().equals("char")) {
      return "setChar";
    }
    return null;
  }
View Full Code Here

    }
    return 0;
  }

  public static MetaMethod findCaseInsensitiveMatch(MetaClass retType, MetaClass clazz, String name, MetaClass... parms) {
    MetaClass c = clazz;

    do {
      Outer:
      for (MetaMethod method : c.getDeclaredMethods()) {
        if (name.equalsIgnoreCase(method.getName())) {
          if (parms.length != method.getParameters().length) continue;

          MetaParameter[] mps = method.getParameters();
          for (int i = 0; i < parms.length; i++) {
            if (!parms[i].getFullyQualifiedName().equals(mps[i].getType().getFullyQualifiedName())) {
              continue Outer;
            }
          }

          if (retType != null
                  && !retType.getFullyQualifiedName().equals(method.getReturnType().getFullyQualifiedName())) {
            continue;
          }

          return method;
        }
      }
    }
    while ((c = c.getSuperClass()) != null);

    return null;
  }
View Full Code Here

            bestCandidate = meth;
            break;
          }

          for (int i = 0; i != arguments.length; i++) {
            MetaClass actualParamType;
            if (isVarArgs && !arguments[arguments.length - 1].isArray() && i >= parmTypes.length - 1)
              actualParamType = parmTypes[parmTypes.length - 1].getType().getComponentType();
            else
              actualParamType = parmTypes[i].getType();

            if (arguments[i] == null) {
              if (!actualParamType.isPrimitive()) {
                score += 6;
              }
              else {
                score = 0;
                break;
              }
            }
            else if (actualParamType.equals(arguments[i])) {
              score += 7;
            }
            else if (actualParamType.isPrimitive() && actualParamType.asBoxed().equals(arguments[i])) {
              score += 6;
            }
            else if (arguments[i].isPrimitive() && arguments[i].asUnboxed().equals(actualParamType)) {
              score += 6;
            }
            else if (actualParamType.isAssignableFrom(arguments[i])) {
              score += 5;
            }
            else if (isNumericallyCoercible(arguments[i], actualParamType)) {
              score += 4;
            }
            else if (actualParamType.asBoxed().isAssignableFrom(arguments[i].asBoxed())
                    && !Object_MetaClass.equals(arguments[i])) {
              score += 3 + scoreInterface(actualParamType, arguments[i]);
            }
            else if (canConvert(actualParamType, arguments[i])) {
              if (actualParamType.isArray() && arguments[i].isArray()) score += 1;
              else if (actualParamType.equals(char_MetaClass) && arguments[i].equals(String_MetaClass)) score += 1;

              score += 1;
            }
            else if (actualParamType.equals(Object_MetaClass) || arguments[i].equals(NullType_MetaClass)) {
              score += 1;
            }
            else {
              score = 0;
              break;
View Full Code Here

      return false;
    }
  }

  public static boolean isNumericallyCoercible(MetaClass target, MetaClass parm) {
    MetaClass boxedTarget = target.isPrimitive() ? target.asBoxed() : target;

    if (boxedTarget != null && Number_MetaClass.isAssignableFrom(target)) {
      if ((boxedTarget = parm.isPrimitive() ? parm.asBoxed() : parm) != null) {
        return Number_MetaClass.isAssignableFrom(boxedTarget);
      }
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

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.