Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

 

Code Block
titleinput YANG file
File : test.yang

module Test {
    yang-version 1;
    namespace http://huawei.com;
    prefix Ant;

    typedef MyDecimal {
        type decimal64 {
            fraction-digits 2;
            range "1 .. 3.14 | 10 | 20..max";
        }
    }
}
Code Block
titleGenerated java files
File: MyDecimal.java
package org.onosproject.yang.gen.v1.http.huawei.com.rev20160718.test;
import java.math.BigDecimal;
import java.util.Objects;
import com.google.common.base.MoreObjects;


/**
 * Represents the implementation of myDecimal.
 */
public final class MyDecimal {
    private BigDecimal decimal64;


    /**
     * Creates an instance of myDecimal.
     */
    private MyDecimal() {
    }


    /**
     * Creates an instance of myDecimalForTypeDecimal64.
     *
     * @param value value of myDecimalForTypeDecimal64
     */
    public MyDecimal(BigDecimal value) {
        this.decimal64 = value;
    }


    /**
     * Returns the object of myDecimalForTypeDecimal64.
     *
     * @param value value of myDecimalForTypeDecimal64
     * @return Object of myDecimalForTypeDecimal64
     */
    public static MyDecimal of(BigDecimal value) {
        return new MyDecimal(value);
    }


    /**
     * Returns the attribute decimal64.
     *
     * @return value of decimal64
     */
    public BigDecimal decimal64() {
        return decimal64;
    }


    @Override
    public int hashCode() {
        return Objects.hash(decimal64);
    }


    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj instanceof MyDecimal) {
            MyDecimal other = (MyDecimal) obj;
            return
                 Objects.equals(decimal64, other.decimal64);
        }
        return false;
    }


    @Override
    public String toString() {
        return MoreObjects.toStringHelper(getClass())
            .add("decimal64", decimal64)
            .toString();
    }


    /**
     * Returns the object of myDecimal fromString input String.
     *
     * @param valInString input String
     * @return Object of myDecimal
     */
    public static MyDecimal fromString(String valInString) {
        try {
            BigDecimal tmpVal = new BigDecimal(valInString);
            return of(tmpVal);
        } catch (Exception e) {
        }
        return null;
    }
}

 

...