|
| 1 | +package io.getstream.core.models; |
| 2 | + |
| 3 | +import com.fasterxml.jackson.annotation.JsonCreator; |
| 4 | +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
| 5 | +import com.fasterxml.jackson.annotation.JsonProperty; |
| 6 | +import com.google.common.base.MoreObjects; |
| 7 | +import io.getstream.core.KeepHistory; |
| 8 | + |
| 9 | +import java.util.Objects; |
| 10 | + |
| 11 | +import static com.google.common.base.Preconditions.checkNotNull; |
| 12 | + |
| 13 | +@JsonIgnoreProperties(ignoreUnknown = true) |
| 14 | +public final class UnfollowOperation { |
| 15 | + private final String source; |
| 16 | + private final String target; |
| 17 | + private final KeepHistory keepHistory; |
| 18 | + |
| 19 | + @JsonCreator |
| 20 | + public UnfollowOperation(@JsonProperty("feed_id") String source, @JsonProperty("target_id") String target, @JsonProperty("keep_history") KeepHistory keepHistory) { |
| 21 | + checkNotNull(source, "UnfollowOperation 'source' field required"); |
| 22 | + checkNotNull(target, "UnfollowOperation 'target' field required"); |
| 23 | + checkNotNull(keepHistory, "UnfollowOperation 'keep history' field required"); |
| 24 | + |
| 25 | + this.source = source; |
| 26 | + this.target = target; |
| 27 | + this.keepHistory = keepHistory; |
| 28 | + } |
| 29 | + |
| 30 | + public UnfollowOperation(FollowRelation follow, KeepHistory keepHistory) { |
| 31 | + checkNotNull(follow, "UnfollowOperation 'follow' field required"); |
| 32 | + checkNotNull(keepHistory, "UnfollowOperation 'keep history' field required"); |
| 33 | + |
| 34 | + this.source = follow.getSource(); |
| 35 | + this.target = follow.getTarget(); |
| 36 | + this.keepHistory = keepHistory; |
| 37 | + } |
| 38 | + |
| 39 | + public String getSource() { |
| 40 | + return this.source; |
| 41 | + } |
| 42 | + |
| 43 | + public String getTarget() { |
| 44 | + return this.target; |
| 45 | + } |
| 46 | + |
| 47 | + public KeepHistory getKeepHistory() { |
| 48 | + return this.keepHistory; |
| 49 | + } |
| 50 | + |
| 51 | + @Override |
| 52 | + public boolean equals(Object o) { |
| 53 | + if (this == o) return true; |
| 54 | + if (o == null || getClass() != o.getClass()) return false; |
| 55 | + UnfollowOperation that = (UnfollowOperation) o; |
| 56 | + return Objects.equals(source, that.source) && |
| 57 | + Objects.equals(target, that.target) && |
| 58 | + Objects.equals(keepHistory, that.keepHistory); |
| 59 | + } |
| 60 | + |
| 61 | + @Override |
| 62 | + public int hashCode() { |
| 63 | + return Objects.hash(source, target, keepHistory); |
| 64 | + } |
| 65 | + |
| 66 | + @Override |
| 67 | + public String toString() { |
| 68 | + return MoreObjects.toStringHelper(this) |
| 69 | + .add("source", this.source) |
| 70 | + .add("target", this.target) |
| 71 | + .add("keep_history", this.keepHistory) |
| 72 | + .toString(); |
| 73 | + } |
| 74 | +} |
0 commit comments