public class HNApplyCastOperator extends HNUnused
Explicit cast is a bare checking (equivalent to java's cast)
Implicit cast can convert one type to another using in order one of
the following methods when available. Lets take the example of casting
a of type A to class B
def B A.as(Class<B>)
B(A a)
static B cast(A a,Class<B>)
Car c=Maseratti();
Maseratti m=(Maseratti)c; //here is the explicit cast
Volvo v=(Volvo?)c; //this will return zero without exception
//this is an explicit nullable cast
double c=2.0;
int m=(int)c; //actually this is an implicit cast done
//by the jvm/java so it is considered as
//explicit cast
Car c=Maseratti();
Maseratti m=c; // here is the implicit cast
// that will check through
// the three possibilities
Note that
Car c=Maseratti();
Maseratti m=c.as(Maseratti); // here is the implicit cast
// that will check through
// the three possibilities as well
Car c=Maseratti();
Volvo m=c.as(Volvo?); // here is the implicit cast
// that will check through
// the three possibilities as well
//but will return null if unavailable cast
def sum(Complex a,Complex b){
return a+b;
}
class Complex(double real,double imag){
constructor(double real)->this(real,0);
def Complex +(Complex o)->Complex(real+o.real,imag+o.imag);
def Complex reverse_+(Complex o)->Complex(real+o.real,imag+o.imag);
}
int a=3;
var c=a+Complex(2,3); // here is an implicit cast
// that will check through
// the tree possibilities
//and will choose #2 (constructor)
Complex equivalent_c= Complex(2,3).reverse_plus(Complex((double)a));
| Constructor and Description |
|---|
HNApplyCastOperator(HNode expr,
net.thevpc.jeep.JTypeName castType,
net.thevpc.jeep.JToken startToken,
net.thevpc.jeep.JToken endToken) |
| Modifier and Type | Method and Description |
|---|---|
void |
copyFrom(net.thevpc.jeep.JNode node,
net.thevpc.jeep.JNodeCopyFactory copyFactory) |
protected void |
findAndReplaceChildren(net.thevpc.jeep.JNodeFindAndReplace findAndReplace) |
net.thevpc.jeep.JTypeName |
getCastType() |
List<net.thevpc.jeep.JNode> |
getChildrenNodes() |
HNode |
getExpr() |
HNApplyCastOperator |
setCastType(net.thevpc.jeep.JTypeName castType) |
HNApplyCastOperator |
setExpr(HNode expr) |
String |
toString() |
addAnnotationNoDuplicates, addAnnotations, addAnnotationsNoDuplicates, addModifierKeys, copy, copy, fullChildInfo, getAnnotations, getEffectiveImports, getElement, getExitPoints, getImports, getModifierKeys, getParentNode, id, removeAnnotations, setAnnotations, setElement, setImportscontainsCaret, containsCaret, copyFrom, findAndReplace, getChildInfo, getEndToken, getExitContextObject, getPosition, getPosition, getSeparators, getStartToken, getUserObjects, isExitContext, isSetUserObject, isTestAndSetUserObject, parentNode, setBounds, setChildInfo, setEndToken, setExitContextObject, setSeparators, setStartToken, setUserObject, setUserObject, setUserObject, unsetUserObject, visit, visitNext, visitNext, visitNextpublic HNApplyCastOperator(HNode expr, net.thevpc.jeep.JTypeName castType, net.thevpc.jeep.JToken startToken, net.thevpc.jeep.JToken endToken)
public net.thevpc.jeep.JTypeName getCastType()
public HNode getExpr()
public HNApplyCastOperator setExpr(HNode expr)
public HNApplyCastOperator setCastType(net.thevpc.jeep.JTypeName castType)
protected void findAndReplaceChildren(net.thevpc.jeep.JNodeFindAndReplace findAndReplace)
findAndReplaceChildren in class net.thevpc.jeep.core.nodes.AbstractJNodepublic void copyFrom(net.thevpc.jeep.JNode node,
net.thevpc.jeep.JNodeCopyFactory copyFactory)
public List<net.thevpc.jeep.JNode> getChildrenNodes()
getChildrenNodes in interface net.thevpc.jeep.JNodegetChildrenNodes in class net.thevpc.jeep.core.nodes.AbstractJNodeCopyright © 2025 vpc open source initiative. All rights reserved.