/** * @since 2.5 */ @Override public YAMLMapper copy() { _checkInvalidCopy(YAMLMapper.class); return new YAMLMapper(this); }
/** * @since 2.5 */ @Override public YAMLMapper copy() { _checkInvalidCopy(YAMLMapper.class); return new YAMLMapper(this); }
private JsonNode getSpec(String spec) throws IOException { return new YAMLFactory(new YAMLMapper()).createParser(new InputStreamReader( SpecTest.class.getResourceAsStream( "/spec/specs/" + spec))).readValueAsTree(); }
/** * Convert this RAML object to Yaml. * * @return Yaml string. * @throws IOException If something goes wrong. */ public String toYaml() throws IOException { YAMLMapper mapper = new YAMLMapper(); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); mapper.configure(YAMLGenerator.Feature.ALWAYS_QUOTE_NUMBERS_AS_STRINGS, false); mapper.configure(YAMLGenerator.Feature.MINIMIZE_QUOTES, true); return "#%RAML 1.0\n" + mapper.writer().withDefaultPrettyPrinter().writeValueAsString(this); }
@Override protected ObjectMapper getObjectMapper() { return new YAMLMapper(); }
public DockerComposeGenerator(DockerCompose model) { this.model = model; YAMLFactory factory = new YAMLFactory(); mapper = new YAMLMapper(factory); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); }
@Override public String toString() { YAMLMapper mapper = new YAMLMapper(); try { return mapper.writeValueAsString(this); } catch (JsonProcessingException e) { throw new RuntimeException(e); } }
@Override public String toString() { YAMLMapper mapper = new YAMLMapper(); try { return mapper.writeValueAsString(this); } catch (JsonProcessingException e) { throw new RuntimeException(e); } }
@Override public String toString() { YAMLMapper mapper = new YAMLMapper(); try { return mapper.writeValueAsString(this); } catch (JsonProcessingException e) { throw new RuntimeException(e); } }
@Override public String toString() { YAMLMapper mapper = new YAMLMapper(); try { return mapper.writeValueAsString(this); } catch (JsonProcessingException e) { throw new RuntimeException(e); } }
public static <T> T fromYamlString(String yamlContent, Class<T> c, boolean ignoreUnknownProperties) { ObjectMapper mapper = new YAMLMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, !ignoreUnknownProperties); try { return mapper.readValue(yamlContent, c); } catch (InvalidFormatException e) { throw new IllegalArgumentException(e); } catch (IOException e) { throw new RuntimeException(e); } }
public static String getContent(File file, Function<JsonNode, String> edit) { YAMLMapper mapper = new YAMLMapper(); try { JsonNode node = mapper.readTree(file); return edit.apply(node); } catch (IOException e) { throw new RuntimeException(e); } }
@Bean public YAMLMapper yamlMapper() { YAMLMapper mapper = new YAMLMapper(); JacksonUtils.registerModules(mapper); return mapper; } }
@Override public synchronized YAMLMapper getDefaultMapper() { if (_defaultMapper == null) { _defaultMapper = new YAMLMapper(); //tarik: maybe there is better default config? _setAnnotations(_defaultMapper, _defaultAnnotationsToUse); } return _defaultMapper; }
public static <T> String toYamlString(T instance) { ObjectMapper mapper = new YAMLMapper() .disable(YAMLGenerator.Feature.USE_NATIVE_TYPE_ID) .setSerializationInclusion(JsonInclude.Include.NON_EMPTY); try { return mapper.writeValueAsString(instance); } catch (JsonProcessingException e) { throw new RuntimeException(e); } }
private Map<String, String> readConfigFromYamlType(InputStream configFileStream) throws IOException { ObjectReader reader = new YAMLMapper().reader(); Map<String, Object> confMap = reader.forType(new TypeReference<Map<String, Object>>() {}) .readValue(configFileStream); return confMap.entrySet().stream() .collect(toMap(Map.Entry::getKey, e -> convertValueAsString(e.getValue()))); }
@Override public String toString() { YAMLMapper mapper = new YAMLMapper().disable(YAMLGenerator.Feature.USE_NATIVE_TYPE_ID); try { return mapper.writeValueAsString(this); } catch (JsonProcessingException e) { throw new RuntimeException(e); } }
@Override public String toString() { YAMLMapper mapper = new YAMLMapper().disable(YAMLGenerator.Feature.USE_NATIVE_TYPE_ID); try { return mapper.writeValueAsString(this); } catch (JsonProcessingException e) { throw new RuntimeException(e); } }
@Override public String toString() { YAMLMapper mapper = new YAMLMapper().disable(YAMLGenerator.Feature.USE_NATIVE_TYPE_ID); try { return mapper.writeValueAsString(this); } catch (JsonProcessingException e) { throw new RuntimeException(e); } }
private static ObjectMapper newYamlMapper() { // Configures Yaml Factory final YAMLFactory yamlFactory = new YAMLFactory(); yamlFactory.configure(WRITE_DOC_START_MARKER, false); yamlFactory.configure(USE_NATIVE_TYPE_ID, false); yamlFactory.configure(MINIMIZE_QUOTES, true); // Constructs Yaml Mapper final ObjectMapper yamlMapper = new YAMLMapper(yamlFactory); // Register modules registerModules(yamlMapper); return yamlMapper; }