public void registerAlias(Class<?> clazz, String alias) { Preconditions.checkArgument(!Strings.isNullOrEmpty(alias), "empty alias"); Tag tag = new Tag('!' + alias); // Add tag to representer and constructor to "notify" them about the alias snakeYAML.getRepresenter().addClassTag(clazz, tag); snakeYAML.getConstructor().addTypeDescription(new TypeDescription(clazz, tag)); }
public void writeDocumented(Writer writer, Object conf) throws IOException { // Write configuration description writeComments(writer, Descriptions.of(conf)); writer.append(DOCUMENT_START); // Write only one configuration, but don't create a new list for that as SnakeYAML is doing that snakeYAML.getYaml().dumpAll(Iterators.singletonIterator(conf), writer); writer.append(newLine); }
public YAMLWriter(SnakeYAML snakeYAML, String[] header) { this.snakeYAML = Preconditions.checkNotNull(snakeYAML, "snakeYAML"); this.newLine = snakeYAML.getDumperOptions().getLineBreak().getString(); this.header = header; }