public class UnionType extends Type
Modifier and Type | Class and Description |
---|---|
static class |
UnionType.Member
Represent a member.
|
Constructor and Description |
---|
UnionType(NamespaceKey key)
Constructor.
|
UnionType(java.lang.String name)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addMember(UnionType.Member member)
Add a Member.
|
boolean |
areEqual(java.lang.Object value1,
java.lang.Object value2)
Return true if two values are considered as equal for this type.
|
void |
clearMembers()
Clear the members of the union.
|
java.util.List<java.lang.Object> |
copyValue(java.lang.Object value)
Copy the current value and return it.
|
int |
countMembers()
Return the number of members.
|
boolean |
equals(java.lang.Object obj) |
java.util.List<java.lang.Object> |
getDefaultValue()
Return the type default value.
|
UnionType |
getExtendedType()
Return the type that this type extends.
|
java.lang.Object |
getInstanceFromValue(java.lang.Object value,
java.lang.Class<?> clazz)
Return a value as an instance of a class.
|
UnionType.Member |
getMember(int variant)
Return the Member at a specified position.
|
UnionType.Member |
getMember(java.lang.String name)
Return the Member of a specified name.
|
java.util.Map<java.lang.String,UnionType.Member> |
getMembers()
Return the members sorted by their name.
|
java.util.List<UnionType.Member> |
getMembersList()
Return the ordered list of members.
|
Type |
getMemberType(java.util.List<java.lang.Object> value)
Return the member type.
|
java.lang.Object |
getMemberValue(java.util.List<java.lang.Object> value)
Return the member value.
|
int |
getMemberVariant(java.util.List<java.lang.Object> value)
Return the member variant.
|
int |
getMemberVariant(java.lang.String name)
Return the variantType of a specified Member.
|
java.util.List<java.lang.Object> |
getNonEmptyDefaultValue()
Return a non empty type default value.
|
Data.Union |
getValueAsData(java.lang.Object value)
Return a value as a Data.
|
java.lang.String |
getValueAsString(java.lang.Object value)
Return a value as a String.
|
java.lang.Object |
getValueFromInstance(java.lang.Object instance)
Return a value as an instance object.
|
SimpleType |
getVariant()
Return the type of the Union variantType.
|
static UnionType |
getVoid()
Return an empty Union type, which contains no members.
|
int |
hashCode() |
boolean |
hasMember(java.lang.String name)
Return true if the Union has a member of a specified name.
|
boolean |
isAbstract()
Return true if the type is abstract.
|
boolean |
isSupportingValue(java.lang.Object value)
Return true if the specified value is supported.
|
void |
lockDefinition()
Lock the fields definition of this type.
|
void |
setAbstract(boolean isAbstract)
Set if the type is abstract.
|
void |
setExtendedType(UnionType type)
Set the type that this type extends.
|
boolean |
setMemberValue(int variant,
java.util.List<java.lang.Object> values)
Set the default value of the Union for a specified variantType.
|
boolean |
setMemberValue(int variant,
java.util.List<java.lang.Object> values,
java.lang.Object value)
Set the value of the Union for a specified variantType.
|
boolean |
setMemberValue(java.lang.String name,
java.util.List<java.lang.Object> values)
Set the default value of the Union for a specified variantType.
|
boolean |
setMemberValue(java.lang.String name,
java.util.List<java.lang.Object> values,
java.lang.Object value)
Set the value of the Union for a specified variantType.
|
void |
setVariant(SimpleType variant)
Set the type of the Union variantType.
|
createData, getDefaultValue, getDescription, getKey, getName, getNamespace, getNamespaceAsString, getTerminalType, getUnit, getValueAsBoolean, getValueAsByte, getValueAsChar, getValueAsDouble, getValueAsDouble, getValueAsFloat, getValueAsFloat, getValueAsInt, getValueAsInt, getValueAsLong, getValueAsLong, getValueAsShort, setDescription, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getFullName
public UnionType(java.lang.String name)
name
- the type namepublic UnionType(NamespaceKey key)
key
- the type keypublic static UnionType getVoid()
public void setAbstract(boolean isAbstract)
isAbstract
- true if the type is abstractpublic boolean isAbstract()
isAbstract
in class Type
public void setExtendedType(UnionType type)
type
- the typepublic UnionType getExtendedType()
getExtendedType
in class Type
public void setVariant(SimpleType variant)
variant
- the type of the Union variantTypepublic SimpleType getVariant()
public java.util.List<java.lang.Object> getDefaultValue()
getDefaultValue
in class Type
public java.util.List<java.lang.Object> getNonEmptyDefaultValue()
getNonEmptyDefaultValue
in class Type
public boolean areEqual(java.lang.Object value1, java.lang.Object value2)
public int getMemberVariant(java.util.List<java.lang.Object> value)
value
- the union valuepublic java.lang.Object getMemberValue(java.util.List<java.lang.Object> value)
value
- the union valuepublic java.lang.Object getValueFromInstance(java.lang.Object instance)
getValueFromInstance
in class Type
instance
- the instance objectpublic java.lang.Object getInstanceFromValue(java.lang.Object value, java.lang.Class<?> clazz)
getInstanceFromValue
in class Type
value
- the valueclazz
- the classpublic Data.Union getValueAsData(java.lang.Object value)
getValueAsData
in class Type
value
- the valuepublic Type getMemberType(java.util.List<java.lang.Object> value)
value
- the union valuepublic boolean setMemberValue(java.lang.String name, java.util.List<java.lang.Object> values, java.lang.Object value)
name
- the member namevalues
- the valuesvalue
- the member valuepublic boolean setMemberValue(java.lang.String name, java.util.List<java.lang.Object> values)
name
- the member namevalues
- the valuespublic boolean setMemberValue(int variant, java.util.List<java.lang.Object> values)
variant
- the variantTypevalues
- the valuespublic boolean setMemberValue(int variant, java.util.List<java.lang.Object> values, java.lang.Object value)
variant
- the variantTypevalues
- the valuesvalue
- the member valuepublic java.util.List<java.lang.Object> copyValue(java.lang.Object value)
public java.lang.String getValueAsString(java.lang.Object value)
getValueAsString
in class Type
value
- the valuepublic boolean isSupportingValue(java.lang.Object value)
isSupportingValue
in class Type
value
- the valuepublic void lockDefinition()
public void clearMembers()
public boolean hasMember(java.lang.String name)
name
- the members namepublic int countMembers()
public java.util.Map<java.lang.String,UnionType.Member> getMembers()
public java.util.List<UnionType.Member> getMembersList()
public UnionType.Member getMember(int variant)
variant
- the variantTypepublic UnionType.Member getMember(java.lang.String name)
name
- the Member namepublic int getMemberVariant(java.lang.String name)
name
- the Member namepublic void addMember(UnionType.Member member)
member
- the Memberpublic int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
Copyright ©2017-2023 Dassault Aviation. All Rights Reserved. Documentation and source under the LGPL v3 licence