/** * Create the {@link Yaml} instance to use. * <p>The default implementation sets the "allowDuplicateKeys" flag to {@code false}, * enabling built-in duplicate key handling in SnakeYAML 1.18+. * @see LoaderOptions#setAllowDuplicateKeys(boolean) */ protected Yaml createYaml() { LoaderOptions options = new LoaderOptions(); options.setAllowDuplicateKeys(false); return new Yaml(options); }
private static <T> T parseObject(String rawConfig) { Constructor constructor = new Constructor(ConfiguratorConfig.class); TypeDescription itemDescription = new TypeDescription(ConfiguratorConfig.class); itemDescription.addPropertyParameters("items", ConfigItem.class); constructor.addTypeDescription(itemDescription); Yaml yaml = new Yaml(constructor); return yaml.load(rawConfig); }
/** * Create Yaml instance. It is safe to create a few instances and use them * in different Threads. * * @param constructor * BaseConstructor to construct incoming documents * @param representer * Representer to emit outgoing objects */ public Yaml(BaseConstructor constructor, Representer representer) { this(constructor, representer, initDumperOptions(representer)); }
private static Yaml yaml() { TypeDescription topologyDescription = new TypeDescription(TopologyDef.class); topologyDescription.putListPropertyType("spouts", SpoutDef.class); topologyDescription.putListPropertyType("bolts", BoltDef.class); topologyDescription.putListPropertyType("includes", IncludeDef.class); Constructor constructor = new Constructor(TopologyDef.class); constructor.addTypeDescription(topologyDescription); Yaml yaml = new Yaml(constructor); return yaml; }
public void save(Writer output) { DumperOptions options = new DumperOptions(); options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); getYaml().dump(this, output); }
/** * Serialize a sequence of Java objects into a YAML stream. * * @param data * Iterator with Objects * @param output * stream to write to */ public void dumpAll(Iterator<? extends Object> data, Writer output) { dumpAll(data, output, null); }
/** * Create Yaml instance. It is safe to create a few instances and use them * in different Threads. * * @param constructor * BaseConstructor to construct incoming documents * @param representer * Representer to emit outgoing objects * @param dumperOptions * DumperOptions to configure outgoing objects * @param resolver * Resolver to detect implicit type */ public Yaml(BaseConstructor constructor, Representer representer, DumperOptions dumperOptions, Resolver resolver) { this(constructor, representer, dumperOptions, new LoaderOptions(), resolver); }
/** * @deprecated use getScalarStyle() instead * @return char which is a value behind ScalarStyle */ @Deprecated public Character getStyle() { return this.style.getChar(); }
@Override public String toString() { return "Version: " + getRepresentation(); } }
@Override public String toString() { return "Line break: " + name(); }
public Property getProperty(String name) { if (!delegatesChecked) { checkDelegates(); } return properties.containsKey(name) ? properties.get(name) : discoverProperty(name); }
@Deprecated public ScalarNode(Tag tag, boolean resolved, String value, Mark startMark, Mark endMark, Character style) { this(tag, resolved, value, startMark, endMark, DumperOptions.ScalarStyle.createStyle(style)); }
@Deprecated public SequenceStartEvent(String anchor, String tag, boolean implicit, Mark startMark, Mark endMark, Boolean flowStyle) { this(anchor, tag, implicit, startMark, endMark, DumperOptions.FlowStyle.fromBoolean(flowStyle)); }
private static <T> T parseObject(String rawConfig) { Constructor constructor = new Constructor(ConfiguratorConfig.class); TypeDescription itemDescription = new TypeDescription(ConfiguratorConfig.class); itemDescription.addPropertyParameters("items", ConfigItem.class); constructor.addTypeDescription(itemDescription); Yaml yaml = new Yaml(constructor); return yaml.load(rawConfig); }
/** * Create the {@link Yaml} instance to use. * <p>The default implementation sets the "allowDuplicateKeys" flag to {@code false}, * enabling built-in duplicate key handling in SnakeYAML 1.18+. * @see LoaderOptions#setAllowDuplicateKeys(boolean) */ protected Yaml createYaml() { LoaderOptions options = new LoaderOptions(); options.setAllowDuplicateKeys(false); return new Yaml(options); }
@Deprecated public ScalarEvent(String anchor, String tag, ImplicitTuple implicit, String value, Mark startMark, Mark endMark, Character style) { this(anchor, tag, implicit, value, startMark, endMark, DumperOptions.ScalarStyle.createStyle(style)); }
@Deprecated public CollectionStartEvent(String anchor, String tag, boolean implicit, Mark startMark, Mark endMark, Boolean flowStyle) { this(anchor, tag, implicit, startMark, endMark, DumperOptions.FlowStyle.fromBoolean(flowStyle)); }
public static TagRouterRule parse(String rawRule) { Constructor constructor = new Constructor(TagRouterRule.class); TypeDescription tagDescription = new TypeDescription(TagRouterRule.class); tagDescription.addPropertyParameters("tags", Tag.class); constructor.addTypeDescription(tagDescription); Yaml yaml = new Yaml(constructor); TagRouterRule rule = yaml.load(rawRule); rule.setRawRule(rawRule); if (CollectionUtils.isEmpty(rule.getTags())) { rule.setValid(false); } rule.init(); return rule; } }
public static TagRouterRule parse(String rawRule) { Constructor constructor = new Constructor(TagRouterRule.class); TypeDescription tagDescription = new TypeDescription(TagRouterRule.class); tagDescription.addPropertyParameters("tags", Tag.class); constructor.addTypeDescription(tagDescription); Yaml yaml = new Yaml(constructor); TagRouterRule rule = yaml.load(rawRule); rule.setRawRule(rawRule); if (CollectionUtils.isEmpty(rule.getTags())) { rule.setValid(false); } rule.init(); return rule; } }