public class YangUnion
extends java.lang.Object
From RFC 6020: When a string representing a union data type is validated, the string is validated against each member type, in the order they are specified in the "type" statement, until a match is found. Any default value or "units" property defined in the member types is not inherited by the union type.
| Modifier and Type | Field and Description |
|---|---|
protected T |
value
The value of this object, of which this class is a wrapper for.
|
| Constructor and Description |
|---|
YangUnion(java.lang.String value,
java.lang.String[] memberTypes)
Creates a YangUnion object from a java.lang.String representing a value
of one of the member types.
|
YangUnion(YangType<?> value,
java.lang.String[] memberTypes)
Creates a YangUnion object from a YangType, which should be an instance
of one of the member types.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
canEqual(java.lang.Object obj)
Compares type of obj with this object to see if they can be equal.
|
void |
check()
Checks that the value of this object is not null and is instance of a
member type.
|
com.tailf.jnc.YangBaseType<T> |
clone()
Clones this object and its value.
|
protected YangUnion |
cloneShallow()
Clones this object without cloning its value.
|
boolean |
equals(java.lang.Object obj)
Compares this union with another object for equality.
|
protected YangType<?> |
fromString(java.lang.String s)
Parses a value of a member type
|
T |
getValue() |
int |
hashCode() |
protected java.lang.String[] |
memberTypes()
Get the types allowed for this union.
|
void |
setValue(java.lang.String value)
Sets the value of this object using a java.lang.String.
|
void |
setValue(YangType<?> value)
Sets the value of this object using an Object.
|
java.lang.String |
toString() |
protected T value
public YangUnion(java.lang.String value,
java.lang.String[] memberTypes)
throws YangException
value - The Java String.memberTypes - A string array with the types of the unionYangException - If an invariant was broken during assignment.public YangUnion(YangType<?> value, java.lang.String[] memberTypes) throws YangException
value - The Object to use as value.memberTypes - A string array with the types of the unionYangException - If an invariant was broken during assignment, for
example if the value is of an incorrect type.protected java.lang.String[] memberTypes()
public void setValue(java.lang.String value)
throws YangException
setValue in interface YangType<YangType<?>>value - The Java String.YangException - If an invariant was broken during assignment.public void setValue(YangType<?> value) throws YangException
setValue in interface YangType<YangType<?>>value - The Object to set as the new value.YangException - If an invariant was broken during assignment.protected YangType<?> fromString(java.lang.String s)
s - String representation of member type valuepublic void check()
throws YangException
check in interface YangType<YangType<?>>YangException - If the value of this object is invalid.public boolean canEqual(java.lang.Object obj)
obj - Object to compare type with.public boolean equals(java.lang.Object obj)
obj - The object to compare with.public int hashCode()
protected YangUnion cloneShallow() throws YangException
YangExceptionpublic T getValue()
public java.lang.String toString()
toString in class java.lang.Object