KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > aspectwerkz > reflect > CflowMetaData


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

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

12 public class CflowMetaData {
13   /**
14    * The class name.
15    */

16   private final String JavaDoc m_className;
17
18   /**
19    * The class info.
20    */

21   private ClassInfo m_classMetaData;
22
23   /**
24    * The method info.
25    */

26   private final MethodInfo m_methodMetaData;
27
28   /**
29    * Creates a new ClassNameMethodInfoTuple.
30    *
31    * @param classMetaData the class metaData
32    * @param methodMetaData the method info
33    */

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

45   public ClassInfo getClassInfo() {
46     return m_classMetaData;
47   }
48
49   /**
50    * Returns the class name.
51    *
52    * @return the class name
53    */

54   public String JavaDoc getClassName() {
55     return m_className;
56   }
57
58   /**
59    * Returns the method info.
60    *
61    * @return the method info
62    */

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