/** * Convenience method, equivalent to: *<pre> * getDeserializationConfig().isEnabled(f); *</pre> * * @since 1.9 */ public boolean isEnabled(DeserializationConfig.Feature f) { return _deserializationConfig.isEnabled(f); }
@Override public boolean isAnnotationProcessingEnabled() { return isEnabled(Feature.USE_ANNOTATIONS); }
@Override public boolean canOverrideAccessModifiers() { return isEnabled(Feature.CAN_OVERRIDE_ACCESS_MODIFIERS); }
public StdValueInstantiator(DeserializationConfig config, Class<?> valueType) { _cfgEmptyStringsAsObjects = (config == null) ? false : config.isEnabled(DeserializationConfig.Feature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT); _valueTypeDesc = (valueType == null) ? "UNKNOWN TYPE" : valueType.getName(); }
/** * Helper method for getting access to filter that only guarantees * that methods used for deserialization are to be included. * * @deprecated Since 1.9 just don't use */ @Deprecated protected MethodFilter getDeserializationMethodFilter(DeserializationConfig cfg) { /* [JACKSON-88]: may also need to include getters (at least for * Collection and Map types) */ if (cfg.isEnabled(DeserializationConfig.Feature.USE_GETTERS_AS_SETTERS)) { return DEFAULT_SETTER_AND_GETTER_FILTER; } return DEFAULT_SETTER_FILTER; }
public StdValueInstantiator(DeserializationConfig config, JavaType valueType) { _cfgEmptyStringsAsObjects = (config == null) ? false : config.isEnabled(DeserializationConfig.Feature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT); _valueTypeDesc = (valueType == null) ? "UNKNOWN TYPE" : valueType.toString(); }
/** * Method for getting {@link AnnotationIntrospector} configured * to introspect annotation values used for configuration. */ @Override public AnnotationIntrospector getAnnotationIntrospector() { /* 29-Jul-2009, tatu: it's now possible to disable use of * annotations; can be done using "no-op" introspector */ if (isEnabled(Feature.USE_ANNOTATIONS)) { return super.getAnnotationIntrospector(); } return NopAnnotationIntrospector.instance; }
protected ObjectReader(ObjectMapper mapper, DeserializationConfig config, JavaType valueType, Object valueToUpdate, FormatSchema schema, InjectableValues injectableValues) { _config = config; _rootDeserializers = mapper._rootDeserializers; _provider = mapper._deserializerProvider; _jsonFactory = mapper._jsonFactory; _valueType = valueType; _valueToUpdate = valueToUpdate; if (valueToUpdate != null && valueType.isArrayType()) { throw new IllegalArgumentException("Can not update an array value"); } _schema = schema; _injectableValues = injectableValues; _unwrapRoot = config.isEnabled(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE); }
/** * Copy constructor used for building variations. */ protected ObjectReader(ObjectReader base, DeserializationConfig config, JavaType valueType, Object valueToUpdate, FormatSchema schema, InjectableValues injectableValues) { _config = config; _rootDeserializers = base._rootDeserializers; _provider = base._provider; _jsonFactory = base._jsonFactory; _valueType = valueType; _valueToUpdate = valueToUpdate; if (valueToUpdate != null && valueType.isArrayType()) { throw new IllegalArgumentException("Can not update an array value"); } _schema = schema; _injectableValues = injectableValues; _unwrapRoot = config.isEnabled(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE); }
@Override public VisibilityChecker<?> getDefaultVisibilityChecker() { VisibilityChecker<?> vchecker = super.getDefaultVisibilityChecker(); if (!isEnabled(DeserializationConfig.Feature.AUTO_DETECT_SETTERS)) { vchecker = vchecker.withSetterVisibility(Visibility.NONE); } if (!isEnabled(DeserializationConfig.Feature.AUTO_DETECT_CREATORS)) { vchecker = vchecker.withCreatorVisibility(Visibility.NONE); } if (!isEnabled(DeserializationConfig.Feature.AUTO_DETECT_FIELDS)) { vchecker = vchecker.withFieldVisibility(Visibility.NONE); } return vchecker; }
protected EnumResolver<?> constructEnumResolver(Class<?> enumClass, DeserializationConfig config) { // [JACKSON-212]: may need to use Enum.toString() if (config.isEnabled(DeserializationConfig.Feature.READ_ENUMS_USING_TO_STRING)) { return EnumResolver.constructUnsafeUsingToString(enumClass); } return EnumResolver.constructUnsafe(enumClass, config.getAnnotationIntrospector()); } }
/** * Factory method used when Enum instances are to be deserialized * using a creator (static factory method) * * @return Deserializer based on given factory method, if type was suitable; * null if type can not be used */ public static JsonDeserializer<?> deserializerForCreator(DeserializationConfig config, Class<?> enumClass, AnnotatedMethod factory) { // note: caller has verified there's just one arg; but we must verify its type Class<?> raw = factory.getParameterClass(0); if (raw == String.class) { raw = null; } else if (raw == Integer.TYPE || raw == Integer.class) { raw = Integer.class; } else if (raw == Long.TYPE || raw == Long.class) { raw = Long.class; } else { throw new IllegalArgumentException("Parameter #0 type for factory method ("+factory +") not suitable, must be java.lang.String or int/Integer/long/Long"); } if (config.isEnabled(DeserializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS)) { ClassUtil.checkAndFixAccess(factory.getMember()); } return new FactoryBasedDeserializer(enumClass, factory, raw); }
/** * Method called locate all members used for value injection (if any), * constructor {@link org.codehaus.jackson.map.deser.impl.ValueInjector} instances, and add them to builder. * * @since 1.9 */ protected void addInjectables(DeserializationConfig config, BasicBeanDescription beanDesc, BeanDeserializerBuilder builder) throws JsonMappingException { Map<Object, AnnotatedMember> raw = beanDesc.findInjectables(); if (raw != null) { boolean fixAccess = config.isEnabled(DeserializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS); for (Map.Entry<Object, AnnotatedMember> entry : raw.entrySet()) { AnnotatedMember m = entry.getValue(); if (fixAccess) { m.fixAccess(); // to ensure we can call it } builder.addInjectable(m.getName(), beanDesc.resolveType(m.getGenericType()), beanDesc.getClassAnnotations(), m, entry.getKey()); } } }
public static KeyDeserializer findStringBasedKeyDeserializer(DeserializationConfig config, JavaType type) { /* We don't need full deserialization information, just need to * know creators. */ BasicBeanDescription beanDesc = config.introspect(type); // Ok, so: can we find T(String) constructor? Constructor<?> ctor = beanDesc.findSingleArgConstructor(String.class); if (ctor != null) { if (config.isEnabled(DeserializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS)) { ClassUtil.checkAndFixAccess(ctor); } return new StdKeyDeserializer.StringCtorKeyDeserializer(ctor); } /* or if not, "static T valueOf(String)" (or equivalent marked * with @JsonCreator annotation?) */ Method m = beanDesc.findFactoryMethod(String.class); if (m != null){ if (config.isEnabled(DeserializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS)) { ClassUtil.checkAndFixAccess(m); } return new StdKeyDeserializer.StringFactoryKeyDeserializer(m); } // nope, no such luck... return null; } }
JsonDeserializer<Object> deser = _findRootDeserializer(cfg, valueType); if (cfg.isEnabled(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)) { result = _unwrapAndDeserialize(jp, valueType, ctxt, deser); } else {
DeserializationContext ctxt = _createDeserializationContext(jp, cfg); JsonDeserializer<Object> deser = _findRootDeserializer(cfg, valueType); if (cfg.isEnabled(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE)) { result = _unwrapAndDeserialize(jp, valueType, ctxt, deser); } else {
if (config.isEnabled(DeserializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS)) { getter.fixAccess();
throws JsonMappingException if (config.isEnabled(DeserializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS)) {
throws JsonMappingException boolean fixAccess = config.isEnabled(DeserializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS); CreatorCollector creators = new CreatorCollector(beanDesc, fixAccess); AnnotationIntrospector intr = config.getAnnotationIntrospector();
if (config.isEnabled(DeserializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS)) { field.fixAccess();