1 package com.soebes.maven.plugins.iterator;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.util.Objects;
23 import java.util.Properties;
24
25
26
27
28
29
30 public class ItemWithProperties
31 {
32 private String name;
33
34 private Properties properties;
35
36 public static final Properties NO_PROPERTIES = new Properties();
37
38 public static final String NO_NAME = "";
39
40 public ItemWithProperties()
41 {
42 this( NO_NAME, NO_PROPERTIES );
43 }
44
45
46
47
48
49
50 public ItemWithProperties( String name, Properties properties )
51 {
52 super();
53 this.name = Objects.requireNonNull( name, "name is not allowed to be null." );
54 this.properties = Objects.requireNonNull( properties, "properties is not allowed to be null." );
55 }
56
57 public String getName()
58 {
59 return name;
60 }
61
62 public void setName( String name )
63 {
64 this.name = Objects.requireNonNull( name, "name is not allowed to be null." );
65 }
66
67 public Properties getProperties()
68 {
69 return properties;
70 }
71
72 public void setProperties( Properties properties )
73 {
74 this.properties = Objects.requireNonNull( properties, "properties is not allowed to be null." );
75 }
76
77 public boolean hasProperties()
78 {
79 if ( properties == NO_PROPERTIES )
80 {
81 return false;
82 }
83 else
84 {
85 return true;
86 }
87 }
88
89 public boolean hasName()
90 {
91 if ( name == NO_NAME )
92 {
93 return false;
94 }
95 else
96 {
97 return true;
98 }
99 }
100
101 @Override
102 public int hashCode()
103 {
104 final int prime = 31;
105 int result = 1;
106 result = prime * result + ( ( name == null ) ? 0 : name.hashCode() );
107 result = prime * result + ( ( properties == null ) ? 0 : properties.hashCode() );
108 return result;
109 }
110
111 @Override
112 public boolean equals( Object obj )
113 {
114 if ( this == obj )
115 return true;
116 if ( obj == null )
117 return false;
118 if ( getClass() != obj.getClass() )
119 return false;
120 ItemWithProperties other = (ItemWithProperties) obj;
121 if ( name == null )
122 {
123 if ( other.name != null )
124 return false;
125 }
126 else if ( !name.equals( other.name ) )
127 return false;
128 if ( properties == null )
129 {
130 if ( other.properties != null )
131 return false;
132 }
133 else if ( !properties.equals( other.properties ) )
134 return false;
135 return true;
136 }
137
138 }