Bump versions to 10.0.0-SNAPSHOT
[mdsal.git] / binding / mdsal-binding-test-model / src / main / java / org / opendaylight / yang / gen / v1 / urn / opendaylight / params / xml / ns / yang / mdsal / test / bug / _6006 / rev160607 / UnionTypeBuilder.java
1 package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.bug._6006.rev160607;
2
3 import org.opendaylight.yangtools.yang.common.Uint8;
4
5 /**
6  * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation.
7  * In some cases it is very difficult to automate it since there can be unions such as (uint32 - uint16), or (string - uint32).
8  *
9  * The reason behind putting it under src/main/java is:
10  * This class is generated in form of a stub and needs to be finished by the user. This class is generated only once to prevent
11  * loss of user code.
12  *
13  */
14 public class UnionTypeBuilder {
15
16     public static UnionType getDefaultInstance(final java.lang.String defaultValue) {
17         if (defaultValue.equals("IdentOne")) {
18             return new UnionType(IdentOne.class);
19         }
20         if (defaultValue.equals("IdentTwo")) {
21             return new UnionType(IdentTwo.class);
22         }
23
24         try {
25             return new UnionType(Uint8.valueOf(defaultValue));
26         } catch (NumberFormatException e) {
27             /* do nothing */
28         }
29
30         throw new IllegalArgumentException("Unknown UnionType string " + defaultValue);
31     }
32
33 }