Deprecate legacy EOS API classes
[controller.git] / opendaylight / md-sal / sal-common-api / src / main / java / org / opendaylight / controller / md / sal / common / api / clustering / EntityOwnershipChange.java
1 /*
2  * Copyright (c) 2015 Brocade Communications Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.md.sal.common.api.clustering;
9
10 import com.google.common.base.Preconditions;
11 import javax.annotation.Nonnull;
12
13 /**
14  * A DTO that encapsulates an ownership change for an entity.
15  *
16  * @author Thomas Pantelis
17  *
18  * @deprecated Use org.opendaylight.mdsal.binding.api.clustering.EntityOwnershipChange or
19  *             org.opendaylight.mdsal.dom.api.clustering.DOMEntityOwnershipChange instead
20  */
21 @Deprecated
22 public class EntityOwnershipChange {
23     private final Entity entity;
24     private final boolean wasOwner;
25     private final boolean isOwner;
26     private final boolean hasOwner;
27     private final boolean inJeopardy;
28
29     public EntityOwnershipChange(@Nonnull Entity entity, boolean wasOwner, boolean isOwner, boolean hasOwner) {
30         this(entity, wasOwner, isOwner, hasOwner, false);
31     }
32
33     public EntityOwnershipChange(@Nonnull Entity entity, boolean wasOwner, boolean isOwner, boolean hasOwner,
34             boolean inJeopardy) {
35         this.entity = Preconditions.checkNotNull(entity, "entity can't be null");
36         this.wasOwner = wasOwner;
37         this.isOwner = isOwner;
38         this.hasOwner = hasOwner;
39         this.inJeopardy = inJeopardy;
40     }
41
42     /**
43      * Returns the entity whose ownership status changed.
44      * @return the entity
45      */
46     @Nonnull public Entity getEntity() {
47         return entity;
48     }
49
50     /**
51      * Returns the previous ownership status of the entity for this process instance.
52      * @return true if this process was the owner of the entity at the time this notification was generated
53      */
54     public boolean wasOwner() {
55         return wasOwner;
56     }
57
58     /**
59      * Returns the current ownership status of the entity for this process instance.
60      * @return true if this process is now the owner of the entity
61      */
62     public boolean isOwner() {
63         return isOwner;
64     }
65
66     /**
67      * Returns the current ownership status of the entity across all process instances.
68      * @return true if the entity has an owner which may or may not be this process. If false, then
69      *         the entity has no candidates and thus no owner.
70      */
71     public boolean hasOwner() {
72         return hasOwner;
73     }
74
75     /**
76      * Returns the current jeopardy state. When in a jeopardy state, the values from other methods may potentially
77      * be out of date.
78      *
79      * @return true if the local node is in a jeopardy state. If false, the reported information is accurate.
80      */
81     public boolean inJeopardy() {
82         return inJeopardy;
83     }
84
85     @Override
86     public String toString() {
87         return "EntityOwnershipChanged [entity=" + entity + ", wasOwner=" + wasOwner + ", isOwner=" + isOwner
88                 + ", hasOwner=" + hasOwner + ", inJeopardy=" + inJeopardy + "]";
89     }
90 }