JBlock block = currentBlock._if(objectVar.ne(JExpr._null()))._then();
if (cls.equals(String.class)) {
writeAs(block, objectVar);
} else if (cls.equals(int.class) || cls.equals(Integer.class)) {
JClass jc = (JClass) model._ref(Integer.class);
writeAs(block, jc.staticInvoke("toString").arg(objectVar));
} else if (cls.equals(boolean.class) || cls.equals(Boolean.class)) {
JClass jc = (JClass) model._ref(Boolean.class);
writeAs(block, jc.staticInvoke("toString").arg(objectVar));
} else if (cls.equals(short.class) || cls.equals(Short.class)) {
JClass jc = (JClass) model._ref(Short.class);
writeAs(block, jc.staticInvoke("toString").arg(objectVar));
} else if (cls.equals(double.class) || cls.equals(Double.class)) {
JClass jc = (JClass) model._ref(Double.class);
writeAs(block, jc.staticInvoke("toString").arg(objectVar));
} else if (cls.equals(long.class) || cls.equals(Long.class)) {
JClass jc = (JClass) model._ref(Long.class);
writeAs(block, jc.staticInvoke("toString").arg(objectVar));
} else if (cls.equals(float.class) || cls.equals(Float.class)) {
JClass jc = (JClass) model._ref(Float.class);
writeAs(block, jc.staticInvoke("toString").arg(objectVar));
} else if (cls.equals(byte.class) || cls.equals(Byte.class)) {
JClass jc = (JClass) model._ref(Byte.class);
writeAs(block, jc.staticInvoke("toString").arg(objectVar));
} else {
throw new UnsupportedOperationException();
}
}