Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import lombok.SneakyThrows;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;


/**
Expand Down Expand Up @@ -88,39 +85,6 @@ public static class PrimaryKey {
@Column(name = CREATED_FOR_COLUMN, nullable = true)
private String createdFor;

@SneakyThrows
@Override
public boolean equals(Object o) {
if (o == null) {
return false;
}
if (o.getClass() != this.getClass()) {
return false;
}
EbeanMetadataAspect other = (EbeanMetadataAspect) o;

boolean primitiveEqualityCheck = this.key.equals(other.key)
// either both metadata fields are null or both are equal (will check non-null equality after)
&& ((this.metadata == null && other.metadata == null) || (this.metadata != null && other.metadata != null))
&& Math.abs(this.createdOn.getTime() - other.getCreatedOn().getTime()) < 1000 // timestamps are considered equal if within 1s of each other
&& this.createdBy.equals(other.getCreatedBy())
// either both createdFor fields are null or both are equal (need to check this.createdFor != null to avoid NPE)
&& ((this.createdFor == null && other.getCreatedFor() == null) || (this.createdFor != null && this.createdFor.equals(other.getCreatedFor())));
if (!primitiveEqualityCheck) {
return false;
}

JSONParser parser = new JSONParser();
JSONObject thisMetadata = (JSONObject) parser.parse(this.metadata);
JSONObject otherMetadata = (JSONObject) parser.parse(other.metadata);
return thisMetadata.equals(otherMetadata);
}

@Override
public int hashCode() {
return super.hashCode();
}

@Override
public String toString() {
final String str = "EbeanMetadataAspect: {key: <urn:%s, aspect:%s, version:%s>, createdOn: %s, createdBy: %s, createdFor: %s, metadata: %s}";
Expand Down