View Javadoc

1   /**
2    * Logback: the generic, reliable, fast and flexible logging framework.
3    * 
4    * Copyright (C) 2000-2009, QOS.ch
5    * 
6    * This library is free software, you can redistribute it and/or modify it under
7    * the terms of the GNU Lesser General Public License as published by the Free
8    * Software Foundation.
9    */
10  package ch.qos.logback.core.joran.spi;
11  
12  /**
13   * A 2-tuple (a double) consisting of a Class and a String. The Class references
14   * the hosting class of a component and the String represents the property name
15   * under which a nested component is referenced the host.
16   * 
17   * This class is used by {@link DefaultNestedComponentRegistry}.
18   * 
19   * @author Ceki Gulcu
20   * 
21   */
22  public class HostClassAndPropertyDouble {
23  
24    final Class hostClass;
25    final String propertyName;
26  
27    public HostClassAndPropertyDouble(Class hostClass, String propertyName) {
28      this.hostClass = hostClass;
29      this.propertyName = propertyName;
30    }
31  
32    public Class getHostClass() {
33      return hostClass;
34    }
35  
36    public String getPropertyName() {
37      return propertyName;
38    }
39  
40    @Override
41    public int hashCode() {
42      final int prime = 31;
43      int result = 1;
44      result = prime * result + ((hostClass == null) ? 0 : hostClass.hashCode());
45      result = prime * result
46          + ((propertyName == null) ? 0 : propertyName.hashCode());
47      return result;
48    }
49  
50    @Override
51    public boolean equals(Object obj) {
52      if (this == obj)
53        return true;
54      if (obj == null)
55        return false;
56      if (getClass() != obj.getClass())
57        return false;
58      final HostClassAndPropertyDouble other = (HostClassAndPropertyDouble) obj;
59      if (hostClass == null) {
60        if (other.hostClass != null)
61          return false;
62      } else if (!hostClass.equals(other.hostClass))
63        return false;
64      if (propertyName == null) {
65        if (other.propertyName != null)
66          return false;
67      } else if (!propertyName.equals(other.propertyName))
68        return false;
69      return true;
70    }
71  
72  }