Merge branch 'master' of ../controller
[yangtools.git] / common / util / src / main / java / org / opendaylight / yangtools / util / concurrent / SettableBoolean.java
1 /*
2  * Copyright (c) 2014 Cisco 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.yangtools.util.concurrent;
9
10 /**
11  * Simple container encapsulating a boolean flag, which can be toggled. It starts
12  * off in the reset state.
13  */
14 final class SettableBoolean {
15     private boolean value = false;
16
17     /**
18      * Set the flag to its initial (false) state.
19      */
20     public void reset() {
21         value = false;
22     }
23
24     /**
25      * Set the flag.
26      */
27     public void set() {
28         value = true;
29     }
30
31     /**
32      * Query the flag.
33      *
34      * @return True if the flag has been set since instantiation or last {@link #reset()}.
35      */
36     public boolean isSet() {
37         return value;
38     }
39 }