/** * Get the list of attribute names for an entity. * * @param entity entity instance * @return List of attribute names for entity */ public List<String> getAttributes(Object entity) { return getAttributes(entity.getClass()); }
/** * Get the list of attribute names for an entity. * * @param entity entity instance * @return List of attribute names for entity */ public List<String> getAttributes(Object entity) { return getAttributes(entity.getClass()); }
/** * Get a list of all fields including both relationships and attributes. * * @param entityClass entity name * @return List of all fields. */ public List<String> getAllFields(Class<?> entityClass) { List<String> fields = new ArrayList<>(); List<String> attrs = getAttributes(entityClass); List<String> rels = getRelationships(entityClass); if (attrs != null) { fields.addAll(attrs); } if (rels != null) { fields.addAll(rels); } return fields; }
/** * Get a list of all fields including both relationships and attributes. * * @param entityClass entity name * @return List of all fields. */ public List<String> getAllFields(Class<?> entityClass) { List<String> fields = new ArrayList<>(); List<String> attrs = getAttributes(entityClass); List<String> rels = getRelationships(entityClass); if (attrs != null) { fields.addAll(attrs); } if (rels != null) { fields.addAll(rels); } return fields; }
/** * Get attributes mapping from entity. * * @return Mapping of attributes to objects */ protected Map<String, Object> getAttributes() { final Map<String, Object> attributes = new LinkedHashMap<>(); final Set<String> attrFields = filterFields(dictionary.getAttributes(obj)); for (String field : attrFields) { Object val = getAttribute(field); attributes.put(field, val); } return attributes; }
/** * Get attributes mapping from entity. * * @return Mapping of attributes to objects */ protected Map<String, Object> getAttributes() { final Map<String, Object> attributes = new LinkedHashMap<>(); final Set<String> attrFields = filterFields(dictionary.getAttributes(obj)); for (String field : attrFields) { Object val = getAttribute(field); attributes.put(field, val); } return attributes; }
/** * @return the JSON-API 'sort' query parameter for some GET operations. */ private Parameter getSortParameter() { List<String> filterAttributes = dictionary.getAttributes(type).stream() .filter((name) -> { Class<?> attributeClass = dictionary.getType(type, name); return (attributeClass.isPrimitive() || String.class.isAssignableFrom(attributeClass)); }) .map((name) -> Arrays.asList(name, "-" + name)) .flatMap(Collection::stream) .collect(Collectors.toList()); return new QueryParameter() .name("sort") .type("array") .description("Sorts the collection on the selected attributes. A prefix of '-' sorts descending") .items(new StringProperty()._enum(filterAttributes)) .collectionFormat("csv"); }
List<String> attributeNames = dictionary.getAttributes(type);
.type(Scalars.GraphQLID)); for (String attribute : dictionary.getAttributes(clazz)) { Class<?> attributeClass = dictionary.getType(clazz, attribute);
.type(Scalars.GraphQLID)); for (String attribute : dictionary.getAttributes(clazz)) { Class<?> attributeClass = dictionary.getType(clazz, attribute);
.type(GraphQLScalars.GRAPHQL_DEFERRED_ID)); for (String attribute : dictionary.getAttributes(entityClass)) { Class<?> attributeClass = dictionary.getType(entityClass, attribute); if (excludedEntities.contains(attributeClass)) {
.type(GraphQLScalars.GRAPHQL_DEFERRED_ID)); for (String attribute : dictionary.getAttributes(entityClass)) { Class<?> attributeClass = dictionary.getType(entityClass, attribute); if (excludedEntities.contains(attributeClass)) {
List<String> attributeNames = dictionary.getAttributes(clazz); for (String attributeName : attributeNames) { Class<?> attributeClazz = dictionary.getType(clazz, attributeName);