com.alachisoft.ncache.serialization.JSON.NCacheAnnotationIntrospector Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nc-serialization Show documentation
Show all versions of nc-serialization Show documentation
Internal package of Alachisoft.
package com.alachisoft.ncache.serialization.JSON;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.PropertyName;
import com.fasterxml.jackson.databind.introspect.Annotated;
import com.fasterxml.jackson.databind.introspect.AnnotatedMember;
import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector;
/**
* This class overrides Jackson's way of working with annotations.
* By using this implementation, we can use @PrimaryField annotation to serialize only marked properties in Distributed Data Types
*/
public class NCacheAnnotationIntrospector extends JacksonAnnotationIntrospector {
@Override
public boolean hasIgnoreMarker(AnnotatedMember m) {
PrimaryField an = _findAnnotation(m, PrimaryField.class);
if(an == null) {
return true;
}
return false;
}
@Override
public PropertyName findNameForSerialization(Annotated a) {
PrimaryField pann = (PrimaryField)_findAnnotation(a, PrimaryField.class);
if (pann != null) {
return PropertyName.construct(pann.value());
}
return null;
}
}