Java Code Examples for com.fasterxml.jackson.core.Version#unknownVersion()

The following examples show how to use com.fasterxml.jackson.core.Version#unknownVersion() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JacksonValueMapperFactory.java    From graphql-spqr with Apache License 2.0 6 votes vote down vote up
private Module getDeserializersModule(GlobalEnvironment environment, ObjectMapper mapper) {
    return new Module() {
        @Override
        public String getModuleName() {
            return "graphql-spqr-deserializers";
        }

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

        @Override
        public void setupModule(SetupContext setupContext) {
            setupContext.addDeserializers(new ConvertingDeserializers(environment, mapper));
        }
    };
}
 
Example 2
Source File: JsonTranscoderTest.java    From simple-spring-memcached with MIT License 6 votes vote down vote up
@Test
public void testEncodeAndDecodeRegisterSerializerDirectlyToModule() {
    JsonObjectMapper mapper = new JsonObjectMapper();

    // first add serializer then register module
    SimpleModule module = new SimpleModule("cemo", Version.unknownVersion());
    module.addSerializer(Point.class, new PointSerializer());
    mapper.registerModule(module);

    transcoder = new JsonTranscoder(mapper);

    Point p = new Point(40, 50);

    CachedObject co = transcoder.encode(p);
    assertNotNull(co);
    assertNotNull(co.getData());
    assertEquals("{\"v\":\"40x50\"}", new String(co.getData()));
}
 
Example 3
Source File: CoreAppConfig.java    From logsniffer with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Bean
public ObjectMapper jsonObjectMapper() {
	final ObjectMapper jsonMapper = new ObjectMapper();
	jsonMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
	jsonMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
	jsonMapper.configure(Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
	jsonMapper.configure(Feature.ALLOW_SINGLE_QUOTES, true);
	jsonMapper.configure(MapperFeature.DEFAULT_VIEW_INCLUSION, false);

	final SimpleModule module = new SimpleModule("FieldsMapping", Version.unknownVersion());
	module.setSerializerModifier(new BeanSerializerModifier() {
		@Override
		public JsonSerializer<?> modifyMapSerializer(final SerializationConfig config, final MapType valueType,
				final BeanDescription beanDesc, final JsonSerializer<?> serializer) {
			if (FieldsMap.class.isAssignableFrom(valueType.getRawClass())) {
				return new FieldsMapMixInLikeSerializer();
			} else {
				return super.modifyMapSerializer(config, valueType, beanDesc, serializer);
			}
		}
	});
	jsonMapper.registerModule(module);
	return jsonMapper;
}
 
Example 4
Source File: SkipperStreamDeployer.java    From spring-cloud-dataflow with Apache License 2.0 6 votes vote down vote up
public static List<AppStatus> deserializeAppStatus(String platformStatus) {
	try {
		if (platformStatus != null) {
			ObjectMapper mapper = new ObjectMapper();
			mapper.addMixIn(AppStatus.class, AppStatusMixin.class);
			mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
			SimpleModule module = new SimpleModule("CustomModel", Version.unknownVersion());
			SimpleAbstractTypeResolver resolver = new SimpleAbstractTypeResolver();
			resolver.addMapping(AppInstanceStatus.class, AppInstanceStatusImpl.class);
			module.setAbstractTypes(resolver);
			mapper.registerModule(module);
			TypeReference<List<AppStatus>> typeRef = new TypeReference<List<AppStatus>>() {
			};
			return mapper.readValue(platformStatus, typeRef);
		}
		return new ArrayList<>();
	}
	catch (Exception e) {
		logger.error("Could not parse Skipper Platform Status JSON [" + platformStatus + "]. " +
				"Exception message = " + e.getMessage());
		return new ArrayList<>();
	}
}
 
Example 5
Source File: ReflectiveRecordSerialiser.java    From octarine with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 6
Source File: SqlgStartupManager.java    From sqlg with MIT License 5 votes vote down vote up
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();
    }
}
 
Example 7
Source File: JasonConfig.java    From springboot-plus with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean(ObjectMapper.class)
public ObjectMapper getObjectMapper() {
	ObjectMapper objectMapper = new ObjectMapper();
	objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
	objectMapper.configure(SerializationFeature.INDENT_OUTPUT, true);
	SimpleModule simpleModule = new SimpleModule("SimpleModule", 
			Version.unknownVersion());
	simpleModule.addSerializer(JsonResult.class, new CustomJsonResultSerializer());
	objectMapper.registerModule(simpleModule);
	return objectMapper;
}
 
Example 8
Source File: AvroObjectModule.java    From stream-registry with Apache License 2.0 5 votes vote down vote up
AvroObjectModule() {
  super(
      AvroObject.class.getSimpleName(),
      Version.unknownVersion(),
      Map.of(AvroObject.class, new AvroObjectDeserializer()),
      List.of(new AvroObjectSerializer())
  );
}
 
Example 9
Source File: JacksonCodecs.java    From immutables with Apache License 2.0 5 votes vote down vote up
/**
 * Create module from existing registry
 */
private static Module module(final CodecRegistry registry) {
  Objects.requireNonNull(registry, "registry");
  return new Module() {
    @Override
    public String getModuleName() {
      return JacksonCodecs.class.getSimpleName();
    }

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

    @Override
    public void setupModule(SetupContext context) {
      context.addSerializers(serializers(registry));
      context.addDeserializers(deserializers(registry));
    }

    @Override
    public Object getTypeId() {
      // return null so multiple modules can be registered
      // with same ObjectMapper instance
      return null;
    }
  };
}
 
Example 10
Source File: VersionUtil.java    From openbd-core with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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();
}
 
Example 11
Source File: ObfuscateAnnotationIntrospector.java    From Singularity with Apache License 2.0 4 votes vote down vote up
@Override
public Version version() {
  return Version.unknownVersion();
}
 
Example 12
Source File: ProtobufModule.java    From jackson-datatype-protobuf with Apache License 2.0 4 votes vote down vote up
@Override
public Version version() {
  return Version.unknownVersion();
}
 
Example 13
Source File: IdAnnotationModule.java    From immutables with Apache License 2.0 4 votes vote down vote up
@Override
public Version version() {
  return Version.unknownVersion();
}
 
Example 14
Source File: JSONAnnotationIntrospector.java    From core-ng-project with Apache License 2.0 4 votes vote down vote up
@Override
public Version version() {
    return Version.unknownVersion();
}
 
Example 15
Source File: AWSServiceSerdeModule.java    From cloudformation-cli-java-plugin with Apache License 2.0 4 votes vote down vote up
@Override
public Version version() {
    return Version.unknownVersion();
}
 
Example 16
Source File: BitlibJsonModule.java    From guarda-android-wallets with GNU General Public License v3.0 4 votes vote down vote up
public BitlibJsonModule() {
   super("BitLibJsonModule", Version.unknownVersion(), DESERIALIZERS, SERIALIZERS);
}
 
Example 17
Source File: Jackson2ObjectMapperFactoryBeanTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
public Version version() {
	return Version.unknownVersion();
}
 
Example 18
Source File: BitlibJsonModule.java    From AndroidWallet with GNU General Public License v3.0 4 votes vote down vote up
public BitlibJsonModule() {
   super("BitLibJsonModule", Version.unknownVersion(), DESERIALIZERS, SERIALIZERS);
}
 
Example 19
Source File: RemoteLoggingJacksonModule.java    From gwt-jackson with Apache License 2.0 4 votes vote down vote up
public RemoteLoggingJacksonModule() {
    super( "RemoteLogging", Version.unknownVersion() );
}
 
Example 20
Source File: Jackson2ObjectMapperBuilderTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
public Version version() {
	return Version.unknownVersion();
}