A trait is an interface that may or may not have default implementations of its methods, properties and fields.
Remarks
Note: This is a deprecated alias for Interface.
Traits have very specific rules in case two traits with the same member are implemented by a subtype:
- If both method definitions are abstract, then the method is abstract.
- If one method definition is abstract and the other concrete, then the concrete method is used.
- If both method definitions are concrete and the traits are implemented at the same level, then the method is abstract.
- If both method definitions are concrete and one of the traits is a sub-type of the other, then its method definition will be used.
In all of those cases, the rule is that a subtype overrides the parent types' definitions. Example: Given the traits A, B, C and D where A defines a method "a" to be abstract and B and C extending trait A with concrete implementations of "a", when D is a trait that implements both B and C, its version of "a" will be abstract, unless it defines its own implementation of "a", in which case that definition is used.
All trait types have a $class
property, which contains their type, and a static isTrait method that can be used to test whether an object implements the trait.
Type Details
- yfiles module
- lang
- yfiles-umd modules
- All modules
- Legacy UMD name
- yfiles.lang.Trait
Static Methods
Tests whether the given object is a trait.
Remarks
obj.$class.isTrait
but safe in case the object does not have a $class
property.Parameters
A map of options to pass to the method.
- o - Object
- The trait candidate.
Returns
- ↪boolean
true
, if the object is a trait;false
otherwise.