private static List<MethodInspect> getInspects(ExecutableMemberDoc[] memberDocs) { List<MethodInspect> methodInspects = new ArrayList<>(memberDocs.length); for (ExecutableMemberDoc memberDoc : memberDocs) { List<String> signature = new ArrayList<>(); for (Parameter parameter : memberDoc.parameters()) { signature.add(parameter.type().qualifiedTypeName() + " " + parameter.name()); } MethodInspect methodInspect = new MethodInspect(memberDoc.name(), memberDoc.getRawCommentText(), String.join(", ", signature)); methodInspects.add(methodInspect); } return methodInspects; } }
public int compare(Type type1, Type type2) { return type1.qualifiedTypeName().compareToIgnoreCase( type2.qualifiedTypeName()); } }
public int compare(Type type1, Type type2) { return type1.qualifiedTypeName().toLowerCase().compareTo( type2.qualifiedTypeName().toLowerCase()); } }
private boolean isAcceptableReturnType(Type returnType) { String fqName = returnType.qualifiedTypeName(); return !(Void.class.getCanonicalName().equals(fqName) || Void.TYPE.getCanonicalName().equals(fqName)) || Response.class.getCanonicalName().equals(fqName); }
private boolean isVoidReturnType(Type typeName) { String fqcn = typeName.qualifiedTypeName(); return fqcn.equals(Void.class.getCanonicalName()) || fqcn.equals(Void.TYPE.getCanonicalName()); }
private static String getTypeName(Type type) { String typeName = type.qualifiedTypeName(); // look for Class<X> way of referencing sub resources ParameterizedType pt = type.asParameterizedType(); if (pt != null && typeName.equals("java.lang.Class")) { Type[] typeArgs = pt.typeArguments(); if (typeArgs != null && typeArgs.length == 1) { typeName = typeArgs[0].qualifiedTypeName(); } } return typeName; }
/** * Return qualified name of type excluding any dimension information. *<p> * For example, a two dimensional array of String * returns 'java.lang.String'. */ public String qualifiedTypeName() { return skipArrays().qualifiedTypeName(); }
/** * Returns the fully qualified class name from a {@link Type} that will work with {@link Class#forName(String)}. * <p> * This method correctly handles nested classes such that they can be fed into {@link Class#forName(String)}. * * @param type The type that you wish to derive the fully qualified path name for. * @return The fully qualified class name for the type. */ private static String getClassForNameFromType(Type type) { final String fullClassName = type.typeName(); final String fullClassForName = fullClassName.replace(".", "$"); return type.qualifiedTypeName().replace(fullClassName, fullClassForName); }
@Override public String qualifiedTypeName() { return this.underlyingType().qualifiedTypeName(); }
private static String parameterListForFragmentIdentifier(ExecutableMemberDoc executableMemberDoc) { StringBuilder result = new StringBuilder().append('('); for (int i = 0; i < executableMemberDoc.parameters().length; i++) { Parameter parameter = executableMemberDoc.parameters()[i]; if (i > 0) result.append(", "); result.append(parameter.type().qualifiedTypeName()); } return result.append(')').toString(); }
private Type extractSubResourceType(Type type) { // sub resources can have Class<A> as their return type and hence A is what we are after if (Class.class.getCanonicalName().equals(type.qualifiedTypeName())) { ParameterizedType parameterizedType = type.asParameterizedType(); return parameterizedType.typeArguments()[0]; } return type; }
private static String parameterListForFragmentIdentifier(ExecutableMemberDoc executableMemberDoc) { StringBuilder result = new StringBuilder().append('('); for (int i = 0; i < executableMemberDoc.parameters().length; i++) { Parameter parameter = executableMemberDoc.parameters()[i]; if (i > 0) result.append(", "); result.append(parameter.type().qualifiedTypeName()); } return result.append(')').toString(); }
private ParameterDescription getPublishedParameterDescription(ClassDescriptionSource source, FieldDoc fd, String name) { String currentClassName = fd.type().qualifiedTypeName(); while (true) { ClassDescription componentCD = source.getDescription(currentClassName); if (componentCD.classDoc == null) throw new IllegalArgumentException(String.format("Published parameter '%s' from %s not found.", name, fd.qualifiedName())); if (componentCD.parameters.containsKey(name)) { return componentCD.parameters.get(name); } currentClassName = componentCD.classDoc.superclass().typeName(); } }
private ParameterDescription getPublishedParameterDescription(ClassDescriptionSource source, FieldDoc fd, String name) { String currentClassName = fd.type().qualifiedTypeName(); while (true) { ClassDescription componentCD = source.getDescription(currentClassName); if (componentCD.classDoc == null) throw new IllegalArgumentException(String.format("Published parameter '%s' from %s not found.", name, fd.qualifiedName())); if (componentCD.parameters.containsKey(name)) { return componentCD.parameters.get(name); } currentClassName = componentCD.classDoc.superclass().typeName(); } }
public static MethodIdentity create(MethodDoc method) { final List<String> parameterTypeNames = new ArrayList<String>(); for (Parameter param: method.parameters()) { Type type = param.type(); parameterTypeNames.add(type.qualifiedTypeName() + type.dimension()); } return new MethodIdentity(method.qualifiedName(), parameterTypeNames); }
/** Print a a basic type t */ private String type(Options opt, Type t, boolean generics) { return ((generics ? opt.showQualifiedGenerics : opt.showQualified) ? // t.qualifiedTypeName() : t.typeName()) // + (opt.hideGenerics ? "" : typeParameters(opt, t.asParameterizedType())); }
/** Print a a basic type t */ private String type(Options opt, Type t) { String type = ""; if (opt.showQualified) type = t.qualifiedTypeName(); else type = t.typeName(); type += typeParameters(opt, t.asParameterizedType()); return type; }
/** * Parse type variables for generics * * @param typeVariable * @return */ protected TypeParameter parseTypeParameter(TypeVariable typeVariable) { TypeParameter typeParameter = objectFactory.createTypeParameter(); typeParameter.setName(typeVariable.typeName()); for (Type bound : typeVariable.bounds()) { typeParameter.getBound().add(bound.qualifiedTypeName()); } return typeParameter; }
private FieldRelationInfo getFieldRelationInfo(FieldDoc field) { Type type = field.type(); if(type.isPrimitive() || type instanceof WildcardType || type instanceof TypeVariable) return null; if (type.dimension().endsWith("[]")) { return new FieldRelationInfo(type.asClassDoc(), true); } Options opt = optionProvider.getOptionsFor(type.asClassDoc()); if (opt.matchesCollPackageExpression(type.qualifiedTypeName())) { Type[] argTypes = getInterfaceTypeArguments(collectionClassDoc, type); if (argTypes != null && argTypes.length == 1 && !argTypes[0].isPrimitive()) return new FieldRelationInfo(argTypes[0].asClassDoc(), true); argTypes = getInterfaceTypeArguments(mapClassDoc, type); if (argTypes != null && argTypes.length == 2 && !argTypes[1].isPrimitive()) return new FieldRelationInfo(argTypes[1].asClassDoc(), true); } return new FieldRelationInfo(type.asClassDoc(), false); }
private FieldRelationInfo getFieldRelationInfo(FieldDoc field) { Type type = field.type(); if(type.isPrimitive() || type instanceof WildcardType || type instanceof TypeVariable) return null; if (type.dimension().endsWith("[]")) { return new FieldRelationInfo(type.asClassDoc(), true); } Options opt = optionProvider.getOptionsFor(type.asClassDoc()); if (opt.matchesCollPackageExpression(type.qualifiedTypeName())) { Type[] argTypes = getInterfaceTypeArguments(collectionClassDoc, type); if (argTypes != null && argTypes.length == 1 && !argTypes[0].isPrimitive()) return new FieldRelationInfo(argTypes[0].asClassDoc(), true); argTypes = getInterfaceTypeArguments(mapClassDoc, type); if (argTypes != null && argTypes.length == 2 && !argTypes[1].isPrimitive()) return new FieldRelationInfo(argTypes[1].asClassDoc(), true); } return new FieldRelationInfo(type.asClassDoc(), false); }