List of usage examples for java.lang.reflect Parameter equals
public boolean equals(Object obj)
From source file:com.phoenixnap.oss.ramlapisync.naming.SchemaHelper.java
/** * Breaks down a class into component fields which are mapped as Query Parameters. If Javadoc is supplied, this will * be injected as comments/*from w ww .j a v a2 s. c om*/ * * @param param The Parameter representing the class to be converted into query parameters * @param javaDocStore The associated JavaDoc (if any) * @return a Map of Parameter RAML models keyed by parameter name */ public static Map<String, QueryParameter> convertClassToQueryParameters(final Parameter param, final JavaDocStore javaDocStore) { final Map<String, QueryParameter> outParams = new TreeMap<>(); if (param == null || param.equals(Void.class)) { return outParams; } final ApiParameterMetadata parameterMetadata = new ApiParameterMetadata(param); if (mapSimpleType(param.getType()) != null) { throw new IllegalArgumentException( "This method should only be called on non primitive classes which will be broken down into query parameters"); } try { for (Field field : param.getType().getDeclaredFields()) { if (!java.lang.reflect.Modifier.isStatic(field.getModifiers()) && !java.lang.reflect.Modifier.isTransient(field.getModifiers()) && !java.lang.reflect.Modifier.isVolatile(field.getModifiers())) { QueryParameter queryParam = new QueryParameter(); // Check if we have comments JavaDocEntry paramComment = javaDocStore == null ? null : javaDocStore.getJavaDoc(field.getName()); if (paramComment != null && StringUtils.hasText(paramComment.getComment())) { queryParam.setDescription(paramComment.getComment()); } // Populate parameter model with data such as name, type and // required/not queryParam.setDisplayName(field.getName()); ParamType simpleType = mapSimpleType(field.getType()); queryParam.setType(simpleType == null ? ParamType.STRING : simpleType); queryParam.setRequired(parameterMetadata.isNullable()); queryParam.setRepeat(false); // TODO we could add validation // info // here - maybe hook into // JSR303 // annotations outParams.put(field.getName(), queryParam); } } return outParams; } catch (Exception e) { throw new IllegalStateException(e); } }