Refine search
JsonProperty pann = am.getAnnotation(JsonProperty.class); if (pann != null) { return pann.value(); JsonSetter ann = am.getAnnotation(JsonSetter.class); if (ann != null) { return ann.value(); if (am.hasAnnotation(JsonDeserialize.class) || am.hasAnnotation(JsonView.class) || am.hasAnnotation(JsonBackReference.class) || am.hasAnnotation(JsonManagedReference.class) ) { return "";
public FactoryBasedDeserializer(Class<?> cls, AnnotatedMethod f, Class<?> inputType) { super(Enum.class); _enumClass = cls; _factory = f.getAnnotated(); _inputType = inputType; }
public String getFullName() { return getDeclaringClass().getName() + "#" + getName() + "(" +getParameterCount()+" params)"; }
/** * Method used to locate the method of introspected class that * implements {@link org.codehaus.jackson.annotate.JsonAnySetter}. If no such method exists * null is returned. If more than one are found, an exception * is thrown. * Additional checks are also made to see that method signature * is acceptable: needs to take 2 arguments, first one String or * Object; second any can be any type. */ @Override public AnnotatedMethod findAnySetter() throws IllegalArgumentException { if (_anySetterMethod != null) { /* Also, let's be somewhat strict on how field name is to be * passed; String, Object make sense, others not * so much. */ /* !!! 18-May-2009, tatu: how about enums? Can add support if * requested; easy enough for devs to add support within * method. */ Class<?> type = _anySetterMethod.getParameterClass(0); if (type != String.class && type != Object.class) { throw new IllegalArgumentException("Invalid 'any-setter' annotation on method "+_anySetterMethod.getName()+"(): first argument not of type String or Object, but "+type.getName()); } } return _anySetterMethod; }
if (config.isEnabled(DeserializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS)) { getter.fixAccess(); JavaType type = getter.getType(beanDesc.bindingsForBeanType()); TypeDeserializer typeDeser = type.getTypeHandler(); SettableBeanProperty prop = new SettableBeanProperty.SetterlessProperty(name, type, typeDeser, beanDesc.getClassAnnotations(), getter);
if (config.isEnabled(DeserializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS)) { setter.fixAccess(); JavaType t0 = beanDesc.bindingsForBeanType().resolveType(setter.getParameterType(0)); BeanProperty.Std property = new BeanProperty.Std(name, t0, beanDesc.getClassAnnotations(), setter); JavaType type = resolveType(config, beanDesc, t0, setter, property); TypeDeserializer typeDeser = type.getTypeHandler(); SettableBeanProperty prop = new SettableBeanProperty.MethodProperty(name, type, typeDeser, beanDesc.getClassAnnotations(), setter); AnnotationIntrospector.ReferenceProperty ref = config.getAnnotationIntrospector().findReferenceType(setter); if (ref != null && ref.isManagedReference()) { prop.setManagedReferenceName(ref.getName());
throws JsonMappingException if (config.isEnabled(DeserializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS)) { setter.fixAccess(); // to ensure we can call it JavaType type = beanDesc.bindingsForBeanType().resolveType(setter.getParameterType(1)); BeanProperty.Std property = new BeanProperty.Std(setter.getName(), type, beanDesc.getClassAnnotations(), setter); type = resolveType(config, beanDesc, type, setter, property);
f = ((AnnotatedField) am).getAnnotated(); } else { m = ((AnnotatedMethod) am).getAnnotated(); f = null; JavaType ct = serializationType.getContentType(); +name+"' (of type "+_beanDesc.getType()+"); serialization type "+serializationType+" has no content"); serializationType = serializationType.withContentTypeHandler(contentTypeSer); ct = serializationType.getContentType();
Class<?> getterClass = getter.getDeclaringClass(); Class<?> nextClass = nextGetter.getDeclaringClass(); if (getterClass != nextClass) { if (getterClass.isAssignableFrom(nextClass)) { // next is more specific +getter.getFullName()+" vs "+nextGetter.getFullName());
throws JsonMappingException Class<?> raw = type.getRawClass(); if (valueMethod != null) { Method m = valueMethod.getAnnotated(); if (config.isEnabled(SerializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS)) { ClassUtil.checkAndFixAccess(m);
AnnotationIntrospector intr = config.getAnnotationIntrospector(); boolean ignoreAny = false; AnnotatedMethod setter = property.getSetter(); Class<?> type = setter.getParameterClass(0); if (isIgnorableType(config, beanDesc, type, ignoredTypes)) { if (config.isEnabled(DeserializationConfig.Feature.USE_GETTERS_AS_SETTERS)) { Class<?> rt = getter.getRawType(); if (Collection.class.isAssignableFrom(rt) || Map.class.isAssignableFrom(rt)) { if (!ignored.contains(name) && !builder.hasProperty(name)) {
/** * 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); }
/** * @param addParamAnnotations Whether parameter annotations are to be * added as well */ protected void _addMixOvers(Method mixin, AnnotatedMethod target, boolean addParamAnnotations) { for (Annotation a : mixin.getDeclaredAnnotations()) { if (_annotationIntrospector.isHandled(a)) { target.addOrOverride(a); } } if (addParamAnnotations) { Annotation[][] pa = mixin.getParameterAnnotations(); for (int i = 0, len = pa.length; i < len; ++i) { for (Annotation a : pa[i]) { target.addOrOverrideParam(i, a); } } } }
_addMixOvers(old.getAnnotated(), newM, false); if (old.getDeclaringClass().isInterface() && !m.getDeclaringClass().isInterface()) { methods.add(old.withMethod(m));
if (anyGetter != null) { // since 1.6 if (config.isEnabled(SerializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS)) { anyGetter.fixAccess(); JavaType type = anyGetter.getType(beanDesc.bindingsForBeanType()); JavaType valueType = type.getContentType(); TypeSerializer typeSer = createTypeSerializer(config, valueType, property);
@Override public <A extends Annotation> A getAnnotation(Class<A> acls) { return _annotated.getAnnotation(acls); }
/** * Method that constructs a new instance with settings (annotations, parameter annotations) * of this instance, but with different physical {@link Method}. * * @since 1.7 */ public AnnotatedMethod withMethod(Method m) { return new AnnotatedMethod(m, _annotations, _paramAnnotations); }
/** * Method that can be called to find if introspected class declares * a static "valueOf" factory method that returns an instance of * introspected type, given one of acceptable types. * * @param expArgTypes Types that the matching single argument factory * method can take: will also accept super types of these types * (ie. arg just has to be assignable from expArgType) */ public Method findFactoryMethod(Class<?>... expArgTypes) { // So, of all single-arg static methods: for (AnnotatedMethod am : _classInfo.getStaticMethods()) { if (isFactoryMethod(am)) { // And must take one of expected arg types (or supertype) Class<?> actualArgType = am.getParameterClass(0); for (Class<?> expArgType : expArgTypes) { // And one that matches what we would pass in if (actualArgType.isAssignableFrom(expArgType)) { return am.getAnnotated(); } } } } return null; }
@Override public Object findInjectableValueId(AnnotatedMember m) { JacksonInject ann = m.getAnnotation(JacksonInject.class); if (ann == null) { return null; } /* Empty String means that we should use name of declared * value class. */ String id = ann.value(); if (id.length() == 0) { // slight complication; for setters, type if (!(m instanceof AnnotatedMethod)) { return m.getRawType().getName(); } AnnotatedMethod am = (AnnotatedMethod) m; if (am.getParameterCount() == 0) { return m.getRawType().getName(); } return am.getParameterClass(0).getName(); } return id; }
/** * Method that will add annotations from specified source method to target method, * but only if target does not yet have them. */ protected void _addMixUnders(Method src, AnnotatedMethod target) { for (Annotation a : src.getDeclaredAnnotations()) { if (_annotationIntrospector.isHandled(a)) { target.addIfNotPresent(a); } } }