All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.alachisoft.ncache.serialization.JSON.NCacheAnnotationIntrospector Maven / Gradle / Ivy

There is a newer version: 5.3.3
Show newest version
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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy