001/** 002 * Logback: the reliable, generic, fast and flexible logging framework. 003 * Copyright (C) 1999-2022, 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.model; 015 016import java.util.Objects; 017 018/** 019 * Abstract representation of configuration elements 020 * 021 * @author Ceki Gülcü 022 * @since 1.3.0 023 */ 024public class ComponentModel extends Model { 025 026 private static final long serialVersionUID = -7117814935763453139L; 027 028 String className; 029 030 @Override 031 protected ComponentModel makeNewInstance() { 032 return new ComponentModel(); 033 } 034 035 @Override 036 protected void mirror(Model that) { 037 ComponentModel actual = (ComponentModel) that; 038 super.mirror(actual); 039 this.className = actual.className; 040 } 041 042 043 public String getClassName() { 044 return className; 045 } 046 047 public void setClassName(String className) { 048 this.className = className; 049 } 050 051 @Override 052 public String toString() { 053 return this.getClass().getSimpleName() + " [tag=" + tag + ", className=" + className + ", bodyText=" + bodyText 054 + "]"; 055 } 056 057 @Override 058 public int hashCode() { 059 final int prime = 31; 060 int result = super.hashCode(); 061 result = prime * result + Objects.hash(className); 062 return result; 063 } 064 065 @Override 066 public boolean equals(Object obj) { 067 if (this == obj) 068 return true; 069 if (!super.equals(obj)) 070 return false; 071 if (getClass() != obj.getClass()) 072 return false; 073 ComponentModel other = (ComponentModel) obj; 074 return Objects.equals(className, other.className); 075 } 076 077}