KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > codehaus > aspectwerkz > reflect > CflowMetaData


1 /**************************************************************************************
2  * Copyright (c) Jonas Bonér, Alexandre Vasseur. All rights reserved. *
3  * http://aspectwerkz.codehaus.org *
4  * ---------------------------------------------------------------------------------- *
5  * The software in this package is published under the terms of the LGPL license *
6  * a copy of which has been included with this distribution in the license.txt file. *
7  **************************************************************************************/

8 package org.codehaus.aspectwerkz.reflect;
9
10 /**
11  * Holds a tuple that consists of the class info and the info for a specific method.
12  *
13  * @author <a HREF="mailto:jboner@codehaus.org">Jonas Bonér </a>
14  * @author <a HREF="mailto:alex@gnilux.com">Alexandre Vasseur </a>
15  */

16 public class CflowMetaData {
17     /**
18      * The class name.
19      */

20     private final String JavaDoc m_className;
21
22     /**
23      * The class info.
24      */

25     private ClassInfo m_classMetaData;
26
27     /**
28      * The method info.
29      */

30     private final MethodInfo m_methodMetaData;
31
32     /**
33      * Creates a new ClassNameMethodInfoTuple.
34      *
35      * @param classMetaData the class metaData
36      * @param methodMetaData the method info
37      */

38     public CflowMetaData(final ClassInfo classMetaData, final MethodInfo methodMetaData) {
39         m_className = classMetaData.getName();
40         m_classMetaData = classMetaData;
41         m_methodMetaData = methodMetaData;
42     }
43
44     /**
45      * Returns the class info.
46      *
47      * @return the class info
48      */

49     public ClassInfo getClassInfo() {
50         return m_classMetaData;
51     }
52
53     /**
54      * Returns the class name.
55      *
56      * @return the class name
57      */

58     public String JavaDoc getClassName() {
59         return m_className;
60     }
61
62     /**
63      * Returns the method info.
64      *
65      * @return the method info
66      */

67     public MethodInfo getMethodInfo() {
68         return m_methodMetaData;
69     }
70
71     // --- over-ridden methods ---
72
public String JavaDoc toString() {
73         return '[' + super.toString() + ": " + ',' + m_className + ',' + m_classMetaData + ',' + m_methodMetaData +
74                ']';
75     }
76
77     public int hashCode() {
78         int result = 17;
79         result = (37 * result) + hashCodeOrZeroIfNull(m_className);
80         result = (37 * result) + hashCodeOrZeroIfNull(m_classMetaData);
81         result = (37 * result) + hashCodeOrZeroIfNull(m_methodMetaData);
82         return result;
83     }
84
85     protected static int hashCodeOrZeroIfNull(final Object JavaDoc o) {
86         if (null == o) {
87             return 19;
88         }
89         return o.hashCode();
90     }
91
92     public boolean equals(final Object JavaDoc o) {
93         if (this == o) {
94             return true;
95         }
96         if (!(o instanceof CflowMetaData)) {
97             return false;
98         }
99         final CflowMetaData obj = (CflowMetaData) o;
100         return areEqualsOrBothNull(obj.m_className, this.m_className)
101                && areEqualsOrBothNull(obj.m_classMetaData, this.m_classMetaData)
102                && areEqualsOrBothNull(obj.m_methodMetaData, this.m_methodMetaData);
103     }
104
105     protected static boolean areEqualsOrBothNull(final Object JavaDoc o1, final Object JavaDoc o2) {
106         if (null == o1) {
107             return (null == o2);
108         }
109         return o1.equals(o2);
110     }
111 }
Popular Tags