View Javadoc

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