private JExpression handleElement(ElementParserBuilder builder,
RuntimeNonElement target,
Adapter<Type, Class> adapter,
Class c,
boolean nillable) {
JExpression toSet;
if (adapter != null) {
JVar adapterVar = getAdapter(adapter);
toSet = adapterVar.invoke("unmarshal").arg(builder.getXSR().invoke("getElementText"));
} else if ((c.equals(String.class)
|| c.equals(Integer.class)
|| c.equals(Double.class)
|| c.equals(Float.class)
|| c.equals(Short.class)
|| c.equals(Long.class)
|| c.equals(Boolean.class)
|| c.equals(Byte.class)
|| c.isPrimitive())
&& c != byte.class) {
toSet = builder.as(c, nillable);
} else if (c.equals(XMLGregorianCalendar.class)) {
toSet = handleXMLGregorianCalendar(builder, builder.as(String.class, nillable));
} else if (c.equals(Duration.class)) {
toSet = handleDuration(builder, builder.as(String.class, nillable));
} else if (c.isEnum()) {
try {
Method method = c.getMethod("value", new Class[0]);
Class<?> readAs = method.getReturnType();
JExpression val = handleElement(builder, target, adapter, readAs, nillable);
toSet = handleEnum(builder, val, c);
} catch (Exception e) {
throw new BuildException(e);
}