protected NodeTuple representJavaBeanProperty(Object javaBean, Property property, Object propertyValue, Tag customTag) { if (property != null && property.getName().equals("pomFile")) { // "pomFile" is not a part of POM http://maven.apache.org/xsd/maven-4.0.0.xsd return null; } if (propertyValue == null) return null; if (propertyValue instanceof Map) { Map map = (Map) propertyValue; if (map.isEmpty()) return null; } if (propertyValue instanceof List) { List map = (List) propertyValue; if (map.isEmpty()) return null; } if (javaBean instanceof Dependency) { //skip optional if it is false if (skipBoolean(property, "optional", propertyValue, false)) return null; //skip type if it is jar if (skipString(property, "type", propertyValue, "jar")) return null; } if (javaBean instanceof Plugin) { //skip extensions if it is false if (skipBoolean(property, "extensions", propertyValue, false)) return null; //skip inherited if it is true if (skipBoolean(property, "inherited", propertyValue, true)) return null; } return super.representJavaBeanProperty(javaBean, property, propertyValue, customTag); }
@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 void write(Writer output, Map<String, Object> o, Model model) throws IOException { //TODO improve SnakeYAML API (A. Somov) DumperOptions dumperOptions = new DumperOptions(); dumperOptions.setIndent(2); dumperOptions.setWidth(80); Serializer serializer = new Serializer(new Emitter(output, dumperOptions), new ModelResolver(), dumperOptions, Tag.MAP); Representer representer = new ModelRepresenter(); try { serializer.open(); Node node = representer.represent(model); serializer.serialize(node); serializer.close(); } catch (IOException e) { throw new YAMLException(e); } } }
for (Object itemKey : mapping.keySet()) { Object itemValue = mapping.get(itemKey); Node nodeKey = representData(itemKey); Node nodeValue = representData(itemValue);
public Node representData( Object data ) { return representMapping( Tags.MAP, toMap( (Xpp3Dom) data ), null ); }
public void write( Writer output, Map<String, Object> o, Model model ) throws IOException { DumperOptions options = new DumperOptions(); options.setExplicitRoot( Tags.MAP ); options.setDefaultFlowStyle( FlowStyle.AUTO ); options.setIndent( 2 ); options.setWidth( 80 ); Representer representer = new ModelRepresenter(); Dumper dumper = new Dumper( representer, options ); Yaml yaml = new Yaml( dumper ); yaml.dump( model, output ); }
for (Object itemKey : mapping.keySet()) { Object itemValue = mapping.get(itemKey); Node nodeKey = representData(itemKey); Node nodeValue = representData(itemValue);
public Node representData( Object data ) { return representMapping( Tags.MAP, toMap( (Xpp3Dom) data ), null ); }
public void write( Writer output, Map<String, Object> o, Model model ) throws IOException { DumperOptions options = new DumperOptions(); options.setExplicitRoot( Tags.MAP ); options.setDefaultFlowStyle( FlowStyle.AUTO ); options.setIndent( 2 ); options.setWidth( 80 ); Representer representer = new ModelRepresenter(); Dumper dumper = new Dumper( representer, options ); Yaml yaml = new Yaml( dumper ); yaml.dump( model, output ); }
for ( Property property : properties ) ScalarNode nodeKey = (ScalarNode) representData( property.getName() ); Object memberValue = property.get( javaBean ); boolean hasAlias = false; Node nodeValue = representData( memberValue );
protected NodeTuple representJavaBeanProperty(Object javaBean, Property property, Object propertyValue, Tag customTag) { if (property != null && property.getName().equals("pomFile")) { // "pomFile" is not a part of POM http://maven.apache.org/xsd/maven-4.0.0.xsd return null; } if (propertyValue == null) return null; if (propertyValue instanceof Map) { Map map = (Map) propertyValue; if (map.isEmpty()) return null; } if (propertyValue instanceof List) { List map = (List) propertyValue; if (map.isEmpty()) return null; } if (javaBean instanceof Dependency) { //skip optional if it is false if (skipBoolean(property, "optional", propertyValue, false)) return null; //skip type if it is jar if (skipString(property, "type", propertyValue, "jar")) return null; } if (javaBean instanceof Plugin) { //skip extensions if it is false if (skipBoolean(property, "extensions", propertyValue, false)) return null; //skip inherited if it is true if (skipBoolean(property, "inherited", propertyValue, true)) return null; } return super.representJavaBeanProperty(javaBean, property, propertyValue, customTag); }
@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 void write(Writer output, Map<String, Object> o, Model model) throws IOException { //TODO improve SnakeYAML API (A. Somov) DumperOptions dumperOptions = new DumperOptions(); dumperOptions.setIndent(2); dumperOptions.setWidth(80); Serializer serializer = new Serializer(new Emitter(output, dumperOptions), new ModelResolver(), dumperOptions, Tag.MAP); Representer representer = new ModelRepresenter(); try { serializer.open(); Node node = representer.represent(model); serializer.serialize(node); serializer.close(); } catch (IOException e) { throw new YAMLException(e); } } }
for ( Property property : properties ) ScalarNode nodeKey = (ScalarNode) representData( property.getName() ); Object memberValue = property.get( javaBean ); boolean hasAlias = false; Node nodeValue = representData( memberValue );