All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.javaetmoi.javabean.generator.XmlGregorianCalendarCodeGenerator Maven / Gradle / Ivy

Go to download

The JavaBeanMarshaller class is responsible for serializing an object (graph) to it's Java code.

There is a newer version: 1.0.3
Show newest version
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