@JsonSetter("valueSerialiser") public void setValueSerialiserClassString(final String classType) throws ClassNotFoundException, IllegalAccessException, InstantiationException { this.valueSerialiser = null != classType ? Class.forName(SimpleClassNameIdResolver.getClassName(classType)).asSubclass(ToBytesSerialiser.class).newInstance() : null; }
@JsonGetter("transientProperties") public Map<String, String> getTransientPropertyMapWithClassNames() { if (transientProperties.isEmpty()) { return null; } Map<String, String> propertyMap = new HashMap<>(); for (final Entry<String, Class<?>> entry : transientProperties.entrySet()) { propertyMap.put(entry.getKey(), SimpleClassNameIdResolver.getSimpleClassName(entry.getValue())); } return propertyMap; }
public static ObjectMapper createDefaultMapper() { final ObjectMapper mapper = new ObjectMapper(); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); mapper.configure(SerializationFeature.CLOSE_CLOSEABLE, true); mapper.disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE); mapper.registerModule(CloseableIterableDeserializer.getModule()); // Allow unknown properties. This will help to avoid conflicts between Gaffer versions. mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, STRICT_JSON_DEFAULT); // Using the deprecated version for compatibility with older versions of jackson mapper.registerModule(new JSR310Module()); // Use the 'setFilters' method so it is compatible with older versions of jackson mapper.setFilters(getFilterProvider()); // Allow simple class names or full class names to be used in JSON. // We must set this to true to ensure serialisation into json uses the // full class name. Otherwise, json deserialisation may fail on worker nodes in Accumulo/HBase. SimpleClassNameCache.setUseFullNameForSerialisation(true); SimpleClassNameIdResolver.configureObjectMapper(mapper); return mapper; }
@Override public String idFromValue(final Object value) { String id = getSimpleClassNameOrNull(value.getClass()); if (null == id) { id = defaultResolver.idFromValue(value); } return id; }
@Override public void init(final JavaType baseType) { this.baseType = baseType; if (null == baseType.getContentType()) { this.baseType = baseType; } else { this.baseType = baseType.getContentType(); } final ClassNameIdResolver newDefaultResolver = new ClassNameIdResolver(this.baseType, null); newDefaultResolver.init(this.baseType); init(newDefaultResolver); }
@Override public String idFromValueAndType(final Object value, final Class<?> suggestedType) { String id = getSimpleClassNameOrNull(value.getClass()); if (null == id) { id = defaultResolver.idFromValueAndType(value, suggestedType); } return id; }
@JsonSetter("keySerialiser") public void setKeySerialiserClassString(final String classType) throws ClassNotFoundException, IllegalAccessException, InstantiationException { this.keySerialiser = null != classType ? Class.forName(SimpleClassNameIdResolver.getClassName(classType)).asSubclass(ToBytesSerialiser.class).newInstance() : null; }
@JsonGetter("mapClass") public String getMapClassString() { return null != mapClass ? SimpleClassNameIdResolver.getSimpleClassName(mapClass) : null; }
@Override public String idFromBaseType() { String id = getSimpleClassNameOrNull(baseType.getRawClass()); if (null == id) { id = defaultResolver.idFromBaseType(); } return id; }
public static ObjectMapper createDefaultMapper() { final ObjectMapper mapper = new ObjectMapper(); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); mapper.configure(SerializationFeature.CLOSE_CLOSEABLE, true); mapper.disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE); mapper.registerModule(CloseableIterableDeserializer.getModule()); // Allow unknown properties. This will help to avoid conflicts between Gaffer versions. mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, STRICT_JSON_DEFAULT); // Using the deprecated version for compatibility with older versions of jackson mapper.registerModule(new JSR310Module()); // Use the 'setFilters' method so it is compatible with older versions of jackson mapper.setFilters(getFilterProvider()); // Allow simple class names or full class names to be used in JSON. // We must set this to true to ensure serialisation into json uses the // full class name. Otherwise, json deserialisation may fail on worker nodes in Accumulo/HBase. SimpleClassNameCache.setUseFullNameForSerialisation(true); SimpleClassNameIdResolver.configureObjectMapper(mapper); return mapper; }
@JsonSetter("mapClass") public void setMapClassString(final String classType) throws ClassNotFoundException { this.mapClass = null != classType ? Class.forName(SimpleClassNameIdResolver.getClassName(classType)).asSubclass(Map.class) : null; }
@JsonGetter("valueSerialiser") public String getValueSerialiserClassString() { return null != valueSerialiser ? SimpleClassNameIdResolver.getSimpleClassName(valueSerialiser.getClass()) : null; }
@JsonSetter("setClass") public void setSetClassString(final String classType) throws ClassNotFoundException { this.setClass = null != classType ? Class.forName(SimpleClassNameIdResolver.getClassName(classType)).asSubclass(Set.class) : null; }
@JsonGetter("setClass") public String getSetClassString() { return null != setClass ? SimpleClassNameIdResolver.getSimpleClassName(setClass) : null; }
@JsonSetter("objectSerialiser") public void setObjectSerialiserClassString(final String classType) throws ClassNotFoundException, IllegalAccessException, InstantiationException { this.objectSerialiser = null != classType ? Class.forName(SimpleClassNameIdResolver.getClassName(classType)).asSubclass(ToBytesSerialiser.class).newInstance() : null; }
@JsonGetter("objectSerialiser") public String getObjectSerialiserClassString() { return null != objectSerialiser ? SimpleClassNameIdResolver.getSimpleClassName(objectSerialiser.getClass()) : null; }
typeName = SimpleClassNameIdResolver.getClassName(typeName);
@JsonGetter("keySerialiser") public String getKeySerialiserClassString() { return null != keySerialiser ? SimpleClassNameIdResolver.getSimpleClassName(keySerialiser.getClass()) : null; }
clazz = Class.forName(SimpleClassNameIdResolver.getClassName(className)); } catch (final Exception e) { throw new IllegalArgumentException("Class name was not recognised: " + className, e);
@JsonGetter("class") default String getClassName() { return SimpleClassNameIdResolver.getSimpleClassName(getClass()); }