private JClassType getBaseType(JClassType classType) { if (classType == null) { return null; } JParameterizedType parameterizedType = classType.isParameterized(); return parameterizedType == null ? classType : parameterizedType.getBaseType(); }
private JClassType getBaseType(JClassType classType) { if (classType == null) { return null; } JParameterizedType parameterizedType = classType.isParameterized(); return parameterizedType == null ? classType : parameterizedType.getBaseType(); }
private JClassType placeTypeForInterfaces(Collection<? extends JClassType> interfaces) { JClassType rtn = null; for (JClassType i : interfaces) { JParameterizedType parameterizedType = i.isParameterized(); if (parameterizedType != null && placeTokenizerType.equals(parameterizedType.getBaseType())) { rtn = parameterizedType.getTypeArgs()[0]; } } return rtn; } }
private JClassType placeTypeForInterfaces(Collection<? extends JClassType> interfaces) { JClassType rtn = null; for (JClassType i : interfaces) { JParameterizedType parameterizedType = i.isParameterized(); if (parameterizedType != null && placeTokenizerType.equals(parameterizedType.getBaseType())) { rtn = parameterizedType.getTypeArgs()[0]; } } return rtn; } }
private static JClassType findFactoryType( JClassType placeHistoryMapperWithFactoryType, JClassType interfaceType) { JClassType superInterfaces[] = interfaceType.getImplementedInterfaces(); for (JClassType superInterface : superInterfaces) { JParameterizedType parameterizedType = superInterface.isParameterized(); if (parameterizedType != null && parameterizedType.getBaseType().equals( placeHistoryMapperWithFactoryType)) { return parameterizedType.getTypeArgs()[0]; } } return null; }
private static JClassType findFactoryType( JClassType placeHistoryMapperWithFactoryType, JClassType interfaceType) { JClassType superInterfaces[] = interfaceType.getImplementedInterfaces(); for (JClassType superInterface : superInterfaces) { JParameterizedType parameterizedType = superInterface.isParameterized(); if (parameterizedType != null && parameterizedType.getBaseType().equals( placeHistoryMapperWithFactoryType)) { return parameterizedType.getTypeArgs()[0]; } } return null; }
private JClassType tryEnhancingTypeInfo(String objectName, JClassType objectType) { OwnerField uiField = ownerClass.getUiField(objectName); if (uiField != null) { JParameterizedType pType = uiField.getRawType().isParameterized(); if (pType != null) { // Even field is parameterized, it might be a super class. In that case, if we use the field // type then we might miss some add handlers methods from the objectType itself; something // we don't want to happen! if (pType.getBaseType().equals(objectType)) { // Now we proved type from UiField is more specific, let's use that one return pType; } } } return objectType; }
private JClassType tryEnhancingTypeInfo(String objectName, JClassType objectType) { OwnerField uiField = ownerClass.getUiField(objectName); if (uiField != null) { JParameterizedType pType = uiField.getRawType().isParameterized(); if (pType != null) { // Even field is parameterized, it might be a super class. In that case, if we use the field // type then we might miss some add handlers methods from the objectType itself; something // we don't want to happen! if (pType.getBaseType().equals(objectType)) { // Now we proved type from UiField is more specific, let's use that one return pType; } } } return objectType; }
static JRealClassType getBaseType(JClassType type) { if (type.isParameterized() != null) { return type.isParameterized().getBaseType(); } else if (type.isRawType() != null) { return type.isRawType().getBaseType(); } return (JRealClassType) type; }
static JRealClassType getBaseType(JClassType type) { if (type.isParameterized() != null) { return type.isParameterized().getBaseType(); } else if (type.isRawType() != null) { return type.isRawType().getBaseType(); } return (JRealClassType) type; }
public static JClassType[] findParameterizationOf(JClassType intfType, JClassType subType) { assert intfType.isAssignableFrom(subType) : subType.getParameterizedQualifiedSourceName() + " is not assignable to " + subType.getParameterizedQualifiedSourceName(); for (JClassType supertype : subType.getFlattenedSupertypeHierarchy()) { JParameterizedType parameterized = supertype.isParameterized(); if (parameterized != null) { // Found the desired supertype if (intfType.equals(parameterized.getBaseType())) { return parameterized.getTypeArgs(); } } } return null; }
public static JClassType[] findParameterizationOf(JClassType intfType, JClassType subType) { assert intfType.isAssignableFrom(subType) : subType.getParameterizedQualifiedSourceName() + " is not assignable to " + subType.getParameterizedQualifiedSourceName(); for (JClassType supertype : subType.getFlattenedSupertypeHierarchy()) { JParameterizedType parameterized = supertype.isParameterized(); if (parameterized != null) { // Found the desired supertype if (intfType.equals(parameterized.getBaseType())) { return parameterized.getTypeArgs(); } } } return null; }
protected void generateProxyMethods(SourceWriter w, SerializableTypeOracle serializableTypeOracle, TypeOracle typeOracle, Map<JMethod, JMethod> syncMethToAsyncMethMap) { JMethod[] syncMethods = serviceIntf.getOverridableMethods(); for (JMethod syncMethod : syncMethods) { 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, typeOracle, syncMethod, asyncMethod); } }
/** * Returns a simple qualified name for simple types, including classes and * interfaces, parameterized, and raw types. Null is returned for other types * such as arrays and type parameters (e.g., 'E' in java.util.List<E>) because * filtering is meaningless for such types. */ private String getBaseTypeName(JClassType type) { JClassType baseType = null; if (type instanceof JRealClassType) { baseType = type; } else if (type.isParameterized() != null) { baseType = type.isParameterized().getBaseType(); } else if (type.isRawType() != null) { baseType = type.isRawType(); } return baseType == null ? null : baseType.getQualifiedSourceName(); } }
/** * Returns a simple qualified name for simple types, including classes and * interfaces, parameterized, and raw types. Null is returned for other types * such as arrays and type parameters (e.g., 'E' in java.util.List<E>) because * filtering is meaningless for such types. */ private String getBaseTypeName(JClassType type) { JClassType baseType = null; if (type instanceof JRealClassType) { baseType = type; } else if (type.isParameterized() != null) { baseType = type.isParameterized().getBaseType(); } else if (type.isRawType() != null) { baseType = type.isRawType(); } return baseType == null ? null : baseType.getQualifiedSourceName(); } }
@Override public MetaTypeVariable[] getTypeParameters() { final JGenericType genericType; if (getEnclosedMetaObject().isGenericType() != null) { genericType = getEnclosedMetaObject().isGenericType(); } else if (getEnclosedMetaObject().isParameterized() != null) { genericType = getEnclosedMetaObject().isParameterized().getBaseType(); } else if (getEnclosedMetaObject().isRawType() != null) { genericType = getEnclosedMetaObject().isRawType().getGenericType(); } else { return new MetaTypeVariable[0]; } return Arrays.stream(genericType.getTypeParameters()) .map(p -> new GWTTypeVariable(oracle, p)).toArray(s -> new MetaTypeVariable[s]); }
@Override public MetaTypeVariable[] getTypeParameters() { final JGenericType genericType; if (getEnclosedMetaObject().isGenericType() != null) { genericType = getEnclosedMetaObject().isGenericType(); } else if (getEnclosedMetaObject().isParameterized() != null) { genericType = getEnclosedMetaObject().isParameterized().getBaseType(); } else if (getEnclosedMetaObject().isRawType() != null) { genericType = getEnclosedMetaObject().isRawType().getGenericType(); } else { return new MetaTypeVariable[0]; } return Arrays.stream(genericType.getTypeParameters()) .map(p -> new GWTTypeVariable(oracle, p)).toArray(s -> new MetaTypeVariable[s]); }
/** * Returns a simple types, including classes and * interfaces, parameterized, and raw types. Null is returned for other types * such as arrays and type parameters (e.g., 'E' in java.util.List<E>) because * filtering is meaningless for such types. */ protected String getBaseTypeName(JClassType type) { if(type == null){ return null; } if (type instanceof JRealClassType) { return type.getQualifiedSourceName(); } else if (type.isParameterized() != null) { return type.isParameterized().getBaseType().getQualifiedSourceName(); } else if (type.isRawType() != null) { return type.isRawType().getQualifiedSourceName(); } return type.getQualifiedSourceName(); }
@SuppressWarnings("unchecked") public static <T extends JType> T ensureBaseType(T maybeParameterized) { if (maybeParameterized.isArray() != null) { JArrayType array = maybeParameterized.isArray(); return (T) array.getOracle().getArrayType( ensureBaseType(array.getComponentType())); } if (maybeParameterized.isTypeParameter() != null) { return (T) maybeParameterized.isTypeParameter().getBaseType(); } if (maybeParameterized.isParameterized() != null) { return (T) maybeParameterized.isParameterized().getBaseType(); } if (maybeParameterized.isRawType() != null) { return (T) maybeParameterized.isRawType().getBaseType(); } if (maybeParameterized.isWildcard() != null) { return (T) maybeParameterized.isWildcard().getBaseType(); } return maybeParameterized; }
@SuppressWarnings("unchecked") public static <T extends JType> T ensureBaseType(T maybeParameterized) { if (maybeParameterized.isArray() != null) { JArrayType array = maybeParameterized.isArray(); return (T) array.getOracle().getArrayType( ensureBaseType(array.getComponentType())); } if (maybeParameterized.isTypeParameter() != null) { return (T) maybeParameterized.isTypeParameter().getBaseType(); } if (maybeParameterized.isParameterized() != null) { return (T) maybeParameterized.isParameterized().getBaseType(); } if (maybeParameterized.isRawType() != null) { return (T) maybeParameterized.isRawType().getBaseType(); } if (maybeParameterized.isWildcard() != null) { return (T) maybeParameterized.isWildcard().getBaseType(); } return maybeParameterized; }