001/** 002 * Logback: the reliable, generic, fast and flexible logging framework. 003 * Copyright (C) 1999-2015, QOS.ch. All rights reserved. 004 * 005 * This program and the accompanying materials are dual-licensed under 006 * either the terms of the Eclipse Public License v1.0 as published by 007 * the Eclipse Foundation 008 * 009 * or (per the licensee's choosing) 010 * 011 * under the terms of the GNU Lesser General Public License version 2.1 012 * as published by the Free Software Foundation. 013 */ 014package ch.qos.logback.core.joran.spi; 015 016/** 017 * A 2-tuple (a double) consisting of a Class and a String. The Class references 018 * the hosting class of a component and the String represents the property name 019 * under which a nested component is referenced the host. 020 * 021 * This class is used by {@link DefaultNestedComponentRegistry}. 022 * 023 * @author Ceki Gulcu 024 * 025 */ 026public class HostClassAndPropertyDouble { 027 028 final Class<?> hostClass; 029 final String propertyName; 030 031 public HostClassAndPropertyDouble(Class<?> hostClass, String propertyName) { 032 this.hostClass = hostClass; 033 this.propertyName = propertyName; 034 } 035 036 public Class<?> getHostClass() { 037 return hostClass; 038 } 039 040 public String getPropertyName() { 041 return propertyName; 042 } 043 044 @Override 045 public int hashCode() { 046 final int prime = 31; 047 int result = 1; 048 result = prime * result + ((hostClass == null) ? 0 : hostClass.hashCode()); 049 result = prime * result + ((propertyName == null) ? 0 : propertyName.hashCode()); 050 return result; 051 } 052 053 @Override 054 public boolean equals(Object obj) { 055 if (this == obj) 056 return true; 057 if (obj == null) 058 return false; 059 if (getClass() != obj.getClass()) 060 return false; 061 final HostClassAndPropertyDouble other = (HostClassAndPropertyDouble) obj; 062 if (hostClass == null) { 063 if (other.hostClass != null) 064 return false; 065 } else if (!hostClass.equals(other.hostClass)) 066 return false; 067 if (propertyName == null) { 068 if (other.propertyName != null) 069 return false; 070 } else if (!propertyName.equals(other.propertyName)) 071 return false; 072 return true; 073 } 074 075}