Beispiel #1
0
 /**
  * Make YAML aware how to parse a custom Class. If there is no root Class assigned in constructor
  * then the 'root' property of this definition is respected.
  *
  * @param definition to be added to the Constructor
  * @return the previous value associated with <tt>definition</tt>, or <tt>null</tt> if there was
  *     no mapping for <tt>definition</tt>.
  */
 public TypeDescription addTypeDescription(TypeDescription definition) {
   if (definition == null) {
     throw new NullPointerException("TypeDescription is required.");
   }
   Tag tag = definition.getTag();
   typeTags.put(tag, definition.getType());
   return typeDefinitions.put(definition.getType(), definition);
 }
Beispiel #2
0
 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);
 }