org.testifyproject.fasterxml.jackson.databind.introspect.ConcreteBeanPropertyBase Maven / Gradle / Ivy
The newest version!
package org.testifyproject.testifyproject.fasterxml.jackson.databind.introspect;
import org.testifyproject.testifyproject.fasterxml.jackson.annotation.JsonFormat;
import org.testifyproject.testifyproject.fasterxml.jackson.annotation.JsonInclude;
import org.testifyproject.testifyproject.fasterxml.jackson.databind.AnnotationIntrospector;
import org.testifyproject.testifyproject.fasterxml.jackson.databind.BeanProperty;
import org.testifyproject.testifyproject.fasterxml.jackson.databind.PropertyMetadata;
import org.testifyproject.testifyproject.fasterxml.jackson.databind.cfg.MapperConfig;
/**
* Intermediate {@link BeanProperty} class shared by concrete readable- and
* writable property implementations for sharing org.testifyproject.testifyprojectmon functionality.
*
* @since 2.7
*/
public abstract class ConcreteBeanPropertyBase
implements BeanProperty, java.io.Serializable
{
private static final long serialVersionUID = 1;
/**
* Additional information about property
*
* @since 2.3
*/
protected final PropertyMetadata _metadata;
/**
* Lazily accessed value for per-property format override definition.
*
* @since 2.8
*/
protected transient JsonFormat.Value _propertyFormat;
protected ConcreteBeanPropertyBase(PropertyMetadata md) {
_metadata = (md == null) ? PropertyMetadata.STD_REQUIRED_OR_OPTIONAL : md;
}
protected ConcreteBeanPropertyBase(ConcreteBeanPropertyBase src) {
_metadata = src._metadata;
_propertyFormat = src._propertyFormat;
}
@Override
public boolean isRequired() { return _metadata.isRequired(); }
@Override
public PropertyMetadata getMetadata() { return _metadata; }
@Override
public boolean isVirtual() { return false; }
@Override
@Deprecated
public final JsonFormat.Value findFormatOverrides(AnnotationIntrospector intr) {
JsonFormat.Value f = null;
if (intr != null) {
AnnotatedMember member = getMember();
if (member != null) {
f = intr.findFormat(member);
}
}
if (f == null) {
f = EMPTY_FORMAT;
}
return f;
}
@Override
public JsonFormat.Value findPropertyFormat(MapperConfig> config, Class> baseType)
{
// 15-Apr-2016, tatu: Let's calculate lazily, retain; assumption being however that
// baseType is always the same
JsonFormat.Value v = _propertyFormat;
if (v == null) {
JsonFormat.Value v1 = config.getDefaultPropertyFormat(baseType);
JsonFormat.Value v2 = null;
AnnotationIntrospector intr = config.getAnnotationIntrospector();
if (intr != null) {
AnnotatedMember member = getMember();
if (member != null) {
v2 = intr.findFormat(member);
}
}
if (v1 == null) {
v = (v2 == null) ? EMPTY_FORMAT : v2;
} else {
v = (v2 == null) ? v1 : v1.withOverrides(v2);
}
_propertyFormat = v;
}
return v;
}
@Override
public JsonInclude.Value findPropertyInclusion(MapperConfig> config, Class> baseType)
{
JsonInclude.Value v0 = config.getDefaultPropertyInclusion(baseType);
AnnotationIntrospector intr = config.getAnnotationIntrospector();
AnnotatedMember member = getMember();
if ((intr == null) || (member == null)) {
return v0;
}
JsonInclude.Value v = intr.findPropertyInclusion(member);
if (v == null) {
return v0;
}
return v0.withOverrides(v);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy