Add getOwnershipState method to EntityOwnershipService
[controller.git] / opendaylight / md-sal / sal-common-api / src / main / java / org / opendaylight / controller / md / sal / common / api / clustering / EntityOwnershipState.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 /**
11  * A DTO that encapsulates ownership state for an entity.
12  *
13  * @author Thomas Pantelis
14  */
15 public class EntityOwnershipState {
16     private final boolean isOwner;
17     private final boolean hasOwner;
18
19     public EntityOwnershipState(boolean isOwner, boolean hasOwner) {
20         this.isOwner = isOwner;
21         this.hasOwner = hasOwner;
22     }
23
24     /**
25      * Returns the current ownership status of the entity for this process instance.
26      * @return true if this process is the owner of the entity
27      */
28     public boolean isOwner() {
29         return isOwner;
30     }
31
32     /**
33      * Returns the current ownership status of the entity across all process instances.
34      * @return true if the entity has an owner which may or may not be this process. If false, then
35      *         the entity has no candidates and thus no owner.
36      */
37     public boolean hasOwner() {
38         return hasOwner;
39     }
40
41     @Override
42     public String toString() {
43         return "EntityOwnershipState [isOwner=" + isOwner + ", hasOwner=" + hasOwner + "]";
44     }
45 }