public Node representData(Object data) { return representJavaBean(getProperties(data.getClass()), data); } }
public Node representData(Object data) { return representJavaBean(getProperties(data.getClass()), data); } }
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 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; }
/** * Represents a Java bean normally, but without any YAML tag * information. * * @param properties a {@link Set} of {@link Property} instances * indicating what facets of the supplied {@code bean} should be * represented; ignored by this implementation * * @param bean the {@link Object} to represent; may be {@code null} * * @return the result of invoking {@link * Representer#representJavaBean(Set, Object)}, but after adding * {@link Tag#MAP} as a {@linkplain Representer#addClassTag(Class, * Tag) class tag} for the supplied {@code bean}'s class */ @Override protected final MappingNode representJavaBean(final Set<Property> properties, final Object bean) { if (bean != null) { final Class<?> beanClass = bean.getClass(); if (this.getTag(beanClass, null) == null) { this.addClassTag(beanClass, Tag.MAP); } } return super.representJavaBean(properties, bean); }
/** * Represents a Java bean normally, but without any YAML tag * information. * * @param properties a {@link Set} of {@link Property} instances * indicating what facets of the supplied {@code bean} should be * represented; ignored by this implementation * * @param bean the {@link Object} to represent; may be {@code null} * * @return the result of invoking {@link * Representer#representJavaBean(Set, Object)}, but after adding * {@link Tag#MAP} as a {@linkplain Representer#addClassTag(Class, * Tag) class tag} for the supplied {@code bean}'s class */ @Override protected final MappingNode representJavaBean(final Set<Property> properties, final Object bean) { if (bean != null) { final Class<?> beanClass = bean.getClass(); if (this.getTag(beanClass, null) == null) { this.addClassTag(beanClass, Tag.MAP); } } return super.representJavaBean(properties, bean); }