2 * Copyright (c) 2015 Brocade Communications Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.mdsal.eos.common.api;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.base.MoreObjects;
13 import org.eclipse.jdt.annotation.NonNull;
16 * A DTO that encapsulates an ownership change for an entity.
18 * @param <E> the {@link GenericEntity} type
19 * @author Thomas Pantelis
21 public final class EntityOwnershipChange<E extends GenericEntity<?>> {
22 private final @NonNull E entity;
23 private final @NonNull EntityOwnershipStateChange state;
24 private final boolean inJeopardy;
26 public EntityOwnershipChange(final @NonNull E entity, final @NonNull EntityOwnershipStateChange state) {
27 this(entity, state, false);
30 public EntityOwnershipChange(final @NonNull E entity, final @NonNull EntityOwnershipStateChange state,
31 final boolean inJeopardy) {
32 this.entity = requireNonNull(entity, "entity can't be null");
33 this.state = requireNonNull(state, "state can't be null");
34 this.inJeopardy = inJeopardy;
38 * Returns the entity whose ownership status changed.
41 public @NonNull E getEntity() {
46 * Returns the ownership change state.
47 * @return an EntityOwnershipStateChange enum
49 public @NonNull EntityOwnershipStateChange getState() {
54 * Returns the current jeopardy state. When in a jeopardy state, the values from other methods may potentially
57 * @return true if the local node is in a jeopardy state. If false, the reported information is accurate.
59 public boolean inJeopardy() {
64 public String toString() {
65 return MoreObjects.toStringHelper(this)
66 .add("entity", entity)
68 .add("inJeopardy", inJeopardy)