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

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


    return generatedCache = buf.toString();
  }

  @Override
  public MetaClass getType() {
    MetaClass returnType = method.getReturnType();

    if (method.getGenericReturnType() != null && method.getGenericReturnType() instanceof MetaTypeVariable) {
      typeVariables = new HashMap<String, MetaClass>();
      resolveTypeVariables();
View Full Code Here


  }

  // Resolves type variables by inspecting call parameters
  private void resolveTypeVariables() {
    MetaParameterizedType gSuperClass = inputType.getGenericSuperClass();
    MetaClass superClass = inputType.getSuperClass();

    if (superClass != null && superClass.getTypeParameters() != null & superClass.getTypeParameters().length > 0
            && gSuperClass != null && gSuperClass.getTypeParameters().length > 0) {
      for (int i = 0; i < superClass.getTypeParameters().length; i++) {
        if (gSuperClass.getTypeParameters()[i] instanceof MetaClass) {
          typeVariables.put(superClass.getTypeParameters()[i].getName(), (MetaClass) gSuperClass.getTypeParameters()[i]);
        }
        else if (gSuperClass.getTypeParameters()[i] instanceof MetaWildcardType) {
          typeVariables.put(superClass.getTypeParameters()[i].getName(), MetaClassFactory.get(Object.class));
        }
      }
    }

    int methodParmIndex = 0;
View Full Code Here

    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"),
                      Parameter.of(type.isArray() ? type.asBoxed() : type, "value")))
              .modifiers(Modifier.Static, Modifier.JSNI)
              .body()
              .append(new StringStatement(JSNIUtil.fieldAccess(f) + " = value"))
              .finish();
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

      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

        return generatedCache = buf.toString();
      }

      @Override
      public MetaClass getType() {
        MetaClass ret;

        int dims = GenUtil.getArrayDimensions(ref.getType());

        if (ref.getType().isArray() && idx.length > 0) {
          int newDims = dims - idx.length;
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.