View Javadoc
1   /**
2    * Logback: the reliable, generic, fast and flexible logging framework.
3    * Copyright (C) 1999-2021, 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.model;
15  
16  import java.util.Objects;
17  
18  public class NamedComponentModel extends ComponentModel implements INamedModel {
19  
20      private static final long serialVersionUID = -6388316680413871442L;
21      String name;
22  
23      @Override
24      protected NamedComponentModel makeNewInstance() {
25          return new NamedComponentModel();
26      }
27      
28      @Override
29      protected void mirror(Model that) {
30          NamedComponentModel actual = (NamedComponentModel) that;
31          super.mirror(actual);
32          this.name = actual.name;
33      }
34      
35      public String getName() {
36          return name;
37      }
38  
39      public void setName(String name) {
40          this.name = name;
41      }
42  
43      @Override
44      public String toString() {
45          return "NamedComponentModel [name=" + name + ", className=" + className + ", tag=" + tag + ", bodyText="
46                  + bodyText + "]";
47      }
48  
49      @Override
50      public int hashCode() {
51          final int prime = 31;
52          int result = super.hashCode();
53          result = prime * result + Objects.hash(name);
54          return result;
55      }
56  
57      @Override
58      public boolean equals(Object obj) {
59          if (this == obj)
60              return true;
61          if (!super.equals(obj))
62              return false;
63          if (getClass() != obj.getClass())
64              return false;
65          NamedComponentModel other = (NamedComponentModel) obj;
66          return Objects.equals(name, other.name);
67      }
68  
69      
70  }