Refine search
/** * 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); } }
@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); } };
public String toFullString() { return _groupId + '/' + _artifactId + '/' + toString(); }
/** * 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(); }
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 {
@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); } }
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); }
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; }
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); }
@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()) ); } }
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); }
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; }
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(); }
public static SimpleModule getModule() { SimpleModule module = new SimpleModule("ObjectID Serializer", Version.unknownVersion()); ObjectIdSerializer serializer = new ObjectIdSerializer(); module.addSerializer(ObjectId.class, serializer); return module; } }
@Override public Version version() { return Version.unknownVersion(); } }
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(); } }
@Override public Version version() { return new Version(1, 0, 0, "", "org.stagemonitor", "stagemonitor-requestmonitor"); }
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; }
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; }
/** * 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; }