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 public String getName()
53 {
54 return this.name;
55 }
56
57
58
59
60
61 public 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 @Override
76 public int hashCode()
77 {
78 final int prime = 31;
79 int result = 1;
80 result = prime * result + this.description.hashCode();
81 result = prime * result + this.name.hashCode();
82 result = prime * result + this.objectClass.getName().hashCode();
83 return result;
84 }
85
86 @Override
87 @SuppressWarnings("checkstyle:needbraces")
88 public boolean equals(final Object obj)
89 {
90 if (this == obj)
91 return true;
92 if (obj == null)
93 return false;
94 if (getClass() != obj.getClass())
95 return false;
96 ObjectDescriptor other = (ObjectDescriptor) obj;
97 if (!this.description.equals(other.description))
98 return false;
99 if (!this.name.equals(other.name))
100 return false;
101 if (!this.objectClass.equals(other.objectClass))
102 return false;
103 return true;
104 }
105
106 @Override
107 public String toString()
108 {
109 return "ObjectDescriptor [name=" + this.name + ", description=" + this.description + ", objectClass=" + this.objectClass
110 + "]";
111 }
112
113 }