com.fasterxml.jackson.core.Version类的使用及代码示例

x33g5p2x  于2022-01-31 转载在 其他  
字(9.7k)|赞(0)|评价(0)|浏览(393)

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

Version介绍

[英]Object that encapsulates versioning information of a component. Version information includes not just version number but also optionally group and artifact ids of the component being versioned.

Note that optional group and artifact id properties are new with Jackson 2.0: if provided, they should align with Maven artifact information.
[中]对象,该对象封装组件的版本控制信息。版本信息不仅包括版本号,还包括被版本控制的组件的可选组和工件ID。
请注意,Jackson 2.0新增了可选的组和工件id属性:如果提供,它们应该与Maven工件信息保持一致。

代码示例

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

/**
 * Takes a JSON string that came from the frontend form submission and deserializes it into its {@link DataWrapper} dto
 * representation so that it can be converted to an MVEL expression
 * @param json
 * @return
 */
public DataWrapper convertJsonToDataWrapper(String json) {
  ObjectMapper mapper = new ObjectMapper();
  DataDTODeserializer dtoDeserializer = new DataDTODeserializer();
  SimpleModule module = new SimpleModule("DataDTODeserializerModule", new Version(1, 0, 0, null));
  module.addDeserializer(DataDTO.class, dtoDeserializer);
  mapper.registerModule(module);
  if (json == null || "[]".equals(json)) {
    return null;
  }
  try {
    return mapper.readValue(json, DataWrapper.class);
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: knowm/XChange

@Override
 public void configureObjectMapper(ObjectMapper mapper) {
  super.configureObjectMapper(mapper);
  final SimpleModule customDeserializer =
    new SimpleModule(TrueFxTicker.class.getSimpleName(), Version.unknownVersion());
  customDeserializer.addDeserializer(
    TrueFxTicker.class, new TrueFxTicker.TrueFxTickerDeserializer());
  mapper.registerModule(customDeserializer);
 }
};

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

public String toFullString() {
  return _groupId + '/' + _artifactId + '/' + toString();
}

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

/**
 * Method used by <code>PackageVersion</code> classes to decode version injected by Maven build.
 */
public static Version parseVersion(String s, String groupId, String artifactId)
{
  if (s != null && (s = s.trim()).length() > 0) {
    String[] parts = V_SEP.split(s);
    return new Version(parseVersionPart(parts[0]),
        (parts.length > 1) ? parseVersionPart(parts[1]) : 0,
        (parts.length > 2) ? parseVersionPart(parts[2]) : 0,
        (parts.length > 3) ? parts[3] : null,
        groupId, artifactId);
  }
  return Version.unknownVersion();
}

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

public static <T> ObjectReader getObjectReader(Class<T> type) {
  final ObjectReader objectReader;
  if (getMapper().version().compareTo(new Version(2, 6, 0, null, "com.fasterxml.jackson.core", "jackson-databind")) >= 0) {
    objectReader = getMapper().readerFor(type);
  } else {
    objectReader = getMapper().reader(type);
  }
  return objectReader;
}
private static class AfterburnerModuleRegisterer {

代码示例来源:origin: gchq/Gaffer

@Test
  public void testCanSerialiseWithCustomObjectMapper() throws IOException {
    //Bitmap of (2,3000,300000) serialised in 0.5.11 Roaring Bitmap base 64 encoded
    String serialisedComparisonBitmap = "{\"roaringBitmap\":{\"value\":\"OjAAAAIAAAAAAAEABAAAABgAAAAcAAAAAgC4C+CT\"}}";
    RoaringBitmap comparisonBitmap = new RoaringBitmap();
    comparisonBitmap.add(2);
    comparisonBitmap.add(3000);
    comparisonBitmap.add(300000);
    final ObjectMapper mapper = JSONSerialiser.createDefaultMapper();
    final SimpleModule bitmapModule = new SimpleModule(RoaringBitmapConstants.BITMAP_MODULE_NAME, new Version(1, 0, 9, null, null, null));
    bitmapModule.addSerializer(RoaringBitmap.class, new RoaringBitmapJsonSerialiser());
    bitmapModule.addDeserializer(RoaringBitmap.class, new RoaringBitmapJsonDeserialiser());
    mapper.registerModule(bitmapModule);
    RoaringBitmap testBitmap = mapper.readValue(serialisedComparisonBitmap, RoaringBitmap.class);
    assertEquals(comparisonBitmap, testBitmap);
    String serialisedBitmap = mapper.writeValueAsString(testBitmap);
    assertEquals(serialisedBitmap, serialisedComparisonBitmap);
  }
}

代码示例来源:origin: jfrog/artifactory-client-java

public static <T> T responseToObject(HttpResponse httpResponse, Class<? extends T> object, Class<T> interfaceClass) throws IOException {
  ObjectMapper objectMapper = new ObjectMapper();
  configureObjectMapper(objectMapper);
  if (interfaceClass != null) {
    SimpleModule module = new SimpleModule("CustomModel", Version.unknownVersion());
    SimpleAbstractTypeResolver resolver = new SimpleAbstractTypeResolver();
    resolver.addMapping(interfaceClass, object);
    module.setAbstractTypes(resolver);
    objectMapper.registerModule(module);
  }
  return objectMapper.readValue(httpResponse.getEntity().getContent(), object);
}

代码示例来源:origin: poetix/octarine

public static ObjectMapper mapperWith(JsonSerializer<?>...extraSerialisers) {
  ObjectMapper mapper = new ObjectMapper();
  SimpleModule simpleModule = new SimpleModule("SimpleModule", Version.unknownVersion());
  simpleModule.addSerializer(new ReflectiveRecordSerialiser());
  simpleModule.addSerializer(new StreamSerialiser());
  Stream.of(extraSerialisers).forEach(simpleModule::addSerializer);
  mapper.registerModules(simpleModule);
  return mapper;
}

代码示例来源:origin: bazaarvoice/jolt

public static void configureStockJoltObjectMapper( ObjectMapper objectMapper ) {
  // All Json maps should be deserialized into LinkedHashMaps.
  SimpleModule stockModule = new SimpleModule("stockJoltMapping", new Version(1, 0, 0, null, null, null))
      .addAbstractTypeMapping( Map.class, LinkedHashMap.class );
  objectMapper.registerModule(stockModule);
  // allow the mapper to parse JSON with comments in it
  objectMapper.configure( JsonParser.Feature.ALLOW_COMMENTS, true);
}

代码示例来源:origin: gchq/Gaffer

@Override
  public List<Module> getModules() {
    return Collections.singletonList(
        new SimpleModule(RoaringBitmapConstants.BITMAP_MODULE_NAME, new Version(1, 0, 0, null, null, null))
            .addSerializer(RoaringBitmap.class, new RoaringBitmapJsonSerialiser())
            .addDeserializer(RoaringBitmap.class, new RoaringBitmapJsonDeserialiser())
    );
  }
}

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

public static void configureMapper(ObjectMapper mapper) {
  mapper.configure(JsonParser.Feature.AUTO_CLOSE_SOURCE, false);
  mapper.configure(JsonGenerator.Feature.AUTO_CLOSE_TARGET, false);
  mapper.registerSubtypes(DeckConfig.class);
  
  SimpleModule module = new SimpleModule("", new Version(0, 5, 0, "", "com.cardshifter", "cardshifter"));
  module.setMixInAnnotation(DeckConfig.class, MixinDeckConfig.class);
  module.setMixInAnnotation(Message.class, MixinMessage.class);
  module.setMixInAnnotation(CardInfoMessage.class, MixinCardInfoMessage.class);
  module.setMixInAnnotation(PlayerConfigMessage.class, MixinPlayerConfigMessage.class);
  module.setMixInAnnotation(ErrorMessage.class, MixinErrorMessage.class);
  mapper.registerModule(module);
}

代码示例来源:origin: opentripplanner/OpenTripPlanner

public static SimpleModule getSerializerModule() {
  SimpleModule module = new SimpleModule("VertexJSONSerializer", new Version(1, 0, 0, null, "com.fasterxml.jackson.module", "jackson-module-jaxb-annotations"));
  module.addSerializer(new GeometrySerializer());
  module.addSerializer(new CoordinateSerializer());
  module.addSerializer(new PackedCoordinateSequenceSerializer());
  return module;
}

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

protected AbstractModelConverter(ObjectMapper mapper, TypeNameResolver typeNameResolver) {
  mapper.registerModule(
      new SimpleModule("swagger", Version.unknownVersion()) {
        @Override
        public void setupModule(SetupContext context) {
          context.insertAnnotationIntrospector(new SwaggerAnnotationIntrospector());
        }
      });
  _mapper = mapper;
  _typeNameResolver = typeNameResolver;
  _intr = mapper.getSerializationConfig().getAnnotationIntrospector();
}

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

public static SimpleModule getModule() {
    SimpleModule module = new SimpleModule("ObjectID Serializer", Version.unknownVersion());
    ObjectIdSerializer serializer = new ObjectIdSerializer();
    module.addSerializer(ObjectId.class, serializer);

    return module;
  }
}

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

@Override
  public Version version() {
    return Version.unknownVersion();
  }
}

代码示例来源:origin: org.umlg/sqlg-core

private void updateTopology(String oldVersion) {
  Version v = Version.unknownVersion();
  if (oldVersion != null) {
    v = VersionUtil.parseVersion(oldVersion, null, null);
  }
  if (v.isUnknownVersion() || v.compareTo(new Version(1, 5, 0, null, null, null)) < 0) {
    if (this.sqlDialect.supportsDeferrableForeignKey()) {
      upgradeForeignKeysToDeferrable();
    }
  }
  if (v.isUnknownVersion() || v.compareTo(new Version(2, 0, 0, null, null, null)) < 0) {
    addPartitionSupportToSqlgSchema();
  }
}

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

@Override
public Version version() {
  return new Version(1, 0, 0, "", "org.stagemonitor", "stagemonitor-requestmonitor");
}

代码示例来源:origin: com.eclipsesource.jaxrs/jersey-all

public static Version parseVersion(String s, String groupId, String artifactId)
{
  if (s != null && (s = s.trim()).length() > 0) {
    String[] parts = V_SEP.split(s);
    return new Version(parseVersionPart(parts[0]),
        (parts.length > 1) ? parseVersionPart(parts[1]) : 0,
        (parts.length > 2) ? parseVersionPart(parts[2]) : 0,
        (parts.length > 3) ? parts[3] : null,
        groupId, artifactId);
  }
  return null;
}

代码示例来源:origin: com.eclipsesource.jaxrs/jersey-all

protected VersionUtil()
{
  Version v = null;
  try {
    /* Class we pass only matters for resource-loading: can't use this Class
     * (as it's just being loaded at this point), nor anything that depends on it.
     */
    v = VersionUtil.versionFor(getClass());
  } catch (Exception e) { // not good to dump to stderr; but that's all we have at this low level
    System.err.println("ERROR: Failed to load Version information from "+getClass());
  }
  if (v == null) {
    v = Version.unknownVersion();
  }
  _v = v;
}

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

/**
 * Helper method that will try to load version information for specified
 * class. Implementation is as follows:
 *
 * First, tries to load version info from a class named
 * "PackageVersion" in the same package as the class.
 *
 * If no version information is found, {@link Version#unknownVersion()} is returned.
 */
public static Version versionFor(Class<?> cls)
{
  Version version = packageVersionFor(cls);
  return version == null ? Version.unknownVersion() : version;
}

相关文章