@Override protected MappingNode representJavaBean(Set<Property> properties, Object javaBean) { MappingNode node = super.representJavaBean(properties, javaBean); // Always set the tag to MAP so that SnakeYaml doesn't print out the class name as a tag. node.setTag(Tag.MAP); // Sort the output of our map so that we put certain keys, such as apiVersion, first. Collections.sort( node.getValue(), new Comparator<NodeTuple>() { @Override public int compare(NodeTuple a, NodeTuple b) { String nameA = ((ScalarNode) a.getKeyNode()).getValue(); String nameB = ((ScalarNode) b.getKeyNode()).getValue(); int intCompare = Integer.compare(getPropertyPosition(nameA), getPropertyPosition(nameB)); if (intCompare != 0) { return intCompare; } else { return nameA.compareTo(nameB); } } }); return node; }
@Override protected MappingNode representJavaBean(Set<Property> properties, Object javaBean) { MappingNode node = super.representJavaBean(properties, javaBean); // Always set the tag to MAP so that SnakeYaml doesn't print out the class name as a tag. node.setTag(Tag.MAP); // Sort the output of our map so that we put certain keys, such as apiVersion, first. Collections.sort( node.getValue(), new Comparator<NodeTuple>() { @Override public int compare(NodeTuple a, NodeTuple b) { String nameA = ((ScalarNode) a.getKeyNode()).getValue(); String nameB = ((ScalarNode) b.getKeyNode()).getValue(); int intCompare = Integer.compare(getPropertyPosition(nameA), getPropertyPosition(nameB)); if (intCompare != 0) { return intCompare; } else { return nameA.compareTo(nameB); } } }); return node; }