1 /**
2  * Logback: the reliable, generic, fast and flexible logging framework.
3  * Copyright (C) 1999-2015, 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 + ((propertyName == null) ? 0 : propertyName.hashCode());
50         return result;
51     }
52
53     @Override
54     public boolean equals(Object obj) {
55         if (this == obj)
56             return true;
57         if (obj == null)
58             return false;
59         if (getClass() != obj.getClass())
60             return false;
61         final HostClassAndPropertyDouble other = (HostClassAndPropertyDouble) obj;
62         if (hostClass == null) {
63             if (other.hostClass != null)
64                 return false;
65         } else if (!hostClass.equals(other.hostClass))
66             return false;
67         if (propertyName == null) {
68             if (other.propertyName != null)
69                 return false;
70         } else if (!propertyName.equals(other.propertyName))
71             return false;
72         return true;
73     }
74
75 }
76