Down-casts the item to specified type.
Namespace: com.mindfusion.diagramming
Package: com.mindfusion.diagramming
SyntaxJava
Copy Code
|
|---|
public <T> T as ( |
A Class instance specifying the target type.
This item cast to specified type, or null if it's of a different type.
RemarksSyntax sugar for a slightly shorter type checking and casting.
ExampleJava
Copy Code
|
|---|
| public void nodeCreated(NodeEvent e) { ContainerNode container = e.getNode().as(ContainerNode.class); if (container != null) { ... } } // alternative to public void nodeCreated(NodeEvent e) { if (e.getNode() instanceof ContainerNode) { ContainerNode container = (ContainerNode)e.getNode(); ... } } |
See Also