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