2016-12-24 05:55:17 +01:00
|
|
|
package net.ME1312.SubServers.Bungee.Library;
|
2016-12-05 04:21:04 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Container Class
|
|
|
|
*
|
2017-01-07 20:06:54 +01:00
|
|
|
* @param <V> Item
|
2016-12-05 04:21:04 +01:00
|
|
|
*/
|
2016-12-15 22:04:39 +01:00
|
|
|
public class Container<V> {
|
|
|
|
private V obj;
|
2016-12-05 04:21:04 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a Container
|
|
|
|
*
|
|
|
|
* @param item Object to Store
|
|
|
|
*/
|
2016-12-15 22:04:39 +01:00
|
|
|
public Container(V item) {
|
2016-12-05 04:21:04 +01:00
|
|
|
obj = item;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Grabs the Object
|
|
|
|
*
|
|
|
|
* @return The Object
|
|
|
|
*/
|
2016-12-15 22:04:39 +01:00
|
|
|
public V get() {
|
2016-12-05 04:21:04 +01:00
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Overwrite the Object
|
|
|
|
*
|
|
|
|
* @param value Object to Store
|
|
|
|
*/
|
2016-12-15 22:04:39 +01:00
|
|
|
public void set(V value) {
|
2016-12-05 04:21:04 +01:00
|
|
|
obj = value;
|
|
|
|
}
|
2017-07-21 22:45:41 +02:00
|
|
|
|
|
|
|
@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);
|
|
|
|
}
|
|
|
|
}
|
2016-12-05 04:21:04 +01:00
|
|
|
}
|