Package com.google.gwt.core.ext.typeinfo

Examples of com.google.gwt.core.ext.typeinfo.JParameterizedType


      } else {
        return "[" + computeBinaryClassName(arrayType.getComponentType());
      }
    }

    JParameterizedType parameterizedType = type.isParameterized();
    if (parameterizedType != null) {
      return computeBinaryClassName(parameterizedType.getBaseType());
    }

    JClassType classType = type.isClassOrInterface();
    assert (classType != null);
View Full Code Here


    String returnTypeName = returnType.getQualifiedSourceName();
    if (returnTypeName.equals("java.lang.String")) {
      return;
    }
    if (returnTypeName.equals("java.util.Map")) {
      JParameterizedType paramType = returnType.isParameterized();
      if (paramType != null) {
        JClassType[] typeArgs = paramType.getTypeArgs();
        if (typeArgs.length != 2 || !typeArgs[0].getQualifiedSourceName().equals("java.lang.String")
            || !typeArgs[1].getQualifiedSourceName().equals("java.lang.String")) {
          throw error(logger,
          "Map Methods in interfaces extending Constant must be raw or <String, String>");
        }
View Full Code Here

      for (JClassType bound : isWildcard.getUpperBounds()) {
        recordTypeParametersIn(bound, params);
      }
    }

    JParameterizedType isParameterized = type.isParameterized();
    if (isParameterized != null) {
      for (JClassType arg : isParameterized.getTypeArgs()) {
        recordTypeParametersIn(arg, params);
      }
    }
  }
View Full Code Here

    if (classOrInterface.isEnum() != null) {
      // The fields of an enum are never serialized; they are always okay.
      return true;
    }

    JParameterizedType isParameterized = classOrInterface.isParameterized();
    if (isParameterized != null) {
      if (isRawMapOrRawCollection(classOrInterface)) {
        /*
         * Backwards compatibility. Raw collections or maps force all object
         * subtypes to be considered.
         */
        checkAllSubtypesOfObject(logger, parent);
      } else {
        TreeLogger paramsLogger = logger.branch(TreeLogger.DEBUG,
            "Checking parameters of '"
                + isParameterized.getParameterizedQualifiedSourceName() + "'");

        for (JTypeParameter param : isParameterized.getBaseType().getTypeParameters()) {
          if (!checkTypeArgument(paramsLogger, isParameterized.getBaseType(),
              param.getOrdinal(),
              isParameterized.getTypeArgs()[param.getOrdinal()], true, parent)) {
            return false;
          }
        }
      }
    }
View Full Code Here

   * <code>subType</code> and <code>superType</code>. The returned type
   * must have the same base type as <code>subType</code>. If there are
   * definitely no such values, return <code>null</code>.
   */
  public JClassType constrainTypeBy(JClassType subType, JClassType superType) {
    JParameterizedType superAsParameterized = superType.isParameterized();
    if (superAsParameterized == null) {
      // If the supertype is not parameterized, it will not be possible to
      // constrain
      // the subtype further.
      return subType;
    }

    // Replace each wildcard in the subType with a fresh type variable.
    // These type variables will be the ones that are constrained.
    Map<JTypeParameter, JClassType> constraints = new HashMap<JTypeParameter, JClassType>();
    JClassType subWithWildcardsReplaced = replaceWildcardsWithFreshTypeVariables(
        subType, constraints);

    // Rewrite subType so that it has the same base type as superType.
    JParameterizedType subAsParameterized = subWithWildcardsReplaced.asParameterizationOf(superAsParameterized.getBaseType());
    if (subAsParameterized == null) {
      // The subtype's base does not inherit from the supertype's base,
      // so again no constraint will be possible.
      return subType;
    }
View Full Code Here

    }

    if (isRealOrParameterized(type1) && isRealOrParameterized(type2)) {
      JClassType baseType1 = getBaseType(type1);
      JClassType baseType2 = getBaseType(type2);
      JParameterizedType type1Parameterized = type1.isParameterized();
      JParameterizedType type2Parameterized = type2.isParameterized();

      if (baseType1 == baseType2 && type1Parameterized != null
          && type2Parameterized != null) {
        // type1 and type2 are parameterized types with the same base type;
        // compare their arguments
        JClassType[] args1 = type1Parameterized.getTypeArgs();
        JClassType[] args2 = type2Parameterized.getTypeArgs();
        boolean allMatch = true;
        for (int i = 0; i < args1.length; i++) {
          if (!typesMatch(args1[i], args2[i], constraints)) {
            allMatch = false;
          }
View Full Code Here

   *
   * @param type the type in question
   * @return the suffix of the method to call
   */
  private static String getCallSuffix(JType type) {
    JParameterizedType isParameterized = type.isParameterized();
    if (isParameterized != null) {
      return getCallSuffix(isParameterized.getRawType());
    } else if (type.isPrimitive() != null) {
      if (type == JPrimitiveType.BOOLEAN) {
        return "Boolean";
      } else if (type == JPrimitiveType.BYTE) {
        return "Byte";
View Full Code Here

    return false;
  }

  private void generateSerializationSignature(JType type, CRC32 crc)
      throws UnsupportedEncodingException {
    JParameterizedType parameterizedType = type.isParameterized();
    if (parameterizedType != null) {
      generateSerializationSignature(parameterizedType.getRawType(), crc);

      return;
    }

    String serializedTypeName = getSerializedTypeName(type);
View Full Code Here

      JMethod asyncMethod = syncMethToAsyncMethMap.get(syncMethod);
      assert (asyncMethod != null);

      JClassType enclosingType = syncMethod.getEnclosingType();
      JParameterizedType isParameterizedType = enclosingType.isParameterized();
      if (isParameterizedType != null) {
        JMethod[] methods = isParameterizedType.getMethods();
        for (int i = 0; i < methods.length; ++i) {
          if (methods[i] == syncMethod) {
            /*
             * Use the generic version of the method to ensure that the server
             * can find the method using the erasure of the generic signature.
             */
            syncMethod = isParameterizedType.getBaseType().getMethods()[i];
          }
        }
      }

      generateProxyMethod(w, serializableTypeOracle, syncMethod, asyncMethod);
View Full Code Here

  public JMethod findMethodWithoutParamsReturning(JGenericType returnType,
      JClassType returnTypeParameter) throws UnableToCompleteException {
    JMethod result = null;
    for (JClassType classType : inspectedClass.getFlattenedSupertypeHierarchy()) {
      for (JMethod method : classType.getMethods()) {
        JParameterizedType actualReturnType = method.getReturnType().isParameterized();
        if (method.getParameters().length == 0
            && actualReturnType != null
            && returnType.isAssignableFrom(actualReturnType)
            && returnTypeParameter.isAssignableFrom(actualReturnType.getTypeArgs()[0])) {
          if (result != null) {
            logger.log(TreeLogger.ERROR, "The class '" + inspectedClass.getName()
                + "' has more than one method returning " + returnType.getName()
                + "<" + returnTypeParameter.getName() + "> and taking no parameter. "
                + "This is not allowed.", null);
View Full Code Here

TOP

Related Classes of com.google.gwt.core.ext.typeinfo.JParameterizedType

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.