1 package com.fasterxml.jackson.databind.introspect;
2
3 import java.lang.reflect.Method;
4 import java.util.*;
5
6 /**
7  * Simple helper class used to keep track of collection of
8  * {@link AnnotatedMethod}s, accessible by lookup. Lookup
9  * is usually needed for augmenting and overriding annotations.
10  */

11 public final class AnnotatedMethodMap
12     implements Iterable<AnnotatedMethod>
13 {
14     protected Map<MemberKey,AnnotatedMethod> _methods;
15
16     public AnnotatedMethodMap() { }
17
18     /**
19      * @since 2.9
20      */

21     public AnnotatedMethodMap(Map<MemberKey,AnnotatedMethod> m) {
22         _methods = m;
23     }
24
25     public int size() {
26         return (_methods == null) ? 0 : _methods.size();
27     }
28
29     public AnnotatedMethod find(String name, Class<?>[] paramTypes)
30     {
31         if (_methods == null) {
32             return null;
33         }
34         return _methods.get(new MemberKey(name, paramTypes));
35     }
36
37     public AnnotatedMethod find(Method m)
38     {
39         if (_methods == null) {
40             return null;
41         }
42         return _methods.get(new MemberKey(m));
43     }
44
45     /*
46     /**********************************************************
47     /* Iterable implementation (for iterating over values)
48     /**********************************************************
49      */

50
51     @Override
52     public Iterator<AnnotatedMethod> iterator()
53     {
54         if (_methods == null) {
55             return Collections.emptyIterator();
56         }
57         return _methods.values().iterator();
58     }
59 }
60