Move Adapter for Binding EntityOwnershipService
[mdsal.git] / entityownership / mdsal-eos-common-api / src / main / java / org / opendaylight / mdsal / 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.mdsal.common.api.clustering;
9
10 /**
11  * Enumerates the current ownership state for an entity.
12  *
13  * @author Thomas Pantelis
14  */
15 public enum EntityOwnershipState {
16     /**
17      * The local process instance is the owner of the entity.
18      */
19     IS_OWNER,
20
21     /**
22      * A remote process instance is the owner of the entity.
23      */
24     OWNED_BY_OTHER,
25
26     /**
27      * The entity has no owner and thus no candidates.
28      */
29     NO_OWNER;
30
31     public static EntityOwnershipState from(boolean isOwner, boolean hasOwner) {
32         if(isOwner) {
33             return IS_OWNER;
34         } else if(hasOwner) {
35             return OWNED_BY_OTHER;
36         } else {
37             return NO_OWNER;
38         }
39     }
40 }