protected Object finalizeConstruction(Node node, Object data) { final Class<? extends Object> type = node.getType(); if (typeDefinitions.containsKey(type)) { return typeDefinitions.get(type).finalizeConstruction(data); } return data; }
@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) { SequenceNode snode = (SequenceNode) node; if (List.class.isAssignableFrom(node.getType())) { List<Object> list = (List<Object>) object; constructSequenceStep2(snode, list); } else if (node.getType().isArray()) { constructArrayStep2(snode, object); } else { throw new YAMLException("Immutable objects cannot be recursive."); } } }
@Override public Object construct(Node node) { if (node.getType().equals(XmlSuite.ParallelMode.class)) { String parallel = (String) constructScalar((ScalarNode) node); return XmlSuite.ParallelMode.getValidParallel(parallel); } if (node.getType().equals(XmlSuite.FailurePolicy.class)) { String failurePolicy = (String) constructScalar((ScalarNode) node); return XmlSuite.FailurePolicy.getValidPolicy(failurePolicy); } return super.construct(node); } }
@Override protected Construct getConstructor(Node node) { if (List.class.isAssignableFrom(node.getType())) { return new AbstractConstruct() { @Override public Object construct(Node node) { return new ArrayList<Object>(); } }; } return super.getConstructor(node); } }
protected Object newInstance(Class<?> ancestor, Node node, boolean tryDefault) throws InstantiationException { final Class<? extends Object> type = node.getType(); if (typeDefinitions.containsKey(type)) { TypeDescription td = typeDefinitions.get(type); final Object instance = td.newInstance(node); if (instance != null) { return instance; } } if (tryDefault) { /* * Removed <code> have InstantiationException in case of abstract * type */ if (ancestor.isAssignableFrom(type) && !Modifier.isAbstract(type.getModifiers())) { try { java.lang.reflect.Constructor<?> c = type.getDeclaredConstructor(); c.setAccessible(true); return c.newInstance(); } catch (NoSuchMethodException e) { throw new InstantiationException("NoSuchMethodException:" + e.getLocalizedMessage()); } catch (Exception e) { throw new YAMLException(e); } } } throw new InstantiationException(); }
@Override public Object construct(Node node) { if (node.getType().equals(XmlSuite.ParallelMode.class)) { String parallel = constructScalar((ScalarNode) node); return XmlSuite.ParallelMode.getValidParallel(parallel); } if (node.getType().equals(XmlSuite.FailurePolicy.class)) { String failurePolicy = constructScalar((ScalarNode) node); return XmlSuite.FailurePolicy.getValidPolicy(failurePolicy); } return super.construct(node); } }
public boolean useClassConstructor() { if (useClassConstructor == null) { if (!tag.isSecondary() && resolved && !Object.class.equals(type) && !tag.equals(Tag.NULL)) { return true; } else if (tag.isCompatible(getType())) { // the tag is compatible with the runtime class // the tag will be ignored return true; } else { return false; } } return useClassConstructor.booleanValue(); }
for (Node child : node.getValue()) { if (child.getType() == Object.class) { child.setType(componentType);
@SuppressWarnings("unchecked") public Object construct(Node node) { SequenceNode snode = (SequenceNode) node; if (Set.class.isAssignableFrom(node.getType())) { if (node.isTwoStepsConstruction()) { throw new YAMLException("Set cannot be recursive."); return constructSet(snode); } else if (Collection.class.isAssignableFrom(node.getType())) { if (node.isTwoStepsConstruction()) { return newList(snode); return constructSequence(snode); } else if (node.getType().isArray()) { if (node.isTwoStepsConstruction()) { return createArray(node.getType(), snode.getValue().size()); } else { return constructArray(snode); for (java.lang.reflect.Constructor<?> constructor : node.getType() .getDeclaredConstructors()) { if (snode.getValue().size() == constructor.getParameterTypes().length) { + " arguments found for " + node.getType());
SequenceNode snode = (SequenceNode) valueNode; snode.setListType(t); } else if (Set.class.isAssignableFrom(valueNode.getType())) { Class<?> t = arguments[0]; MappingNode mnode = (MappingNode) valueNode; mnode.setOnlyKeyType(t); mnode.setUseClassConstructor(true); } else if (Map.class.isAssignableFrom(valueNode.getType())) { Class<?> ketType = arguments[0]; Class<?> valueType = arguments[1];
protected Object finalizeConstruction(Node node, Object data) { final Class<? extends Object> type = node.getType(); if (typeDefinitions.containsKey(type)) { return typeDefinitions.get(type).finalizeConstruction(data); } return data; }
@Override protected Object constructObject(Node node) { if (node.getType() == IntOrString.class) { return constructIntOrString((ScalarNode) node); } if (node.getType() == byte[].class) { return constructByteArray((ScalarNode) node); } if (node.getType() == org.joda.time.DateTime.class) { return constructDateTime((ScalarNode) node); } return super.constructObject(node); }
@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 public Object construct(Node node) { if (node.getType() == Path.class) { ScalarNode snode = (ScalarNode) node; return Paths.get(snode.getValue()); } else { return super.construct(node); } } }