public Field getField(Class definedIn, String fieldName) { return this.wrapped.getField(definedIn, fieldName); }
boolean fieldExistsInClass = fieldDefinedInClass(result, attrName); if (fieldExistsInClass) { Field field = reflectionProvider.getField(result.getClass(), attrName); SingleValueConverter converter = mapper.getConverterFromAttribute(field.getDeclaringClass(),attrName,field.getType()); Class type = field.getType(); final Object value; if (fieldExistsInClass) { Field field = reflectionProvider.getField(result.getClass(),fieldName); value = unmarshalField(context, result, type, field);
final Class classDefiningField = valueField.getDeclaringClass(); final String fieldName = valueField.getName(); final Field field = fieldName == null ? null : reflectionProvider.getField( classDefiningField, fieldName); if (fieldName == null || field == null) {
/** * Tells this mapper to use an attribute for this field. * * @param definedIn the declaring class of the field * @param fieldName the name of the field * @since 1.3 */ public void addAttributeFor(Class definedIn, String fieldName) { addAttributeFor(reflectionProvider.getField(definedIn, fieldName)); } }
public boolean add(Object object) { if (object == null) { boolean containsNull = !map.containsKey(null); map.put(null, null); return containsNull; } Class itemType = object.getClass(); if (keyFieldName != null) { Field field = (Field)fieldCache.get(itemType); if (field == null) { field = reflectionProvider.getField(itemType, keyFieldName); fieldCache.put(itemType, field); } if (field != null) { Object key = Fields.read(field, object); return map.put(key, object) == null; } } else if (object instanceof Map.Entry) { final Map.Entry entry = (Map.Entry)object; return map.put(entry.getKey(), entry.getValue()) == null; } ConversionException exception = new ConversionException("Element is not defined as entry for implicit map"); exception.add("map-type", map.getClass().getName()); exception.add("element-type", object.getClass().getName()); throw exception; }
private void writeField(String fieldName, String aliasName, Class fieldType, Class definedIn, Object newObj) { try { if (!mapper.shouldSerializeMember(definedIn, aliasName)) { return; } ExtendedHierarchicalStreamWriterHelper.startNode(writer, mapper.serializedMember(definedIn, aliasName), fieldType); Class actualType = newObj.getClass(); Class defaultType = mapper.defaultImplementationOf(fieldType); if (!actualType.equals(defaultType)) { String serializedClassName = mapper.serializedClass(actualType); if (!serializedClassName.equals(mapper.serializedClass(defaultType))) { writer.addAttribute(mapper.aliasForSystemAttribute("class"), serializedClassName); } } if (seenFields.contains(aliasName)) { writer.addAttribute(mapper.aliasForAttribute("defined-in"), mapper.serializedClass(definedIn)); } Field field = reflectionProvider.getField(definedIn,fieldName); marshallField(context, newObj, field); writer.endNode(); } catch (RuntimeException e) { // intercept an exception so that the stack trace shows how we end up marshalling the object in question throw new RuntimeException("Failed to serialize "+definedIn.getName()+"#"+fieldName+" for "+source.getClass(),e); } }
fieldName, reflectionProvider.getField(lookupType, fieldName));
public void writeField(String fieldName, String aliasName, Class fieldType, Class definedIn, Object newObj) { Class actualType = newObj != null ? newObj.getClass() : fieldType; ExtendedHierarchicalStreamWriterHelper.startNode(writer, aliasName != null ? aliasName : mapper.serializedMember(sourceType, fieldName), actualType); if (newObj != null) { Class defaultType = mapper.defaultImplementationOf(fieldType); if (!actualType.equals(defaultType)) { String serializedClassName = mapper.serializedClass(actualType); if (!serializedClassName.equals(mapper.serializedClass(defaultType))) { String attributeName = mapper.aliasForSystemAttribute("class"); if (attributeName != null) { writer.addAttribute(attributeName, serializedClassName); } } } final Field defaultField = (Field)defaultFieldDefinition.get(fieldName); if (defaultField.getDeclaringClass() != definedIn) { String attributeName = mapper.aliasForSystemAttribute("defined-in"); if (attributeName != null) { writer.addAttribute( attributeName, mapper.serializedClass(definedIn)); } } Field field = reflectionProvider.getField(definedIn, fieldName); marshallField(context, newObj, field); } writer.endNode(); }
final Class lookupType = sourceType; defaultFieldDefinition.put( alias, reflectionProvider.getField(lookupType, fieldName)); } else if (!fieldIsEqual(field)) { final ConversionException exception = new ConversionException(
@Override public Field getField(final Class<?> definedIn, final String fieldName) { return wrapped.getField(definedIn, fieldName); }
/** * Tells this mapper to use an attribute for this field. * * @param definedIn the declaring class of the field * @param fieldName the name of the field * @throws IllegalArgumentException if the field does not exist * @since 1.3 */ public void addAttributeFor(Class definedIn, String fieldName) { fieldToUseAsAttribute.add(reflectionProvider.getField(definedIn, fieldName)); } }
/** * Tells this mapper to use an attribute for this field. * * @param definedIn the declaring class of the field * @param fieldName the name of the field * @throws IllegalArgumentException if the field does not exist * @since 1.3 */ public void addAttributeFor(Class definedIn, String fieldName) { fieldToUseAsAttribute.add(reflectionProvider.getField(definedIn, fieldName)); } }
public boolean shouldLookForSingleValueConverter(String fieldName, Class type, Class definedIn) { if (typeSet.contains(type)) { return true; } else if (fieldNameToTypeMap.get(fieldName) == type) { return true; } else if (fieldName != null && definedIn != null) { Field field = reflectionProvider.getField(definedIn, fieldName); return fieldToUseAsAttribute.contains(field); } return false; }
public boolean shouldLookForSingleValueConverter(String fieldName, Class type, Class definedIn) { Field field = reflectionProvider.getField(definedIn, fieldName); return fieldToUseAsAttribute.contains(field) || fieldNameToTypeMap.get(fieldName) == type || typeSet.contains(type); }
/** * Tells this mapper to use an attribute for this field. * * @param definedIn the declaring class of the field * @param fieldName the name of the field * @since 1.3 */ public void addAttributeFor(final Class<?> definedIn, final String fieldName) { addAttributeFor(reflectionProvider.getField(definedIn, fieldName)); } }
/** * Tells this mapper to use an attribute for this field. * * @param definedIn the declaring class of the field * @param fieldName the name of the field * @since 1.3 */ public void addAttributeFor(Class definedIn, String fieldName) { addAttributeFor(reflectionProvider.getField(definedIn, fieldName)); } }
/** * Tells this mapper to use an attribute for this field. * * @param definedIn the declaring class of the field * @param fieldName the name of the field * @since 1.3 */ public void addAttributeFor(Class definedIn, String fieldName) { addAttributeFor(reflectionProvider.getField(definedIn, fieldName)); } }
/** * Tells this mapper to use an attribute for this field. * * @param definedIn the declaring class of the field * @param fieldName the name of the field * @since 1.3 */ public void addAttributeFor(Class definedIn, String fieldName) { addAttributeFor(reflectionProvider.getField(definedIn, fieldName)); } }
/** * @deprecated As of 1.3.1, use {@link #getConverterFromAttribute(Class, String, Class)} */ public SingleValueConverter getConverterFromAttribute(Class definedIn, String attribute) { Field field = reflectionProvider.getField(definedIn, attribute); return getConverterFromAttribute(definedIn, attribute, field.getType()); }
/** * @deprecated As of 1.3.1, use {@link #getConverterFromAttribute(Class, String, Class)} */ public SingleValueConverter getConverterFromAttribute(Class definedIn, String attribute) { Field field = reflectionProvider.getField(definedIn, attribute); return getConverterFromAttribute(definedIn, attribute, field.getType()); }