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

com.fasterxml.classmate.AnnotationConfiguration Maven / Gradle / Ivy

Go to download

Library for introspecting types with full generic information including resolving of field and method types.

There is a newer version: 1.7.0
Show newest version
package com.fasterxml.classmate;

import java.io.Serializable;
import java.lang.annotation.Annotation;
import java.util.*;

import com.fasterxml.classmate.util.ClassKey;

/**
 * Interface for object that determines handling of annotations in regards
 * to inheritance, overrides.
 */
@SuppressWarnings("serial")
public abstract class AnnotationConfiguration implements Serializable
{
    /**
     * Method called to figure out how to handle instances of specified annotation
     * type when used as class annotation.
     */
    public abstract AnnotationInclusion getInclusionForClass(Class annotationType);

    /**
     * Method called to figure out how to handle instances of specified annotation
     * type when used as constructor annotation.
     *

* Note that constructor annotations can never be inherited so this just determines * between inclusion or non-inclusion. */ public abstract AnnotationInclusion getInclusionForConstructor(Class annotationType); /** * Method called to figure out how to handle instances of specified annotation * type when used as field annotation. *

* Note that field annotations can never be inherited so this just determines * between inclusion or non-inclusion. */ public abstract AnnotationInclusion getInclusionForField(Class annotationType); /** * Method called to figure out how to handle instances of specified annotation * type when used as method annotation. *

* Note that method annotations can be inherited for member methods, but not for static * methods; for static methods thereby this just determines between inclusion and * non-inclusion. */ public abstract AnnotationInclusion getInclusionForMethod(Class annotationType); /** * Method called to figure out how to handle instances of specified annotation * type when used as parameter annotation. *

* Note that parameter annotations can be inherited for member methods, but not for static * methods; for static methods thereby this just determines between inclusion and * non-inclusion. */ public abstract AnnotationInclusion getInclusionForParameter(Class annotationType); /** * Simple implementation that can be configured with default behavior * for unknown annotations, as well as explicit behaviors for * enumerated annotation types. Same default is used for both class and * member method annotations (constructor, field and static method * annotations are never inherited) */ public static class StdConfiguration extends AnnotationConfiguration implements Serializable { protected final AnnotationInclusion _defaultInclusion; protected final HashMap _inclusions = new HashMap(); public StdConfiguration(AnnotationInclusion defaultBehavior) { _defaultInclusion = defaultBehavior; } @Override public AnnotationInclusion getInclusionForClass(Class annotationType) { return _inclusionFor(annotationType); } @Override public AnnotationInclusion getInclusionForConstructor(Class annotationType) { return _inclusionFor(annotationType); } @Override public AnnotationInclusion getInclusionForField(Class annotationType) { return getInclusionForClass(annotationType); } @Override public AnnotationInclusion getInclusionForMethod(Class annotationType) { return getInclusionForClass(annotationType); } @Override public AnnotationInclusion getInclusionForParameter(Class annotationType) { return getInclusionForClass(annotationType); } public void setInclusion(Class annotationType, AnnotationInclusion incl) { _inclusions.put(new ClassKey(annotationType), incl); } protected AnnotationInclusion _inclusionFor(Class annotationType) { ClassKey key = new ClassKey(annotationType); AnnotationInclusion beh = _inclusions.get(key); return (beh == null) ? _defaultInclusion : beh; } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy