View Javadoc

1   package ch.elca.el4j.services.persistence.hibernate.entityfinder;
2   
3   import java.net.URL;
4   
5   import org.hibernate.proxy.HibernateProxyHelper;
6   import org.springframework.util.Assert;
7   
8   /**
9    * Describes the location of a class, accessible through the given classloader. The url points to
10   * the real class file location.
11   *
12   * @svnLink $Revision: 3873 $;$Date: 2009-08-04 13:59:45 +0200 (Di, 04. Aug 2009) $;$Author: swismer $;$URL: https://el4j.svn.sourceforge.net/svnroot/el4j/branches/el4j_3_1/el4j/framework/modules/hibernate/src/main/java/ch/elca/el4j/services/persistence/hibernate/entityfinder/ClassLocation.java $
13   */
14  public class ClassLocation {
15  
16  	private String className;
17  
18  	private URL url;
19  
20  	private ClassLoader classLoader;
21  
22  	public ClassLocation(ClassLoader classLoader, String className, URL url) {
23  		Assert.notNull(classLoader);
24  		Assert.hasText(className);
25  		Assert.notNull(url);
26  		this.className = className;
27  		this.url = url;
28  		this.classLoader = classLoader;
29  	}
30  
31  	public String getClassName() {
32  		return className;
33  	}
34  
35  	public void setClassName(String className) {
36  		this.className = className;
37  	}
38  
39  	public URL getUrl() {
40  		return url;
41  	}
42  
43  	public void setUrl(URL url) {
44  		this.url = url;
45  	}
46  
47  	public ClassLoader getClassLoader() {
48  		return classLoader;
49  	}
50  
51  	public void setClassLoader(ClassLoader classLoader) {
52  		this.classLoader = classLoader;
53  	}
54  
55  	@Override
56  	public int hashCode() {
57  		final int prime = 31;
58  		int result = 1;
59  		result = prime * result + ((getClassName() == null) ? 0 : getClassName().hashCode());
60  		return result;
61  	}
62  
63  	@Override
64  	public boolean equals(Object obj) {
65  		if (this == obj) {
66  			return true;
67  		}
68  		if ((obj == null) || (obj.getClass() != this.getClass())) {
69  			return false;
70  		}
71  		if (getClass() != HibernateProxyHelper.getClassWithoutInitializingProxy(obj)) {
72  			return false;
73  		}
74  		final ClassLocation other = (ClassLocation) obj;
75  		if (getClassName() == null && other.getClassName() != null) {
76  			return false;
77  		}
78  		return getClassName().equals(other.getClassName());
79  	}
80  }