return obj; } else { return constructJavaBean2ndStep(mnode, obj);
try { TypeDescription memberDescription = typeDefinitions.get(beanType); Property property = memberDescription == null ? getProperty(beanType, key) : memberDescription.getProperty(key); ? newInstance(memberDescription, key, valueNode) : constructObject(valueNode);
public Constructor(TypeDescription theRoot, Collection<TypeDescription> moreTDs) { if (theRoot == null) { throw new NullPointerException("Root type must be provided."); } this.yamlConstructors.put(null, new ConstructYamlObject()); if (!Object.class.equals(theRoot.getType())) { rootTag = new Tag(theRoot.getType()); } yamlClassConstructors.put(NodeId.scalar, new ConstructScalar()); yamlClassConstructors.put(NodeId.mapping, new ConstructMapping()); yamlClassConstructors.put(NodeId.sequence, new ConstructSequence()); addTypeDescription(theRoot); if (moreTDs != null) { for (TypeDescription td : moreTDs) { addTypeDescription(td); } } }
return super.constructJavaBean2ndStep(node, object);
String key = (String) constructObject(keyNode); try { Property property = getProperty(beanType, key); valueNode.setType(property.getType()); TypeDescription memberDescription = typeDefinitions.get(beanType);
String key = (String) constructObject(keyNode); try { Property property = getProperty(beanType, key); valueNode.setType(property.getType()); TypeDescription memberDescription = typeDefinitions.get(beanType);
try { TypeDescription memberDescription = typeDefinitions.get(beanType); Property property = memberDescription == null ? getProperty(beanType, key) : memberDescription.getProperty(key); ? newInstance(memberDescription, key, valueNode) : constructObject(valueNode);
return createEmptyJavaBean(mnode); } else { return constructJavaBean2ndStep(mnode, createEmptyJavaBean(mnode));
return createEmptyJavaBean(mnode); } else { return constructJavaBean2ndStep(mnode, createEmptyJavaBean(mnode));
String coordinate = removeId(node); if (coordinate == null) { return super.constructJavaBean2ndStep(node, object); Dependency dep = (Dependency) super.constructJavaBean2ndStep(node, object); return ConstructDependency.createDependency(coordinate, dep); } else if (type.equals(Model.class)) { Coordinate coord = Coordinate.createCoordinate(coordinate); Model model = (Model) super.constructJavaBean2ndStep(node, object); return coord.mergeModel(model); } else if (type.equals(Plugin.class)) { Coordinate coord = Coordinate.createCoordinate(coordinate); Plugin plugin = (Plugin) super.constructJavaBean2ndStep(node, object); return coord.mergePlugin(plugin); } else if (type.equals(ReportPlugin.class)) { Coordinate coord = Coordinate.createCoordinate(coordinate); ReportPlugin plugin = (ReportPlugin) super.constructJavaBean2ndStep(node, object); return coord.mergeReportPlugin(plugin); return super.constructJavaBean2ndStep(node, object);
return obj; } else { return constructJavaBean2ndStep(mnode, obj);
@Override protected Object constructJavaBean2ndStep(MappingNode node, Object object) { if (node.getNodeId()==NodeId.mapping) { List<NodeTuple> toExtract = new ArrayList<>(); // Find all matching field names and remember them for (NodeTuple nodeTuple : node.getValue()) { Node prospectNode = nodeTuple.getKeyNode(); if (nodeTuple.getKeyNode() instanceof ScalarNode) { ScalarNode nameNode = (ScalarNode) prospectNode; if (SnakeYamlCharmer.this.handlerDefs.keySet().contains(nameNode.getValue())) { toExtract.add(nodeTuple); } } } /** * Remove each matching field name by node and owning object * Construct a safe collection-based Java object * Call the delegated handler for the owning object and the sub-object */ for (NodeTuple nodeTuple : toExtract) { node.getValue().remove(nodeTuple); String nodeName = ((ScalarNode) nodeTuple.getKeyNode()).getValue(); Object subObject = ctor.constructObject(nodeTuple.getValueNode()); HandlerDef handlerDef = SnakeYamlCharmer.this.handlerDefs.get(nodeName); handlerDef.handler.handleMapping(object,subObject); } } return super.constructJavaBean2ndStep(node,object); } }
/** * This method checks if a snakeyaml Node is of type VNFAutoscaling and applies the custom * parsing for it. Otherwise the default is used. * * @param node * @param object * @return */ @Override protected Object constructJavaBean2ndStep(MappingNode node, Object object) { if (node.getType().equals(VNFAutoscaling.class)) { Object nodeMap = null; try { nodeMap = yamlNodeToMap(node); } catch (BadFormatException e) { e.printStackTrace(); } VNFAutoscaling vnfAutoscaling = new VNFAutoscaling(nodeMap); return vnfAutoscaling; } return super.constructJavaBean2ndStep(node, object); } }
public Constructor(TypeDescription theRoot, Collection<TypeDescription> moreTDs) { if (theRoot == null) { throw new NullPointerException("Root type must be provided."); } this.yamlConstructors.put(null, new ConstructYamlObject()); if (!Object.class.equals(theRoot.getType())) { rootTag = new Tag(theRoot.getType()); } yamlClassConstructors.put(NodeId.scalar, new ConstructScalar()); yamlClassConstructors.put(NodeId.mapping, new ConstructMapping()); yamlClassConstructors.put(NodeId.sequence, new ConstructSequence()); addTypeDescription(theRoot); if (moreTDs != null) { for (TypeDescription td : moreTDs) { addTypeDescription(td); } } }
public Constructor(TypeDescription theRoot) { if (theRoot == null) { throw new NullPointerException("Root type must be provided."); } this.yamlConstructors.put(null, new ConstructYamlObject()); if (!Object.class.equals(theRoot.getType())) { rootTag = new Tag(theRoot.getType()); } typeTags = new HashMap<Tag, Class<? extends Object>>(); typeDefinitions = new HashMap<Class<? extends Object>, TypeDescription>(); yamlClassConstructors.put(NodeId.scalar, new ConstructScalar()); yamlClassConstructors.put(NodeId.mapping, new ConstructMapping()); yamlClassConstructors.put(NodeId.sequence, new ConstructSequence()); addTypeDescription(theRoot); }
public Constructor(TypeDescription theRoot) { if (theRoot == null) { throw new NullPointerException("Root type must be provided."); } this.yamlConstructors.put(null, new ConstructYamlObject()); if (!Object.class.equals(theRoot.getType())) { rootTag = new Tag(theRoot.getType()); } typeTags = new HashMap<Tag, Class<? extends Object>>(); typeDefinitions = new HashMap<Class<? extends Object>, TypeDescription>(); yamlClassConstructors.put(NodeId.scalar, new ConstructScalar()); yamlClassConstructors.put(NodeId.mapping, new ConstructMapping()); yamlClassConstructors.put(NodeId.sequence, new ConstructSequence()); addTypeDescription(theRoot); }
@SuppressWarnings("unchecked") public void construct2ndStep(Node node, Object object) { if (Map.class.isAssignableFrom(node.getType())) { constructMapping2ndStep((MappingNode) node, (Map<Object, Object>) object); } else if (Set.class.isAssignableFrom(node.getType())) { constructSet2ndStep((MappingNode) node, (Set<Object>) object); } else { constructJavaBean2ndStep((MappingNode) node, object); } }
@SuppressWarnings("unchecked") public void construct2ndStep(Node node, Object object) { if (Map.class.isAssignableFrom(node.getType())) { constructMapping2ndStep((MappingNode) node, (Map<Object, Object>) object); } else if (Set.class.isAssignableFrom(node.getType())) { constructSet2ndStep((MappingNode) node, (Set<Object>) object); } else { constructJavaBean2ndStep((MappingNode) node, object); } }
@SuppressWarnings("unchecked") public void construct2ndStep(Node node, Object object) { if (Map.class.isAssignableFrom(node.getType())) { constructMapping2ndStep((MappingNode) node, (Map<Object, Object>) object); } else if (Set.class.isAssignableFrom(node.getType())) { constructSet2ndStep((MappingNode) node, (Set<Object>) object); } else { constructJavaBean2ndStep((MappingNode) node, object); } }
@Override protected Object createEmptyJavaBean(MappingNode node) { if (YamlTape.class.equals(node.getType())) { return new YamlTape(); } else { return super.createEmptyJavaBean(node); } } }