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 com.google.common.base.Preconditions;
11 import javax.annotation.Nonnull;
12 import org.opendaylight.yangtools.concepts.Path;
15 * A DTO that encapsulates an ownership change for an entity.
17 * @author Thomas Pantelis
19 * @param <P> the instance identifier path type
20 * @param <E> the GenericEntity type
22 public class GenericEntityOwnershipChange<P extends Path<P>, E extends GenericEntity<P>> {
23 private final E entity;
24 private final EntityOwnershipChangeState state;
25 private final boolean inJeopardy;
27 public GenericEntityOwnershipChange(@Nonnull final E entity, @Nonnull final EntityOwnershipChangeState state) {
28 this(entity, state, false);
31 public GenericEntityOwnershipChange(@Nonnull final E entity, @Nonnull final EntityOwnershipChangeState state,
32 final boolean inJeopardy) {
33 this.entity = Preconditions.checkNotNull(entity, "entity can't be null");
34 this.state = Preconditions.checkNotNull(state, "state can't be null");
35 this.inJeopardy = inJeopardy;
39 * Returns the entity whose ownership status changed.
42 @Nonnull public E getEntity() {
47 * Returns the ownership change state.
48 * @return an EntityOwnershipChangeState enum
50 @Nonnull public EntityOwnershipChangeState getState() {
55 * Returns the current jeopardy state. When in a jeopardy state, the values from other methods may potentially
58 * @return true if the local node is in a jeopardy state. If false, the reported information is accurate.
60 public boolean inJeopardy() {
65 public String toString() {
66 return getClass().getSimpleName() + " [entity=" + entity + ", state=" + state + ", inJeopardy=" + inJeopardy + "]";