Skip to content

Commit

Permalink
Add annotation-access support for #527
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Oct 17, 2014
1 parent 5dba16a commit 76731bc
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,12 @@ public Object findNullSerializer(Annotated am) {
* field) defines which Bean/Map properties are to be included in
* serialization.
* If no annotation is found, method should return given second
* argument; otherwise value indicated by the annotation
* argument; otherwise value indicated by the annotation.
*<p>
* Note that meaning of inclusion value depends on whether it is for
* a Class or property (field/method/constructor): in former case,
* it is the default for all properties; in latter case it is specific
* override for annotated property.
*
* @return Enumerated value indicating which properties to include
* in serialization
Expand All @@ -578,6 +583,16 @@ public JsonInclude.Include findSerializationInclusion(Annotated a, JsonInclude.I
return defValue;
}

/**
* Method for checking whether content (entries) of a {@link java.util.Map} property
* are to be included during serialization or not.
*
* @since 2.5
*/
public JsonInclude.Include findSerializationInclusionForContent(Annotated a, JsonInclude.Include defValue) {
return defValue;
}

/**
* Method for accessing annotated type definition that a
* method/field can have, to be used as the type for serialization
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,16 +315,15 @@ public Object findNullSerializer(Annotated a) {
public JsonInclude.Include findSerializationInclusion(Annotated a,
JsonInclude.Include defValue)
{
/* This is bit trickier: need to combine results in a meaningful
* way. Seems like it should be a disjoint; that is, most
* restrictive value should be returned.
* For enumerations, comparison is done by indexes, which
* works: largest value is the last one, which is the most
* restrictive value as well.
*/
/* 09-Mar-2010, tatu: Actually, as per [JACKSON-256], it is probably better to just
* use strict overriding. Simpler, easier to understand.
*/
// note: call secondary first, to give lower priority
defValue = _secondary.findSerializationInclusion(a, defValue);
defValue = _primary.findSerializationInclusion(a, defValue);
return defValue;
}

@Override
public JsonInclude.Include findSerializationInclusionForContent(Annotated a, JsonInclude.Include defValue)
{
// note: call secondary first, to give lower priority
defValue = _secondary.findSerializationInclusion(a, defValue);
defValue = _primary.findSerializationInclusion(a, defValue);
Expand All @@ -333,7 +332,7 @@ public JsonInclude.Include findSerializationInclusion(Annotated a,

@Override
public Class<?> findSerializationType(Annotated a) {
Class<?> r = _primary.findSerializationType(a);
Class<?> r = _primary.findSerializationType(a);
return (r == null) ? _secondary.findSerializationType(a) : r;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,13 @@ public JsonInclude.Include findSerializationInclusion(Annotated a, JsonInclude.I
return defValue;
}

@Override
public JsonInclude.Include findSerializationInclusionForContent(Annotated a, JsonInclude.Include defValue)
{
JsonInclude inc = _findAnnotation(a, JsonInclude.class);
return (inc == null) ? defValue : inc.content();
}

@Override
public Class<?> findSerializationType(Annotated am)
{
Expand Down Expand Up @@ -745,6 +752,7 @@ protected Class<?> _classIfExplicit(Class<?> cls, Class<?> implicit) {
* Helper method called to construct and initialize instance of {@link TypeResolverBuilder}
* if given annotated element indicates one is needed.
*/
@SuppressWarnings("deprecation")
protected TypeResolverBuilder<?> _findTypeResolver(MapperConfig<?> config,
Annotated ann, JavaType baseType)
{
Expand Down

0 comments on commit 76731bc

Please sign in to comment.