de.otto.synapse.subscription.events.SubscriptionUpdated Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of synapse-core Show documentation
Show all versions of synapse-core Show documentation
A library used at otto.de to implement Spring Boot based event-sourcing microservices.
package de.otto.synapse.subscription.events;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.collect.ImmutableSet;
import java.util.Set;
public class SubscriptionUpdated extends SubscriptionEvent {
private final Set subscribedEntities;
private final Set unsubscribedEntities;
public SubscriptionUpdated(final @JsonProperty("id") String id,
final @JsonProperty("subscribedEntities") Set subscribedEntities,
final @JsonProperty("unsubscribedEntities") Set unsubscribedEntities) {
super(id, Type.UPDATED);
this.subscribedEntities = subscribedEntities;
this.unsubscribedEntities = unsubscribedEntities;
}
@Override
public SubscriptionCreated asSubscriptionCreated() {
throw new ClassCastException("not a SubscriptionCreated event");
}
@Override
public SubscriptionUpdated asSubscriptionUpdated() {
return this;
}
public Set getSubscribedEntities() {
return subscribedEntities != null ? subscribedEntities : ImmutableSet.of();
}
public Set getUnsubscribedEntities() {
return unsubscribedEntities != null ? unsubscribedEntities : ImmutableSet.of();
}
@Override
public String toString() {
return "SubscriptionUpdated{" +
"subscribedEntities=" + subscribedEntities +
", unsubscribedEntities=" + unsubscribedEntities +
'}';
}
}