Use pattern matching on instanceof in yang-common
[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 java.io.Serializable;
11 import org.eclipse.jdt.annotation.NonNullByDefault;
12 import org.opendaylight.yangtools.concepts.Immutable;
13
14 /**
15  * Dedicated singleton type for YANG's 'type empty' value.
16  *
17  * @author Robert Varga
18  */
19 @NonNullByDefault
20 public final class Empty implements Immutable, Serializable {
21     private static final long serialVersionUID = 1L;
22     private static final Empty INSTANCE = new Empty();
23
24     private Empty() {
25         // Hidden on purpose
26     }
27
28     /**
29      * Return the singleton {@link Empty} value.
30      *
31      * @return Empty value.
32      */
33     public static Empty value()  {
34         return INSTANCE;
35     }
36
37     @Override
38     public String toString() {
39         return "empty";
40     }
41
42     @SuppressWarnings("static-method")
43     private Object readResolve() {
44         return INSTANCE;
45     }
46 }