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.transform; 9 10 /*** 11 * A tuple based on className and defining ClassLoader object 12 * 13 * @author <a href="mailto:alex@gnilux.com">Alexandre Vasseur </a> 14 */ 15 public class ClassCacheTuple { 16 private ClassLoader classLoader; 17 18 private String className; 19 20 public ClassCacheTuple(ClassLoader classLoader, String className) { 21 setClassLoader(classLoader); 22 setClassName(className); 23 } 24 25 public ClassCacheTuple(Class klass) { 26 setClassLoader(klass.getClassLoader()); 27 setClassName(klass.getName()); 28 } 29 30 public ClassLoader getClassLoader() { 31 return classLoader; 32 } 33 34 public void setClassLoader(ClassLoader classLoader) { 35 this.classLoader = classLoader; 36 } 37 38 public String getClassName() { 39 return className; 40 } 41 42 public void setClassName(String className) { 43 this.className = className; 44 } 45 46 public boolean equals(Object o) { 47 if (this == o) { 48 return true; 49 } 50 if (!(o instanceof ClassCacheTuple)) { 51 return false; 52 } 53 final ClassCacheTuple classCacheTuple = (ClassCacheTuple) o; 54 if (!classLoader.equals(classCacheTuple.classLoader)) { 55 return false; 56 } 57 if (!className.equals(classCacheTuple.className)) { 58 return false; 59 } 60 return true; 61 } 62 63 public int hashCode() { 64 int result; 65 result = classLoader.hashCode(); 66 result = (29 * result) + className.hashCode(); 67 return result; 68 } 69 }