public void setTypes(Class<? extends Object> keyType, Class<? extends Object> valueType) { for (NodeTuple nodes : value) { nodes.getValueNode().setType(valueType); nodes.getKeyNode().setType(keyType); } }
public void setOnlyKeyType(Class<? extends Object> keyType) { for (NodeTuple nodes : value) { nodes.getKeyNode().setType(keyType); } }
public Node(Tag tag, Mark startMark, Mark endMark) { setTag(tag); this.startMark = startMark; this.endMark = endMark; this.type = Object.class; this.twoStepsConstruction = false; this.resolved = true; this.useClassConstructor = null; }
public AnchorNode(Node realNode) { super(realNode.getTag(), realNode.getStartMark(), realNode.getEndMark()); this.realNode = realNode; }
@Override public Object construct(Node node) { MappingNode mnode = (MappingNode) node; if (node.isTwoStepsConstruction()) { return createDefaultMap(mnode.getValue().size()); } else { return constructMapping(mnode); } }
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(); }
@Override public Object construct(Node node) { throw new ConstructorException(null, null, "could not determine a constructor for the tag " + node.getTag(), node.getStartMark()); } }
protected String constructScalar(ScalarNode node) { return node.getValue(); }
public TypeDescription(Class<? extends Object> clazz, String tag) { this(clazz, new Tag(tag), null); }
protected Node representScalar(Tag tag, String value, DumperOptions.ScalarStyle style) { if (style == null) { style = this.defaultScalarStyle; } Node node = new ScalarNode(tag, value, null, null, style); return node; }
@Override public boolean equals(Object obj) { if (obj instanceof Tag) { return value.equals(((Tag) obj).getValue()); } else return false; }
@Override public Object construct(Node node) { SequenceNode seqNode = (SequenceNode) node; if (node.isTwoStepsConstruction()) { return newList(seqNode); } else { return constructSequence(seqNode); } }
public void setListType(Class<? extends Object> listType) { for (Node node : value) { node.setType(listType); } }
public CollectionNode(Tag tag, Mark startMark, Mark endMark, DumperOptions.FlowStyle flowStyle) { super(tag, startMark, endMark); setFlowStyle(flowStyle); }
@Override public Object construct(Node node) { if (node.isTwoStepsConstruction()) { return (constructedObjects.containsKey(node) ? constructedObjects.get(node) : createDefaultSet(((MappingNode) node).getValue().size())); } else { return constructSet((MappingNode) node); } }