1   package org.djutils.metadata;
2   
3   import java.io.Serializable;
4   
5   import org.djutils.exceptions.Throw;
6   
7   
8   
9   
10  
11  
12  
13  
14  
15  
16  
17  public class ObjectDescriptor implements Serializable
18  {
19      
20      private static final long serialVersionUID = 20200417L;
21  
22      
23      private final String name;
24  
25      
26      private final String description;
27  
28      
29      private final Class<?> objectClass;
30  
31      
32  
33  
34  
35  
36  
37      public ObjectDescriptor(final String name, final String description, final Class<?> objectClass)
38      {
39          Throw.whenNull(name, "name may not be null");
40          Throw.when(name.length() == 0, IllegalArgumentException.class, "empty name is not allowed");
41          Throw.whenNull(description, "description may not be null");
42          Throw.whenNull(objectClass, "objectClass may not be null");
43          this.name = name;
44          this.description = description;
45          this.objectClass = objectClass;
46      }
47  
48      
49  
50  
51  
52      String getName()
53      {
54          return this.name;
55      }
56  
57      
58  
59  
60  
61      String getDescription()
62      {
63          return this.description;
64      }
65  
66      
67  
68  
69  
70      public Class<?> getObjectClass()
71      {
72          return this.objectClass;
73      }
74  
75      
76      @Override
77      public int hashCode()
78      {
79          final int prime = 31;
80          int result = 1;
81          result = prime * result + this.description.hashCode();
82          result = prime * result + this.name.hashCode();
83          result = prime * result + this.objectClass.getName().hashCode();
84          return result;
85      }
86  
87      
88      @Override
89      @SuppressWarnings("checkstyle:needbraces")
90      public boolean equals(final Object obj)
91      {
92          if (this == obj)
93              return true;
94          if (obj == null)
95              return false;
96          if (getClass() != obj.getClass())
97              return false;
98          ObjectDescriptor other = (ObjectDescriptor) obj;
99          if (!this.description.equals(other.description))
100             return false;
101         if (!this.name.equals(other.name))
102             return false;
103         if (!this.objectClass.equals(other.objectClass))
104             return false;
105         return true;
106     }
107 
108     
109     @Override
110     public String toString()
111     {
112         return "ObjectDescriptor [name=" + this.name + ", description=" + this.description + ", objectClass=" + this.objectClass
113                 + "]";
114     }
115 
116 }