public Node representData(Object data) { return representJavaBean(getProperties(data.getClass()), data); } }
private Set<Property> sortTypeWithOrder(Class<? extends Object> type, List<String> order) throws IntrospectionException { Set<Property> standard = super.getProperties(type); Set<Property> sorted = new TreeSet<Property>(new ModelPropertyComparator(order)); sorted.addAll(standard); return sorted; }
@Override protected Set<Property> getProperties(Class<? extends Object> type) throws IntrospectionException { if (type.isAssignableFrom(Model.class)) { return sortTypeWithOrder(type, ORDER_MODEL); } else if (type.isAssignableFrom(Developer.class)) { return sortTypeWithOrder(type, ORDER_DEVELOPER); } else if (type.isAssignableFrom(Contributor.class)) { return sortTypeWithOrder(type, ORDER_CONTRIBUTOR); } else if (type.isAssignableFrom(Dependency.class)) { return sortTypeWithOrder(type, ORDER_DEPENDENCY); } else if (type.isAssignableFrom(Plugin.class)) { return sortTypeWithOrder(type, ORDER_PLUGIN); } else { return super.getProperties(type); } }
public Node representData(Object data) { return representJavaBean(getProperties(data.getClass()), data); } }
@Override protected Set<Property> getProperties(Class<? extends Object> type) throws IntrospectionException { Set<Property> props = super.getProperties(type); Property toRemove = null; for (Property prop : props) { if (prop.getName().equals("metaClass")) { toRemove = prop; break; } } if (toRemove != null) props.remove(toRemove); return props; } };
private Set<Property> sortTypeWithOrder(Class<? extends Object> type, List<String> order) throws IntrospectionException { Set<Property> standard = super.getProperties(type); Set<Property> sorted = new TreeSet<Property>(new ModelPropertyComparator(order)); sorted.addAll(standard); return sorted; }
@Override protected Set<Property> getProperties(Class<? extends Object> type) { Set<Property> properties = super.getProperties(type); if (type.isAnnotationPresent(YamlElementOrder.class)) { List<String> fieldOrder = Arrays.asList(type.getAnnotation(YamlElementOrder.class) .value()); Set<Property> sortedProperties = new TreeSet<>(new YamlPropertyComparator(fieldOrder)); sortedProperties.addAll(properties); return sortedProperties; } return properties; }
public Node representData(Object data) { try { return representJavaBean(getProperties(data.getClass()), data); } catch (IntrospectionException e) { throw new YAMLException(e); } } }
public Node representData(Object data) { try { return representJavaBean(getProperties(data.getClass()), data); } catch (IntrospectionException e) { throw new YAMLException(e); } } }
@Override protected Set<Property> getProperties(Class<? extends Object> type) throws IntrospectionException { if (type.isAssignableFrom(Model.class)) { return sortTypeWithOrder(type, ORDER_MODEL); } else if (type.isAssignableFrom(Developer.class)) { return sortTypeWithOrder(type, ORDER_DEVELOPER); } else if (type.isAssignableFrom(Contributor.class)) { return sortTypeWithOrder(type, ORDER_CONTRIBUTOR); } else if (type.isAssignableFrom(Dependency.class)) { return sortTypeWithOrder(type, ORDER_DEPENDENCY); } else if (type.isAssignableFrom(Plugin.class)) { return sortTypeWithOrder(type, ORDER_PLUGIN); } else { return super.getProperties(type); } }