1 package org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev191129;
3 import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
4 import java.lang.reflect.Constructor;
5 import java.lang.reflect.InvocationTargetException;
6 import java.math.BigDecimal;
7 import java.math.BigInteger;
8 import java.util.Optional;
9 import org.opendaylight.yangtools.yang.common.Uint64;
12 * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string
13 * representation. In some cases it is very difficult to automate it since there can be unions such as (uint32 -
14 * uint16), or (string - uint32).
16 * The reason behind putting it under src/main/java is: This class is generated in form of a stub and needs to be
17 * finished by the user. This class is generated only once to prevent loss of user code.
20 @JsonPOJOBuilder(buildMethodName = "build", withPrefix = "with")
21 public class PmDataTypeBuilder {
22 private Uint64 _uint64;
23 private BigInteger _unint64;
25 private BigDecimal _decimal64;
27 public PmDataTypeBuilder() {
28 System.out.println("-- Builder");
31 public PmDataTypeBuilder setUnint64(String v) {
32 _unint64 = new BigInteger(v);
36 public PmDataTypeBuilder setUint64(String v) {
37 _uint64 = Uint64.valueOf(v);
41 public PmDataTypeBuilder setInt64(String v) {
46 public PmDataTypeBuilder setDecimal64(String v) {
47 _decimal64 = new BigDecimal(v);
51 public PmDataType build() {
52 Optional<Constructor<PmDataType>> cons1;
54 cons1 = Optional.of(PmDataType.class.getConstructor(BigInteger.class));
55 } catch (NoSuchMethodException | SecurityException e) {
56 cons1 = Optional.empty();
58 Optional<Constructor<PmDataType>> cons2;
60 cons2 = Optional.of(PmDataType.class.getConstructor(Uint64.class));
61 } catch (NoSuchMethodException | SecurityException e) {
62 cons2 = Optional.empty();
66 if (_unint64 != null) {
67 return cons1.get().newInstance(_unint64);
68 } else if (_uint64 != null) {
69 return cons2.get().newInstance(_uint64);
70 } else if (_int64 != null) {
71 return new PmDataType(_int64);
73 return new PmDataType(_decimal64);
75 } catch (InstantiationException | IllegalAccessException | IllegalArgumentException
76 | InvocationTargetException e) {
77 throw new IllegalArgumentException("Wrong stuff");
81 public static PmDataType getDefaultInstance(String defaultValue) {
82 return new PmDataTypeBuilder().setInt64("-1").build();