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 018public class NamedModel extends Model implements INamedModel { 019 020 private static final long serialVersionUID = 3549881638769570183L; 021 022 String name; 023 024 @Override 025 protected NamedModel makeNewInstance() { 026 return new NamedModel(); 027 } 028 029 @Override 030 protected void mirror(Model that) { 031 NamedModel actual = (NamedModel) that; 032 super.mirror(actual); 033 this.name = actual.name; 034 } 035 036 public String getName() { 037 return name; 038 } 039 040 public void setName(String name) { 041 this.name = name; 042 } 043 044 @Override 045 public int hashCode() { 046 final int prime = 31; 047 int result = super.hashCode(); 048 result = prime * result + Objects.hash(name); 049 return result; 050 } 051 052 @Override 053 public boolean equals(Object obj) { 054 if (this == obj) 055 return true; 056 if (!super.equals(obj)) 057 return false; 058 if (getClass() != obj.getClass()) 059 return false; 060 NamedModel other = (NamedModel) obj; 061 return Objects.equals(name, other.name); 062 } 063 064 065}