package com.atlassian.bitbucket.mesh.repository;

import javax.annotation.Nonnull;

import static java.util.Objects.requireNonNull;

public class ReplicaStateObservedEvent {

    private final ReplicaStateObservation observation;
    private final boolean reported;
    private final String repositoryId;

    public ReplicaStateObservedEvent(@Nonnull String repositoryId, @Nonnull ReplicaStateObservation observation) {
        this(repositoryId, observation, false);
    }

    public ReplicaStateObservedEvent(@Nonnull String repositoryId, @Nonnull ReplicaStateObservation observation,
                                     boolean reported) {
        this.observation = requireNonNull(observation, "observation");
        this.reported = reported;
        this.repositoryId = requireNonNull(repositoryId, "repositoryId");
    }

    @Nonnull
    public ReplicaStateObservation getObservation() {
        return observation;
    }

    @Nonnull
    public String getRepositoryId() {
        return repositoryId;
    }

    /**
     * @return {@code true} if the state has already been reported to the control plane
     */
    public boolean isReported() {
        return reported;
    }
}
