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 org.eclipse.jdt.annotation.NonNull;
13 import org.opendaylight.yangtools.concepts.Path;
16 * A DTO that encapsulates an ownership change for an entity.
18 * @author Thomas Pantelis
20 * @param <P> the instance identifier path type
21 * @param <E> the GenericEntity type
23 public class GenericEntityOwnershipChange<P extends Path<P>, E extends GenericEntity<P>> {
24 private final @NonNull E entity;
25 private final @NonNull EntityOwnershipChangeState state;
26 private final boolean inJeopardy;
28 public GenericEntityOwnershipChange(final @NonNull E entity, final @NonNull EntityOwnershipChangeState state) {
29 this(entity, state, false);
32 public GenericEntityOwnershipChange(final @NonNull E entity, final @NonNull EntityOwnershipChangeState state,
33 final boolean inJeopardy) {
34 this.entity = requireNonNull(entity, "entity can't be null");
35 this.state = requireNonNull(state, "state can't be null");
36 this.inJeopardy = inJeopardy;
40 * Returns the entity whose ownership status changed.
43 public @NonNull E getEntity() {
48 * Returns the ownership change state.
49 * @return an EntityOwnershipChangeState enum
51 public @NonNull EntityOwnershipChangeState getState() {
56 * Returns the current jeopardy state. When in a jeopardy state, the values from other methods may potentially
59 * @return true if the local node is in a jeopardy state. If false, the reported information is accurate.
61 public boolean inJeopardy() {
66 public String toString() {
67 return getClass().getSimpleName() + " [entity=" + entity + ", state=" + state
68 + ", inJeopardy=" + inJeopardy + "]";