@SuppressWarnings("unchecked") private void add(Class<?> cls, JsonDeserializer<?> deser) { /* Not super clean to use default TypeFactory in general, but * since primitive array types can't be modified for anything * useful, this should be ok: */ _allDeserializers.put(TypeFactory.defaultInstance().constructType(cls), (JsonDeserializer<Object>) deser); }
/** * @deprecated Since 1.8; instead use variant that takes JavaType: this ensures * that type information is properly resolved */ @Deprecated public JSONPObject(String function, Object value, Class<?> rawType) { _function = function; _value = value; _serializationType = (rawType == null) ? null : TypeFactory.defaultInstance().constructType(rawType); }
/** * Method for constructing a marker type that indicates missing generic * type information, which is handled same as simple type for * <code>java.lang.Object</code>. * * @since 1.8 */ public static JavaType unknownType() { return defaultInstance()._unknownType(); }
/** * @deprecated Since 1.8; should construct with resolved <code>JavaType</code>, * to ensure type has been properly resolved */ @Deprecated public JSONWrappedObject(String prefix, String suffix, Object value, Class<?> rawType) { _prefix = prefix; _suffix = suffix; _value = value; _serializationType = (rawType == null) ? null : TypeFactory.defaultInstance().constructType(rawType); }
private void add(StdKeyDeserializer kdeser) { Class<?> keyClass = kdeser.getKeyClass(); /* As with other cases involving primitive types, we can use * default TypeFactory ok, even if it's not our first choice: */ _keyDeserializers.put(TypeFactory.defaultInstance().uncheckedSimpleType(keyClass), kdeser); }
public static Class<?> rawClass(Type t) { if (t instanceof Class<?>) { return (Class<?>) t; } // Can optimize bit more in future... return defaultInstance().constructType(t).getRawClass(); }
@Override public Class<?> getRawType() { if (_type instanceof Class<?>) { return (Class<?>) _type; } // 14-Mar-2011, tatu: Not optimal, but has to do for now... JavaType t = TypeFactory.defaultInstance().constructType(_type); return t.getRawClass(); }
/** * Handling of narrowing conversions for arrays is trickier: for now, * it is not even allowed. */ @Override protected JavaType _narrow(Class<?> subclass) { /* Ok: need a bit of indirection here. First, must replace component * type (and check that it is compatible), then re-construct. */ if (!subclass.isArray()) { // sanity check, should never occur throw new IllegalArgumentException("Incompatible narrowing operation: trying to narrow "+toString()+" to class "+subclass.getName()); } /* Hmmh. This is an awkward back reference... but seems like the * only simple way to do it. */ Class<?> newCompClass = subclass.getComponentType(); /* 14-Mar-2011, tatu: it gets even worse, as we do not have access to * currently configured TypeFactory. This could theoretically cause * problems (when narrowing from array of Objects, to array of non-standard * Maps, for example); but for now need to defer solving this until * it actually becomes a real problem, not just potential one. * (famous last words?) */ JavaType newCompType = TypeFactory.defaultInstance().constructType(newCompClass); return construct(newCompType, _valueHandler, _typeHandler); }
protected final static JavaType TYPE_OBJECT = TypeFactory.defaultInstance().uncheckedSimpleType(Object.class);
Class<?> enumClass = ClassUtil.findEnumType((EnumSet<?>) value); str = TypeFactory.defaultInstance().constructCollectionType(EnumSet.class, enumClass).toCanonical(); } else if (value instanceof EnumMap<?,?>) { Class<?> enumClass = ClassUtil.findEnumType((EnumMap<?,?>) value); Class<?> valueClass = Object.class; str = TypeFactory.defaultInstance().constructMapType(EnumMap.class, enumClass, valueClass).toCanonical(); } else { String end = str.substring(9);
_typeFactory = TypeFactory.defaultInstance(); _serializationConfig = (sconfig != null) ? sconfig : new SerializationConfig(DEFAULT_INTROSPECTOR, DEFAULT_ANNOTATION_INTROSPECTOR, STD_VISIBILITY_CHECKER,
public HttpMetricsIngestionHandler(HttpMetricsIngestionServer.Processor processor, TimeValue timeout, boolean enablePerTenantMetrics) { this.mapper = new ObjectMapper(); this.typeFactory = TypeFactory.defaultInstance(); this.timeout = timeout; this.processor = processor; this.enablePerTenantMetrics = enablePerTenantMetrics; }
/** * Method for constructing a marker type that indicates missing generic * type information, which is handled same as simple type for * <code>java.lang.Object</code>. * * @since 1.8 */ public static JavaType unknownType() { return defaultInstance()._unknownType(); }
@SuppressWarnings("unchecked") private void add(Class<?> cls, JsonDeserializer<?> deser) { /* Not super clean to use default TypeFactory in general, but * since primitive array types can't be modified for anything * useful, this should be ok: */ _allDeserializers.put(TypeFactory.defaultInstance().constructType(cls), (JsonDeserializer<Object>) deser); }
/** * @deprecated Since 1.8; should construct with resolved <code>JavaType</code>, * to ensure type has been properly resolved */ @Deprecated public JSONWrappedObject(String prefix, String suffix, Object value, Class<?> rawType) { _prefix = prefix; _suffix = suffix; _value = value; _serializationType = (rawType == null) ? null : TypeFactory.defaultInstance().constructType(rawType); }
/** * @deprecated Since 1.8; instead use variant that takes JavaType: this ensures * that type information is properly resolved */ @Deprecated public JSONPObject(String function, Object value, Class<?> rawType) { _function = function; _value = value; _serializationType = (rawType == null) ? null : TypeFactory.defaultInstance().constructType(rawType); }
private void add(StdKeyDeserializer kdeser) { Class<?> keyClass = kdeser.getKeyClass(); /* As with other cases involving primitive types, we can use * default TypeFactory ok, even if it's not our first choice: */ _keyDeserializers.put(TypeFactory.defaultInstance().uncheckedSimpleType(keyClass), kdeser); }
public static Class<?> rawClass(Type t) { if (t instanceof Class<?>) { return (Class<?>) t; } // Can optimize bit more in future... return defaultInstance().constructType(t).getRawClass(); }
@Override public Class<?> getRawType() { if (_type instanceof Class<?>) { return (Class<?>) _type; } // 14-Mar-2011, tatu: Not optimal, but has to do for now... JavaType t = TypeFactory.defaultInstance().constructType(_type); return t.getRawClass(); }
/** * Handling of narrowing conversions for arrays is trickier: for now, * it is not even allowed. */ @Override protected JavaType _narrow(Class<?> subclass) { /* Ok: need a bit of indirection here. First, must replace component * type (and check that it is compatible), then re-construct. */ if (!subclass.isArray()) { // sanity check, should never occur throw new IllegalArgumentException("Incompatible narrowing operation: trying to narrow "+toString()+" to class "+subclass.getName()); } /* Hmmh. This is an awkward back reference... but seems like the * only simple way to do it. */ Class<?> newCompClass = subclass.getComponentType(); /* 14-Mar-2011, tatu: it gets even worse, as we do not have access to * currently configured TypeFactory. This could theoretically cause * problems (when narrowing from array of Objects, to array of non-standard * Maps, for example); but for now need to defer solving this until * it actually becomes a real problem, not just potential one. * (famous last words?) */ JavaType newCompType = TypeFactory.defaultInstance().constructType(newCompClass); return construct(newCompType, _valueHandler, _typeHandler); }