@Override public String[] findSerializationPropertyOrder(AnnotatedClass ac) { JsonPropertyOrder order = _findAnnotation(ac, JsonPropertyOrder.class); return (order == null) ? null : order.value(); }
private <T> SortMethod sortMethod(Class<T> instanceClazz) { if (instanceClazz != null) { //Jackson Support if (instanceClazz.isAnnotationPresent(JsonPropertyOrder.class)) { String[] value = instanceClazz.getAnnotation(JsonPropertyOrder.class).value(); return (value != null && value.length > 0) ? SortMethod.ANNOTATION : SortMethod.ALPHABETICAL; } } return SortMethod.FIELD_DECLARATION; } }
@Override public String[] findSerializationPropertyOrder(AnnotatedClass ac) { JsonPropertyOrder order = _findAnnotation(ac, JsonPropertyOrder.class); return (order == null) ? null : order.value(); }
@Override public String[] findSerializationPropertyOrder(AnnotatedClass ac) { JsonPropertyOrder order = ac.getAnnotation(JsonPropertyOrder.class); return (order == null) ? null : order.value(); }
@Override public String[] findSerializationPropertyOrder(AnnotatedClass ac) { JsonPropertyOrder order = _findAnnotation(ac, JsonPropertyOrder.class); return (order == null) ? null : order.value(); }
@Override public String[] findSerializationPropertyOrder(AnnotatedClass ac) { JsonPropertyOrder order = _findAnnotation(ac, JsonPropertyOrder.class); return (order == null) ? null : order.value(); }
@Override public String[] findSerializationPropertyOrder(AnnotatedClass ac) { JsonPropertyOrder order = _findAnnotation(ac, JsonPropertyOrder.class); return (order == null) ? null : order.value(); }
@Override public String[] findSerializationPropertyOrder(AnnotatedClass ac) { JsonPropertyOrder order = ac.getAnnotation(JsonPropertyOrder.class); return (order == null) ? null : order.value(); }
private List<String> annotationFields(Class<T> instanceClazz) { if (instanceClazz.isAnnotationPresent(JsonPropertyOrder.class)) { return Arrays.asList(instanceClazz.getAnnotation(JsonPropertyOrder.class).value()); } throw new CatnapException("Missing CatnapOrder or JsonPropertyOrder annotation"); }
private Collection<Property> unionOfSubclassProperties(Class<?> crdClass) { TreeMap<String, Property> result = new TreeMap<>(); for (Class subtype : Property.subtypes(crdClass)) { result.putAll(properties(subtype)); } result.putAll(properties(crdClass)); JsonPropertyOrder order = crdClass.getAnnotation(JsonPropertyOrder.class); return sortedProperties(order != null ? order.value() : null, result).values(); }
String[] propOrder = (order == null) ? null : order.value();
static Map<String, Property> properties(Class<?> crdClass) { TreeMap<String, Property> unordered = new TreeMap<>(); for (Method method : crdClass.getMethods()) { Class<?> returnType = method.getReturnType(); boolean isGetter = isGetterName(method) && method.getParameterCount() == 0 && !returnType.equals(void.class); boolean isNotInherited = !hasMethod(CustomResource.class, method) && !hasMethod(HasMetadata.class, method); boolean isNotIgnored = !method.isAnnotationPresent(JsonIgnore.class) && !method.isAnnotationPresent(JsonAnyGetter.class); if (isGetter && isNotInherited && isNotIgnored) { Property property = new Property(method); unordered.put(property.getName(), property); } } for (Field field : crdClass.getFields()) { boolean isProperty = !Modifier.isStatic(field.getModifiers()); boolean isNotIgnored = !field.isAnnotationPresent(JsonIgnore.class); if (isProperty && isNotIgnored) { Property property = new Property(field); unordered.put(property.getName(), property); } } JsonPropertyOrder order = crdClass.getAnnotation(JsonPropertyOrder.class); return sortedProperties(order != null ? order.value() : null, unordered); }
String[] propOrder = (order == null) ? null : order.value();
@SuppressWarnings({"unchecked", "rawtypes"}) public ResourceInformation build(Class<?> resourceClass) { List<AnnotatedResourceField> resourceFields = getResourceFields(resourceClass); String resourceType = getResourceType(resourceClass); Optional<JsonPropertyOrder> propertyOrder = ClassUtils.getAnnotation(resourceClass, JsonPropertyOrder.class); if (propertyOrder.isPresent()) { JsonPropertyOrder propertyOrderAnnotation = propertyOrder.get(); Collections.sort(resourceFields, new FieldOrderedComparator(propertyOrderAnnotation.value(), propertyOrderAnnotation.alphabetic())); } DefaultResourceInstanceBuilder<?> instanceBuilder = new DefaultResourceInstanceBuilder(resourceClass); Class<?> superclass = resourceClass.getSuperclass(); String superResourceType = superclass != Object.class && context.accept(superclass) ? context.getResourceType(superclass) : null; return new ResourceInformation(context.getTypeParser(), resourceClass, resourceType, superResourceType, instanceBuilder, (List) resourceFields); }
propOrder = propOrderInfo.value(); alphabetical = propOrderInfo.alphabetic();
propOrder = propOrderInfo.value(); alphabetical = propOrderInfo.alphabetic();
JsonPropertyOrder.class ); builder.setPropertyOrderAlphabetic( jsonPropertyOrder.isPresent() && jsonPropertyOrder.get().alphabetic() ); if ( jsonPropertyOrder.isPresent() && jsonPropertyOrder.get().value().length > 0 ) { builder.setPropertyOrderList( Arrays.asList( jsonPropertyOrder.get().value() ) ); } else if ( !builder.getCreatorParameters().isEmpty() ) { List<String> propertyOrderList = new ArrayList<String>( builder.getCreatorParameters().keySet() );