001: /*
002: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
003: */
004: package com.tc.aspectwerkz.reflect;
005:
006: /**
007: * Holds a tuple that consists of the class info and the info for a specific method.
008: *
009: * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a>
010: * @author <a href="mailto:alex@gnilux.com">Alexandre Vasseur </a>
011: */
012: public class CflowMetaData {
013: /**
014: * The class name.
015: */
016: private final String m_className;
017:
018: /**
019: * The class info.
020: */
021: private ClassInfo m_classMetaData;
022:
023: /**
024: * The method info.
025: */
026: private final MethodInfo m_methodMetaData;
027:
028: /**
029: * Creates a new ClassNameMethodInfoTuple.
030: *
031: * @param classMetaData the class metaData
032: * @param methodMetaData the method info
033: */
034: public CflowMetaData(final ClassInfo classMetaData,
035: final MethodInfo methodMetaData) {
036: m_className = classMetaData.getName();
037: m_classMetaData = classMetaData;
038: m_methodMetaData = methodMetaData;
039: }
040:
041: /**
042: * Returns the class info.
043: *
044: * @return the class info
045: */
046: public ClassInfo getClassInfo() {
047: return m_classMetaData;
048: }
049:
050: /**
051: * Returns the class name.
052: *
053: * @return the class name
054: */
055: public String getClassName() {
056: return m_className;
057: }
058:
059: /**
060: * Returns the method info.
061: *
062: * @return the method info
063: */
064: public MethodInfo getMethodInfo() {
065: return m_methodMetaData;
066: }
067:
068: // --- over-ridden methods ---
069: public String toString() {
070: return '[' + super .toString() + ": " + ',' + m_className + ','
071: + m_classMetaData + ',' + m_methodMetaData + ']';
072: }
073:
074: public int hashCode() {
075: int result = 17;
076: result = (37 * result) + hashCodeOrZeroIfNull(m_className);
077: result = (37 * result) + hashCodeOrZeroIfNull(m_classMetaData);
078: result = (37 * result) + hashCodeOrZeroIfNull(m_methodMetaData);
079: return result;
080: }
081:
082: protected static int hashCodeOrZeroIfNull(final Object o) {
083: if (null == o) {
084: return 19;
085: }
086: return o.hashCode();
087: }
088:
089: public boolean equals(final Object o) {
090: if (this == o) {
091: return true;
092: }
093: if (!(o instanceof CflowMetaData)) {
094: return false;
095: }
096: final CflowMetaData obj = (CflowMetaData) o;
097: return areEqualsOrBothNull(obj.m_className, this .m_className)
098: && areEqualsOrBothNull(obj.m_classMetaData,
099: this .m_classMetaData)
100: && areEqualsOrBothNull(obj.m_methodMetaData,
101: this .m_methodMetaData);
102: }
103:
104: protected static boolean areEqualsOrBothNull(final Object o1,
105: final Object o2) {
106: if (null == o1) {
107: return (null == o2);
108: }
109: return o1.equals(o2);
110: }
111: }
|