57 lines
1.0 KiB
Java
57 lines
1.0 KiB
Java
package org.gcube.spatial.data.sdi.model.metadata;
|
|
|
|
import java.util.HashSet;
|
|
import java.util.Set;
|
|
|
|
import javax.xml.bind.annotation.XmlAnyElement;
|
|
|
|
public class SetWrapper<T> {
|
|
|
|
private Set<T> set;
|
|
|
|
public SetWrapper() {
|
|
set=new HashSet<T>();
|
|
}
|
|
|
|
public SetWrapper(Set<T> set){
|
|
this.set=set;
|
|
}
|
|
|
|
@XmlAnyElement(lax=true)
|
|
public Set<T> getSet(){
|
|
return set;
|
|
}
|
|
|
|
@Override
|
|
public int hashCode() {
|
|
final int prime = 31;
|
|
int result = 1;
|
|
if(set==null)
|
|
result=prime*result;
|
|
else
|
|
for(T obj:set)
|
|
result = prime * result + ((obj == null) ? 0 : obj.hashCode());
|
|
return result;
|
|
}
|
|
|
|
@Override
|
|
public boolean equals(Object obj) {
|
|
if (this == obj)
|
|
return true;
|
|
if (obj == null)
|
|
return false;
|
|
if (getClass() != obj.getClass())
|
|
return false;
|
|
SetWrapper other = (SetWrapper) obj;
|
|
if (set == null) {
|
|
if (other.set != null)
|
|
return false;
|
|
} else
|
|
if(!other.set.containsAll(set)) return false;
|
|
else if (!set.containsAll(other.set)) return false;
|
|
return true;
|
|
}
|
|
|
|
|
|
}
|