All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.otto.synapse.subscription.events.SubscriptionUpdated Maven / Gradle / Ivy

Go to download

A library used at otto.de to implement Spring Boot based event-sourcing microservices.

There is a newer version: 0.33.1
Show newest version
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 +
                '}';
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy