com.javaetmoi.javabean.generator.XmlGregorianCalendarCodeGenerator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of javaetmoi-javabean-marshaller Show documentation
Show all versions of javaetmoi-javabean-marshaller Show documentation
The JavaBeanMarshaller class is responsible for serializing an object (graph) to it's Java code.
package com.javaetmoi.javabean.generator;
import com.javaetmoi.javabean.bean.SetterParam;
import com.javaetmoi.javabean.util.JavapoetHelper;
import com.squareup.javapoet.MethodSpec;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;
public class XmlGregorianCalendarCodeGenerator extends DefaultCodeGenerator {
@Override
public void generateSetter(MethodSpec.Builder method, SetterParam param) {
XMLGregorianCalendar cal = getValue(param);
int year = cal.getYear();
int month = cal.getMonth();
int day = cal.getDay();
int hour = cal.getHour();
int minute = cal.getMinute();
int second = cal.getSecond();
int millis = cal.getMillisecond();
int timezone = cal.getTimezone();
method.addStatement("$L.$L($T.newInstance().newXMLGregorianCalendar($L, $L, $L, $L, $L, $L, $L, $L))", param.getVarName(), param.getSetterName(), DatatypeFactory.class, year, month, day, hour, minute, second, millis, timezone);
JavapoetHelper.addExceptionIfNotDeclared(method, DatatypeConfigurationException.class);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy