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