org.codehaus.jackson.map.introspect.AnnotatedMethodMap Maven / Gradle / Ivy
Go to download
Data Mapper package is a high-performance data binding package
built on Jackson JSON processor
package org.codehaus.jackson.map.introspect;
import java.lang.reflect.Method;
import java.util.*;
/**
* Simple helper class used to keep track of collection of
* {@link AnnotatedMethod}s, accessible by lookup. Lookup
* is usually needed for augmenting and overriding annotations.
*/
public final class AnnotatedMethodMap
implements Iterable
{
protected LinkedHashMap _methods;
public AnnotatedMethodMap() { }
/**
* Method called to add specified annotated method in the Map.
*/
public void add(AnnotatedMethod am)
{
if (_methods == null) {
_methods = new LinkedHashMap();
}
_methods.put(new MemberKey(am.getAnnotated()), am);
}
/**
* Method called to remove specified method, assuming
* it exists in the Map
*/
public AnnotatedMethod remove(AnnotatedMethod am)
{
return remove(am.getAnnotated());
}
public AnnotatedMethod remove(Method m)
{
if (_methods != null) {
return _methods.remove(new MemberKey(m));
}
return null;
}
public boolean isEmpty() {
return (_methods == null || _methods.size() == 0);
}
public int size() {
return (_methods == null) ? 0 : _methods.size();
}
public AnnotatedMethod find(String name, Class>[] paramTypes)
{
if (_methods == null) {
return null;
}
return _methods.get(new MemberKey(name, paramTypes));
}
public AnnotatedMethod find(Method m)
{
if (_methods == null) {
return null;
}
return _methods.get(new MemberKey(m));
}
/*
/**********************************************************
/* Iterable implementation (for iterating over values)
/**********************************************************
*/
@Override
public Iterator iterator()
{
if (_methods != null) {
return _methods.values().iterator();
}
List empty = Collections.emptyList();
return empty.iterator();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy