From a1131e68c98bb9eaf39fbe28ddf6e5852b9401f2 Mon Sep 17 00:00:00 2001 From: sjaakd Date: Mon, 5 Sep 2016 17:19:29 +0200 Subject: [PATCH] #689 Joda LocalTime to XmlGregorianCalendar built in and vice versa --- .../source/builtin/BuiltInMappingMethods.java | 2 + .../JodaLocalTimeToXmlGregorianCalendar.java | 74 +++++++++++++ .../XmlGregorianCalendarToJodaLocalTime.java | 64 +++++++++++ .../JodaLocalTimeToXmlGregorianCalendar.ftl | 37 +++++++ .../XmlGregorianCalendarToJodaLocalTime.ftl | 50 +++++++++ .../builtin/bean/jodatime/JodaTimeTest.java | 100 ++++++++++++++++++ .../bean/jodatime/bean/LocalTimeBean.java | 38 +++++++ .../LocalTimeToXmlGregorianCalendar.java | 39 +++++++ .../XmlGregorianCalendarToLocalTime.java | 38 +++++++ 9 files changed, 442 insertions(+) create mode 100644 processor/src/main/java/org/mapstruct/ap/internal/model/source/builtin/JodaLocalTimeToXmlGregorianCalendar.java create mode 100644 processor/src/main/java/org/mapstruct/ap/internal/model/source/builtin/XmlGregorianCalendarToJodaLocalTime.java create mode 100644 processor/src/main/resources/org/mapstruct/ap/internal/model/source/builtin/JodaLocalTimeToXmlGregorianCalendar.ftl create mode 100644 processor/src/main/resources/org/mapstruct/ap/internal/model/source/builtin/XmlGregorianCalendarToJodaLocalTime.ftl create mode 100644 processor/src/test/java/org/mapstruct/ap/test/builtin/bean/jodatime/bean/LocalTimeBean.java create mode 100644 processor/src/test/java/org/mapstruct/ap/test/builtin/bean/jodatime/mapper/LocalTimeToXmlGregorianCalendar.java create mode 100644 processor/src/test/java/org/mapstruct/ap/test/builtin/bean/jodatime/mapper/XmlGregorianCalendarToLocalTime.java diff --git a/processor/src/main/java/org/mapstruct/ap/internal/model/source/builtin/BuiltInMappingMethods.java b/processor/src/main/java/org/mapstruct/ap/internal/model/source/builtin/BuiltInMappingMethods.java index 9178318f1..b583b4d8b 100644 --- a/processor/src/main/java/org/mapstruct/ap/internal/model/source/builtin/BuiltInMappingMethods.java +++ b/processor/src/main/java/org/mapstruct/ap/internal/model/source/builtin/BuiltInMappingMethods.java @@ -63,6 +63,8 @@ public class BuiltInMappingMethods { builtInMethods.add( new XmlGregorianCalendarToJodaLocalDateTime( typeFactory ) ); builtInMethods.add( new JodaLocalDateToXmlGregorianCalendar( typeFactory ) ); builtInMethods.add( new XmlGregorianCalendarToJodaLocalDate( typeFactory ) ); + builtInMethods.add( new JodaLocalTimeToXmlGregorianCalendar( typeFactory ) ); + builtInMethods.add( new XmlGregorianCalendarToJodaLocalTime( typeFactory ) ); } } diff --git a/processor/src/main/java/org/mapstruct/ap/internal/model/source/builtin/JodaLocalTimeToXmlGregorianCalendar.java b/processor/src/main/java/org/mapstruct/ap/internal/model/source/builtin/JodaLocalTimeToXmlGregorianCalendar.java new file mode 100644 index 000000000..2f665fb0f --- /dev/null +++ b/processor/src/main/java/org/mapstruct/ap/internal/model/source/builtin/JodaLocalTimeToXmlGregorianCalendar.java @@ -0,0 +1,74 @@ +/** + * Copyright 2012-2016 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.internal.model.source.builtin; + +import static org.mapstruct.ap.internal.util.Collections.asSet; + +import java.util.Set; + +import javax.xml.datatype.DatatypeConfigurationException; +import javax.xml.datatype.DatatypeConstants; +import javax.xml.datatype.DatatypeFactory; +import javax.xml.datatype.XMLGregorianCalendar; + +import org.mapstruct.ap.internal.model.common.Parameter; +import org.mapstruct.ap.internal.model.common.Type; +import org.mapstruct.ap.internal.model.common.TypeFactory; +import org.mapstruct.ap.internal.util.JodaTimeConstants; + +/** + * @author Sjaak Derksen + */ +public class JodaLocalTimeToXmlGregorianCalendar extends BuiltInMethod { + + private final Parameter parameter; + private final Type returnType; + private final Set importTypes; + + public JodaLocalTimeToXmlGregorianCalendar(TypeFactory typeFactory) { + this.parameter = new Parameter( + "dt", + typeFactory.getType( JodaTimeConstants.LOCAL_TIME_FQN ) + ); + this.returnType = typeFactory.getType( XMLGregorianCalendar.class ); + + this.importTypes = asSet( + returnType, + parameter.getType(), + typeFactory.getType( DatatypeConstants.class ), + typeFactory.getType( DatatypeFactory.class ), + typeFactory.getType( DatatypeConfigurationException.class ) + ); + } + + @Override + public Set getImportTypes() { + return importTypes; + } + + @Override + public Parameter getParameter() { + return parameter; + } + + @Override + public Type getReturnType() { + return returnType; + } +} diff --git a/processor/src/main/java/org/mapstruct/ap/internal/model/source/builtin/XmlGregorianCalendarToJodaLocalTime.java b/processor/src/main/java/org/mapstruct/ap/internal/model/source/builtin/XmlGregorianCalendarToJodaLocalTime.java new file mode 100644 index 000000000..59ee756c7 --- /dev/null +++ b/processor/src/main/java/org/mapstruct/ap/internal/model/source/builtin/XmlGregorianCalendarToJodaLocalTime.java @@ -0,0 +1,64 @@ +/** + * Copyright 2012-2016 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.internal.model.source.builtin; + +import static org.mapstruct.ap.internal.util.Collections.asSet; + +import java.util.Set; +import javax.xml.datatype.DatatypeConstants; +import javax.xml.datatype.XMLGregorianCalendar; + +import org.mapstruct.ap.internal.model.common.Parameter; +import org.mapstruct.ap.internal.model.common.Type; +import org.mapstruct.ap.internal.model.common.TypeFactory; +import org.mapstruct.ap.internal.util.JodaTimeConstants; + +/** + * @author Sjaak Derksen + */ +public class XmlGregorianCalendarToJodaLocalTime extends BuiltInMethod { + + private final Parameter parameter; + private final Type returnType; + private final Set importTypes; + + public XmlGregorianCalendarToJodaLocalTime(TypeFactory typeFactory) { + this.parameter = new Parameter( "xcal", typeFactory.getType( XMLGregorianCalendar.class ) ); + this.returnType = typeFactory.getType( JodaTimeConstants.LOCAL_TIME_FQN ); + this.importTypes = asSet( + typeFactory.getType( DatatypeConstants.class ), + returnType, + parameter.getType() ); + } + + @Override + public Parameter getParameter() { + return parameter; + } + + @Override + public Type getReturnType() { + return returnType; + } + + @Override + public Set getImportTypes() { + return importTypes; + } +} diff --git a/processor/src/main/resources/org/mapstruct/ap/internal/model/source/builtin/JodaLocalTimeToXmlGregorianCalendar.ftl b/processor/src/main/resources/org/mapstruct/ap/internal/model/source/builtin/JodaLocalTimeToXmlGregorianCalendar.ftl new file mode 100644 index 000000000..0decf4ec3 --- /dev/null +++ b/processor/src/main/resources/org/mapstruct/ap/internal/model/source/builtin/JodaLocalTimeToXmlGregorianCalendar.ftl @@ -0,0 +1,37 @@ +<#-- + + Copyright 2012-2016 Gunnar Morling (http://www.gunnarmorling.de/) + and/or other contributors as indicated by the @authors tag. See the + copyright.txt file in the distribution for a full listing of all + contributors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> +private XMLGregorianCalendar ${name}( LocalTime dt ) { + if ( dt == null ) { + return null; + } + + try { + return DatatypeFactory.newInstance().newXMLGregorianCalendarTime( + dt.getHourOfDay(), + dt.getMinuteOfHour(), + dt.getSecondOfMinute(), + dt.getMillisOfSecond(), + DatatypeConstants.FIELD_UNDEFINED ); + } + catch ( DatatypeConfigurationException ex ) { + throw new RuntimeException( ex ); + } +} \ No newline at end of file diff --git a/processor/src/main/resources/org/mapstruct/ap/internal/model/source/builtin/XmlGregorianCalendarToJodaLocalTime.ftl b/processor/src/main/resources/org/mapstruct/ap/internal/model/source/builtin/XmlGregorianCalendarToJodaLocalTime.ftl new file mode 100644 index 000000000..13e53bb13 --- /dev/null +++ b/processor/src/main/resources/org/mapstruct/ap/internal/model/source/builtin/XmlGregorianCalendarToJodaLocalTime.ftl @@ -0,0 +1,50 @@ +<#-- + + Copyright 2012-2016 Gunnar Morling (http://www.gunnarmorling.de/) + and/or other contributors as indicated by the @authors tag. See the + copyright.txt file in the distribution for a full listing of all + contributors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--> +private static LocalTime ${name}( XMLGregorianCalendar xcal ) { + if ( xcal == null ) { + return null; + } + + if ( xcal.getHour() != DatatypeConstants.FIELD_UNDEFINED + && xcal.getMinute() != DatatypeConstants.FIELD_UNDEFINED ) { + if ( xcal.getSecond() != DatatypeConstants.FIELD_UNDEFINED + && xcal.getMillisecond() != DatatypeConstants.FIELD_UNDEFINED ) { + return new LocalTime( xcal.getHour(), + xcal.getMinute(), + xcal.getSecond(), + xcal.getMillisecond() + ); + } + else if ( xcal.getSecond() != DatatypeConstants.FIELD_UNDEFINED ) { + return new LocalTime( + xcal.getHour(), + xcal.getMinute(), + xcal.getSecond() + ); + } + else { + return new LocalTime( xcal.getHour(), + xcal.getMinute() + ); + } + } + return null; +} \ No newline at end of file diff --git a/processor/src/test/java/org/mapstruct/ap/test/builtin/bean/jodatime/JodaTimeTest.java b/processor/src/test/java/org/mapstruct/ap/test/builtin/bean/jodatime/JodaTimeTest.java index aec9ee13e..791f02f8a 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/builtin/bean/jodatime/JodaTimeTest.java +++ b/processor/src/test/java/org/mapstruct/ap/test/builtin/bean/jodatime/JodaTimeTest.java @@ -27,18 +27,22 @@ import org.joda.time.DateTime; import org.joda.time.DateTimeZone; import org.joda.time.LocalDate; import org.joda.time.LocalDateTime; +import org.joda.time.LocalTime; import org.junit.Test; import org.junit.runner.RunWith; import org.mapstruct.ap.test.builtin.bean.jodatime.bean.DateTimeBean; import org.mapstruct.ap.test.builtin.bean.jodatime.bean.LocalDateBean; import org.mapstruct.ap.test.builtin.bean.jodatime.bean.LocalDateTimeBean; +import org.mapstruct.ap.test.builtin.bean.jodatime.bean.LocalTimeBean; import org.mapstruct.ap.test.builtin.bean.jodatime.bean.XmlGregorianCalendarBean; import org.mapstruct.ap.test.builtin.bean.jodatime.mapper.DateTimeToXmlGregorianCalendar; import org.mapstruct.ap.test.builtin.bean.jodatime.mapper.LocalDateTimeToXmlGregorianCalendar; import org.mapstruct.ap.test.builtin.bean.jodatime.mapper.LocalDateToXmlGregorianCalendar; +import org.mapstruct.ap.test.builtin.bean.jodatime.mapper.LocalTimeToXmlGregorianCalendar; import org.mapstruct.ap.test.builtin.bean.jodatime.mapper.XmlGregorianCalendarToDateTime; import org.mapstruct.ap.test.builtin.bean.jodatime.mapper.XmlGregorianCalendarToLocalDate; import org.mapstruct.ap.test.builtin.bean.jodatime.mapper.XmlGregorianCalendarToLocalDateTime; +import org.mapstruct.ap.test.builtin.bean.jodatime.mapper.XmlGregorianCalendarToLocalTime; import org.mapstruct.ap.testutil.IssueKey; import org.mapstruct.ap.testutil.WithClasses; import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner; @@ -49,6 +53,7 @@ import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner; */ @WithClasses({ DateTimeBean.class, + LocalTimeBean.class, LocalDateBean.class, LocalDateTimeBean.class, XmlGregorianCalendarBean.class @@ -447,4 +452,99 @@ public class JodaTimeTest { assertThat( res.getLocalDate() ).isNull(); } + + + + + + + + @Test + @WithClasses(LocalTimeToXmlGregorianCalendar.class) + public void shouldMapIncompleteLocalTimeToXmlGregorianCalendar() { + + LocalTimeBean in = new LocalTimeBean(); + LocalTime dt = new LocalTime( 1, 1, 0, 100 ); + in.setLocalTime( dt ); + XmlGregorianCalendarBean res = LocalTimeToXmlGregorianCalendar.INSTANCE.toXmlGregorianCalendarBean( in ); + + assertThat( res.getxMLGregorianCalendar().getYear() ).isEqualTo( DatatypeConstants.FIELD_UNDEFINED ); + assertThat( res.getxMLGregorianCalendar().getMonth() ).isEqualTo( DatatypeConstants.FIELD_UNDEFINED ); + assertThat( res.getxMLGregorianCalendar().getDay() ).isEqualTo( DatatypeConstants.FIELD_UNDEFINED ); + assertThat( res.getxMLGregorianCalendar().getHour() ).isEqualTo( 1 ); + assertThat( res.getxMLGregorianCalendar().getMinute() ).isEqualTo( 1 ); + assertThat( res.getxMLGregorianCalendar().getSecond() ).isEqualTo( 0 ); + assertThat( res.getxMLGregorianCalendar().getMillisecond() ).isEqualTo( 100 ); + assertThat( res.getxMLGregorianCalendar().getTimezone() ).isEqualTo( DatatypeConstants.FIELD_UNDEFINED ); + } + + @Test + @WithClasses(XmlGregorianCalendarToLocalTime.class) + public void shouldMapXmlGregorianCalendarToLocalTime() throws Exception { + + XmlGregorianCalendarBean in = new XmlGregorianCalendarBean(); + XMLGregorianCalendar xcal = + DatatypeFactory.newInstance().newXMLGregorianCalendarTime( 1, 1, 1, 100, 60 ); + in.setxMLGregorianCalendar( xcal ); + + LocalTimeBean res = XmlGregorianCalendarToLocalTime.INSTANCE.toLocalTimeBean( in ); + assertThat( res.getLocalTime().getHourOfDay() ).isEqualTo( 1 ); + assertThat( res.getLocalTime().getMinuteOfHour() ).isEqualTo( 1 ); + assertThat( res.getLocalTime().getSecondOfMinute() ).isEqualTo( 1 ); + assertThat( res.getLocalTime().getMillisOfSecond() ).isEqualTo( 100 ); + } + + @Test + @WithClasses(XmlGregorianCalendarToLocalTime.class) + public void shouldMapXmlGregorianCalendarWithoutMillisToLocalTime() throws Exception { + + XmlGregorianCalendarBean in = new XmlGregorianCalendarBean(); + XMLGregorianCalendar xcal = DatatypeFactory.newInstance().newXMLGregorianCalendar(); + xcal.setHour( 23 ); + xcal.setMinute( 34 ); + xcal.setSecond( 45 ); + in.setxMLGregorianCalendar( xcal ); + + LocalTimeBean res = XmlGregorianCalendarToLocalTime.INSTANCE.toLocalTimeBean( in ); + assertThat( res.getLocalTime().getHourOfDay() ).isEqualTo( 23 ); + assertThat( res.getLocalTime().getMinuteOfHour() ).isEqualTo( 34 ); + assertThat( res.getLocalTime().getSecondOfMinute() ).isEqualTo( 45 ); + assertThat( res.getLocalTime().getMillisOfSecond() ).isEqualTo( 0 ); + } + + @Test + @WithClasses(XmlGregorianCalendarToLocalTime.class) + public void shouldMapXmlGregorianCalendarWithoutSecondsToLocalTime() throws Exception { + + XmlGregorianCalendarBean in = new XmlGregorianCalendarBean(); + XMLGregorianCalendar xcal = DatatypeFactory.newInstance().newXMLGregorianCalendar(); + xcal.setHour( 23 ); + xcal.setMinute( 34 ); + xcal.setTimezone( 60 ); + in.setxMLGregorianCalendar( xcal ); + + LocalTimeBean res = XmlGregorianCalendarToLocalTime.INSTANCE.toLocalTimeBean( in ); + assertThat( res.getLocalTime().getHourOfDay() ).isEqualTo( 23 ); + assertThat( res.getLocalTime().getMinuteOfHour() ).isEqualTo( 34 ); + assertThat( res.getLocalTime().getSecondOfMinute() ).isEqualTo( 0 ); + assertThat( res.getLocalTime().getMillisOfSecond() ).isEqualTo( 0 ); + } + + @Test + @WithClasses(XmlGregorianCalendarToLocalTime.class) + public void shouldNotMapXmlGregorianCalendarWithoutMinutesToLocalTime() throws Exception { + + XmlGregorianCalendarBean in = new XmlGregorianCalendarBean(); + XMLGregorianCalendar xcal = DatatypeFactory.newInstance().newXMLGregorianCalendar(); + xcal.setYear( 1999 ); + xcal.setMonth( 5 ); + xcal.setDay( 25 ); + xcal.setHour( 23 ); + in.setxMLGregorianCalendar( xcal ); + + LocalTimeBean res = XmlGregorianCalendarToLocalTime.INSTANCE.toLocalTimeBean( in ); + assertThat( res.getLocalTime() ).isNull(); + + } + } diff --git a/processor/src/test/java/org/mapstruct/ap/test/builtin/bean/jodatime/bean/LocalTimeBean.java b/processor/src/test/java/org/mapstruct/ap/test/builtin/bean/jodatime/bean/LocalTimeBean.java new file mode 100644 index 000000000..ea7f0c396 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/builtin/bean/jodatime/bean/LocalTimeBean.java @@ -0,0 +1,38 @@ +/** + * Copyright 2012-2016 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.test.builtin.bean.jodatime.bean; + +import org.joda.time.LocalTime; + +/** + * + * @author Sjaak Derksen + */ +public class LocalTimeBean { + + private LocalTime localTime; + + public LocalTime getLocalTime() { + return localTime; + } + + public void setLocalTime(LocalTime localTime) { + this.localTime = localTime; + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/builtin/bean/jodatime/mapper/LocalTimeToXmlGregorianCalendar.java b/processor/src/test/java/org/mapstruct/ap/test/builtin/bean/jodatime/mapper/LocalTimeToXmlGregorianCalendar.java new file mode 100644 index 000000000..8c93b13b0 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/builtin/bean/jodatime/mapper/LocalTimeToXmlGregorianCalendar.java @@ -0,0 +1,39 @@ +/** + * Copyright 2012-2016 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.test.builtin.bean.jodatime.mapper; + +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.ap.test.builtin.bean.jodatime.bean.LocalTimeBean; +import org.mapstruct.ap.test.builtin.bean.jodatime.bean.XmlGregorianCalendarBean; +import org.mapstruct.factory.Mappers; + +/** + * + * @author Sjaak Derksen + */ +@Mapper +public interface LocalTimeToXmlGregorianCalendar { + + LocalTimeToXmlGregorianCalendar INSTANCE = Mappers.getMapper( LocalTimeToXmlGregorianCalendar.class ); + + @Mapping( target = "xMLGregorianCalendar", source = "localTime") + XmlGregorianCalendarBean toXmlGregorianCalendarBean( LocalTimeBean in ); + +} diff --git a/processor/src/test/java/org/mapstruct/ap/test/builtin/bean/jodatime/mapper/XmlGregorianCalendarToLocalTime.java b/processor/src/test/java/org/mapstruct/ap/test/builtin/bean/jodatime/mapper/XmlGregorianCalendarToLocalTime.java new file mode 100644 index 000000000..230bee1d5 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/test/builtin/bean/jodatime/mapper/XmlGregorianCalendarToLocalTime.java @@ -0,0 +1,38 @@ +/** + * Copyright 2012-2016 Gunnar Morling (http://www.gunnarmorling.de/) + * and/or other contributors as indicated by the @authors tag. See the + * copyright.txt file in the distribution for a full listing of all + * contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mapstruct.ap.test.builtin.bean.jodatime.mapper; + +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.ap.test.builtin.bean.jodatime.bean.LocalTimeBean; +import org.mapstruct.ap.test.builtin.bean.jodatime.bean.XmlGregorianCalendarBean; +import org.mapstruct.factory.Mappers; + +/** + * + * @author Sjaak Derksen + */ +@Mapper +public interface XmlGregorianCalendarToLocalTime { + + XmlGregorianCalendarToLocalTime INSTANCE = Mappers.getMapper( XmlGregorianCalendarToLocalTime.class ); + + @Mapping( target = "localTime", source = "xMLGregorianCalendar" ) + LocalTimeBean toLocalTimeBean( XmlGregorianCalendarBean in ); +}