Skip to content

Commit

Permalink
feat: added equals() to artifact events (#556)
Browse files Browse the repository at this point in the history
  • Loading branch information
olenagerasimova authored Aug 30, 2023
1 parent ee448a4 commit a7fcace
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/main/java/com/artipie/scheduling/ArtifactEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*/
package com.artipie.scheduling;

import java.util.Objects;

/**
* Artifact data record.
* @since 1.3
Expand Down Expand Up @@ -201,6 +203,26 @@ public Type eventType() {
return this.etype;
}

@Override
public int hashCode() {
return Objects.hash(this.rname, this.aname, this.version, this.etype);
}

@Override
public boolean equals(final Object other) {
final boolean res;
if (this == other) {
res = true;
} else if (other == null || getClass() != other.getClass()) {
res = false;
} else {
final ArtifactEvent that = (ArtifactEvent) other;
res = that.rname.equals(this.rname) && that.aname.equals(this.aname)
&& that.version.equals(this.version) && that.etype.equals(this.etype);
}
return res;
}

/**
* Events type.
* @since 1.3
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/com/artipie/scheduling/ProxyArtifactEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package com.artipie.scheduling;

import com.artipie.asto.Key;
import java.util.Objects;

/**
* Proxy artifact event contains artifact key in storage,
Expand Down Expand Up @@ -73,4 +74,22 @@ public String ownerLogin() {
return this.owner;
}

@Override
public boolean equals(final Object other) {
final boolean res;
if (this == other) {
res = true;
} else if (other == null || getClass() != other.getClass()) {
res = false;
} else {
final ProxyArtifactEvent that = (ProxyArtifactEvent) other;
res = this.key.equals(that.key) && this.rname.equals(that.rname);
}
return res;
}

@Override
public int hashCode() {
return Objects.hash(this.key, this.rname);
}
}

0 comments on commit a7fcace

Please sign in to comment.