com.fasterxml.jackson.dataformat.yaml.YAMLFactory.<init>()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(6.2k)|赞(0)|评价(0)|浏览(316)

本文整理了Java中com.fasterxml.jackson.dataformat.yaml.YAMLFactory.<init>()方法的一些代码示例,展示了YAMLFactory.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YAMLFactory.<init>()方法的具体详情如下:
包路径:com.fasterxml.jackson.dataformat.yaml.YAMLFactory
类名称:YAMLFactory
方法名:<init>

YAMLFactory.<init>介绍

[英]Default constructor used to create factory instances. Creation of a factory instance is a light-weight operation, but it is still a good idea to reuse limited number of factory instances (and quite often just a single instance): factories are used as context for storing some reused processing objects (such as symbol tables parsers use) and this reuse only works within context of a single factory instance.
[中]用于创建工厂实例的默认构造函数。创建工厂实例是一项轻量级操作,但重用有限数量的工厂实例(通常只有一个实例)仍然是一个好主意:工厂被用作存储一些重用处理对象(例如解析器使用的符号表)的上下文,这种重用只在单个工厂实例的上下文中起作用。

代码示例

代码示例来源:origin: redisson/redisson

/**
 * Method that we need to override to actually make restoration go
 * through constructors etc.
 * Also: must be overridden by sub-classes as well.
 */
@Override
protected Object readResolve() {
  return new YAMLFactory(this, _objectCodec);
}

代码示例来源:origin: redisson/redisson

public YAMLMapper() { this(new YAMLFactory()); }

代码示例来源:origin: com.fasterxml.jackson.dataformat/jackson-dataformat-yaml

/**
 * Method that we need to override to actually make restoration go
 * through constructors etc.
 * Also: must be overridden by sub-classes as well.
 */
@Override
protected Object readResolve() {
  return new YAMLFactory(this, _objectCodec);
}

代码示例来源:origin: bootique/bootique

public JsonNodeYamlParser(ObjectMapper mapper) {
  this.mapper = mapper;
  this.yamlFactory = new YAMLFactory();
}

代码示例来源:origin: Graylog2/graylog2-server

private NetFlowV9FieldTypeRegistry(InputStream definitions) throws IOException {
  this(definitions, new ObjectMapper(new YAMLFactory()));
}

代码示例来源:origin: dropwizard/dropwizard

/**
   * Creates a new configuration factory for the given class.
   *
   * @param klass          the configuration class
   * @param validator      the validator to use
   * @param objectMapper   the Jackson {@link ObjectMapper} to use
   * @param propertyPrefix the system property name prefix used by overrides
   */
  public YamlConfigurationFactory(Class<T> klass,
                  @Nullable Validator validator,
                  ObjectMapper objectMapper,
                  String propertyPrefix) {
    super(new YAMLFactory(), YAMLFactory.FORMAT_NAME_YAML, klass, validator, objectMapper, propertyPrefix);
  }
}

代码示例来源:origin: apache/pulsar

public static ObjectMapper createYaml() {
  ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
  // forward compatibility for the properties may go away in the future
  mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
  mapper.configure(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL, true);
  mapper.setSerializationInclusion(Include.NON_NULL);
  return mapper;
}

代码示例来源:origin: google/data-transfer-project

@VisibleForTesting
void parseRetryLibrary(InputStream in) {
 if (in != null) {
  ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
  try {
   settings.put("retryLibrary", mapper.readValue(in, RetryStrategyLibrary.class));
  } catch (IOException e) {
   throw new RuntimeException("Could not parse extension settings", e);
  }
 }
}

代码示例来源:origin: redisson/redisson

@Override
public YAMLFactory copy()
{
  _checkInvalidCopy(YAMLFactory.class);
  return new YAMLFactory(this, null);
}

代码示例来源:origin: google/data-transfer-project

@VisibleForTesting
void parseSimple(InputStream in) {
 if (in == null) {
  settings = new HashMap<>();
 } else {
  ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
  try {
   settings = mapper.readValue(in, Map.class);
  } catch (IOException e) {
   throw new RuntimeException("Could not parse extension settings", e);
  }
 }
}

代码示例来源:origin: stackoverflow.com

public MyYamlFile readYaml(final File file) {
  final ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); // jackson databind
  return mapper.readValue(file, MyYamlFile.class);
}

代码示例来源:origin: redisson/redisson

public <T> T fromYAML(File file, Class<T> configType, ClassLoader classLoader) throws IOException {
  yamlMapper = createMapper(new YAMLFactory(), classLoader);
  String content = resolveEnvParams(new FileReader(file));
  return yamlMapper.readValue(content, configType);
}

代码示例来源:origin: redisson/redisson

public <T> T fromYAML(File file, Class<T> configType, ClassLoader classLoader) throws IOException {
  yamlMapper = createMapper(new YAMLFactory(), classLoader);
  String content = resolveEnvParams(new FileReader(file));
  return yamlMapper.readValue(content, configType);
}

代码示例来源:origin: rapidoid/rapidoid

private static ObjectMapper mapper() {
  ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
  mapper.setBase64Variant(Base64Variants.MODIFIED_FOR_URL);
  mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
  mapper.registerModule(new AfterburnerModule());
  return mapper;
}

代码示例来源:origin: com.fasterxml.jackson.dataformat/jackson-dataformat-yaml

@Override
public YAMLFactory copy()
{
  _checkInvalidCopy(YAMLFactory.class);
  return new YAMLFactory(this, null);
}

代码示例来源:origin: joelittlejohn/jsonschema2pojo

private static ContentResolver createContentResolver(GenerationConfig config) {
  if (config.getSourceType() == SourceType.YAMLSCHEMA || config.getSourceType() == SourceType.YAML) {
    return new ContentResolver(new YAMLFactory());
  } else {
    return new ContentResolver();
  }
}

代码示例来源:origin: joelittlejohn/jsonschema2pojo

private static SchemaGenerator createSchemaGenerator(GenerationConfig config) {
  if (config.getSourceType() == SourceType.YAMLSCHEMA || config.getSourceType() == SourceType.YAML) {
    return new SchemaGenerator(new YAMLFactory());
  } else {
    return new SchemaGenerator();
  }
}

代码示例来源:origin: jmxtrans/jmxtrans

@Nonnull
public static Injector createInjector(@Nonnull JmxTransConfiguration configuration) {
  return Guice.createInjector(
      new JmxTransModule(configuration),
      new ObjectMapperModule(JsonFormat.class)
          .registerModule(new GuavaModule()),
      new ObjectMapperModule(YamlFormat.class)
          .withObjectMapper(new ObjectMapper(new YAMLFactory()))
          .registerModule(new GuavaModule())
  );
}

代码示例来源:origin: swagger-api/swagger-core

protected static ObjectMapper createYaml() {
  YAMLFactory factory = new YAMLFactory();
  factory.disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER);
  factory.enable(YAMLGenerator.Feature.MINIMIZE_QUOTES);
  factory.enable(YAMLGenerator.Feature.SPLIT_LINES);
  factory.enable(YAMLGenerator.Feature.ALWAYS_QUOTE_NUMBERS_AS_STRINGS);
  return create(factory);
}

代码示例来源:origin: spullara/mustache.java

private JsonNode getSpec(String spec) throws IOException {
 return new YAMLFactory(new YAMLMapper()).createParser(new InputStreamReader(
     SpecTest.class.getResourceAsStream(
         "/spec/specs/" + spec))).readValueAsTree();
}

相关文章