Cleaned up Java Binding code from YANG Tools
[mdsal.git] / binding / mdsal-binding-generator-api / src / main / java / org / opendaylight / yangtools / sal / binding / model / api / Constant.java
1 /*
2  * Copyright (c) 2013 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.sal.binding.model.api;
9
10 /**
11  * Interface Contact is designed to hold and model java constant. In Java there
12  * are no constant keywords instead of the constant is defined as static final
13  * field with assigned value. For this purpose the Constant interface contains
14  * methods {@link #getType()} to provide wrapped return Type of Constant,
15  * {@link #getName()} the Name of constant and the {@link #getValue()} for
16  * providing of value assigned to Constant. To determine of which type the
17  * constant value is it is recommended firstly to retrieve Type from constant.
18  * The Type interface holds base information like java package name and java
19  * type name (e.g. fully qualified name). From this string user should be able
20  * to determine to which type can be {@link #getValue()} type typecasted to
21  * unbox and provide value assigned to constant.
22  */
23 public interface Constant {
24
25     /**
26      * Returns the Type that declares constant.
27      * 
28      * @return the Type that declares constant.
29      */
30     Type getDefiningType();
31
32     /**
33      * Returns the return Type (or just Type) of the Constant.
34      * 
35      * @return the return Type (or just Type) of the Constant.
36      */
37     Type getType();
38
39     /**
40      * Returns the name of constant. <br>
41      * By conventions the name SHOULD be in CAPITALS separated with underscores.
42      * 
43      * @return the name of constant.
44      */
45     String getName();
46
47     /**
48      * Returns boxed value that is assigned for context.
49      * 
50      * @return boxed value that is assigned for context.
51      */
52     Object getValue();
53
54     /**
55      * Returns Constant definition in formatted string. <br>
56      * <br>
57      * The expected string SHOULD be in format: <code>public final
58      * static [Type] CONSTANT_NAME = [value];</code>
59      * 
60      * @return Constant definition in formatted string.
61      */
62     String toFormattedString();
63 }