/
Container.java
50 lines (45 loc) · 944 Bytes
/
Container.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package net.ME1312.Galaxi.Library;
/**
* Container Class
*
* @param <V> Item
*/
public class Container<V> {
private V obj;
/**
* Creates a Container
*
* @param item Object to Store
*/
public Container(V item) {
obj = item;
}
/**
* Grabs the Object
*
* @return The Object
*/
public V get() {
return obj;
}
/**
* Overwrite the Object
*
* @param value Object to Store
*/
public void set(V value) {
obj = value;
}
@Override
public boolean equals(Object object) {
if (object instanceof Container) {
if (obj == null || ((Container) object).get() == null) {
return obj == ((Container) object).get();
} else {
return obj.equals(((Container) object).get());
}
} else {
return super.equals(object);
}
}
}