Remvoed final and added compareTo() hashCode() and equals() functions
This commit is contained in:
parent
5b2e92b7c7
commit
814fe6c395
|
@ -4,6 +4,7 @@
|
|||
package org.gcube.informationsystem.model.impl.properties;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.gcube.com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import org.gcube.informationsystem.model.reference.properties.Event;
|
||||
|
@ -12,7 +13,7 @@ import org.gcube.informationsystem.model.reference.properties.Event;
|
|||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
@JsonTypeName(value=Event.NAME)
|
||||
public final class EventImpl extends PropertyImpl implements Event {
|
||||
public class EventImpl extends PropertyImpl implements Event {
|
||||
|
||||
/**
|
||||
* Generated Serial Version UID
|
||||
|
@ -90,4 +91,74 @@ public final class EventImpl extends PropertyImpl implements Event {
|
|||
this.how = how;
|
||||
}
|
||||
|
||||
private int compareStrings(String sThis, String sOther) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Event o) {
|
||||
if(o == null) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int compare = 0;
|
||||
if(this.when==null) {
|
||||
if(o.getWhen()==null) {
|
||||
compare = 0;
|
||||
}else {
|
||||
compare = 1;
|
||||
}
|
||||
}else {
|
||||
if(o.getWhen()==null) {
|
||||
compare = -1;
|
||||
}else {
|
||||
compare = this.when.compareTo(o.getWhen());
|
||||
}
|
||||
}
|
||||
if(compare!=0) {
|
||||
return compare;
|
||||
}
|
||||
|
||||
compare = compareStrings(this.what,o.getWhat());
|
||||
if(compare!=0) {
|
||||
return compare;
|
||||
}
|
||||
|
||||
compare = compareStrings(this.who,o.getWho());
|
||||
if(compare!=0) {
|
||||
return compare;
|
||||
}
|
||||
|
||||
compare = compareStrings(where,o.getWhere());
|
||||
if(compare!=0) {
|
||||
return compare;
|
||||
}
|
||||
|
||||
compare = compareStrings(why,o.getWhy());
|
||||
if(compare!=0) {
|
||||
return compare;
|
||||
}
|
||||
|
||||
compare = compareStrings(how,o.getHow());
|
||||
return compare;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(how, what, when, where, who, why);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
EventImpl other = (EventImpl) obj;
|
||||
return Objects.equals(how, other.how) && Objects.equals(what, other.what) && Objects.equals(when, other.when)
|
||||
&& Objects.equals(where, other.where) && Objects.equals(who, other.who)
|
||||
&& Objects.equals(why, other.why);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue