Add Empty.value()
[yangtools.git] / common / yang-common / src / main / java / org / opendaylight / yangtools / yang / common / Empty.java
1 /*
2  * Copyright (c) 2015 Pantheon Technologies s.r.o. 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.yang.common;
9
10 import com.google.common.annotations.Beta;
11 import java.io.Serializable;
12 import org.eclipse.jdt.annotation.NonNullByDefault;
13 import org.opendaylight.yangtools.concepts.Immutable;
14
15 /**
16  * Dedicated singleton type for YANG's 'type empty' value.
17  *
18  * @author Robert Varga
19  */
20 @Beta
21 @NonNullByDefault
22 public final class Empty implements Immutable, Serializable {
23     private static final long serialVersionUID = 1L;
24     private static final Empty INSTANCE = new Empty();
25
26     private Empty() {
27         // Hidden on purpose
28     }
29
30     /**
31      * Return the singleton {@link Empty} value.
32      *
33      * @return Empty value.
34      * @deprecated Use {@link #value()} instead.
35      */
36     @Deprecated(since = "7.0.10", forRemoval = true)
37     public static Empty getInstance() {
38         return value();
39     }
40
41     /**
42      * Return the singleton {@link Empty} value.
43      *
44      * @return Empty value.
45      */
46     public static Empty value()  {
47         return INSTANCE;
48     }
49
50     @Override
51     public String toString() {
52         return "empty";
53     }
54
55     @SuppressWarnings("static-method")
56     private Object readResolve() {
57         return INSTANCE;
58     }
59 }