mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#135 first attempt, UT based on scope AND name now
This commit is contained in:
parent
093019b5d9
commit
4d22ff7abd
@ -18,6 +18,7 @@
|
||||
*/
|
||||
package org.mapstruct.ap.prism;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElementDecl;
|
||||
import net.java.dev.hickory.prism.GeneratePrism;
|
||||
import net.java.dev.hickory.prism.GeneratePrisms;
|
||||
|
||||
@ -39,7 +40,10 @@ import org.mapstruct.Mappings;
|
||||
@GeneratePrism(value = Mappings.class, publicAccess = true),
|
||||
@GeneratePrism(value = IterableMapping.class, publicAccess = true),
|
||||
@GeneratePrism(value = MapMapping.class, publicAccess = true),
|
||||
@GeneratePrism(value = MappingTarget.class, publicAccess = true)
|
||||
@GeneratePrism(value = MappingTarget.class, publicAccess = true),
|
||||
|
||||
// external types
|
||||
@GeneratePrism(value = XmlElementDecl.class, publicAccess = true)
|
||||
})
|
||||
public class PrismGenerator {
|
||||
|
||||
|
@ -65,6 +65,7 @@ import org.mapstruct.ap.model.source.builtin.BuiltInMethod;
|
||||
import org.mapstruct.ap.option.Options;
|
||||
import org.mapstruct.ap.option.ReportingPolicy;
|
||||
import org.mapstruct.ap.prism.MapperPrism;
|
||||
import org.mapstruct.ap.prism.XmlElementDeclPrism;
|
||||
import org.mapstruct.ap.util.Executables;
|
||||
import org.mapstruct.ap.util.Filters;
|
||||
import org.mapstruct.ap.util.Strings;
|
||||
@ -583,9 +584,7 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Sourc
|
||||
String dateFormat) {
|
||||
Type sourceType = typeFactory.getReturnType( sourceAccessor );
|
||||
Type targetType = null;
|
||||
String conversionString = null;
|
||||
conversionString = parameter.getName() + "." + sourceAccessor.getSimpleName().toString() + "()";
|
||||
|
||||
String conversionString = parameter.getName() + "." + sourceAccessor.getSimpleName().toString() + "()";
|
||||
if ( Executables.isSetterMethod( targetAcessor ) ) {
|
||||
targetType = typeFactory.getSingleParameter( targetAcessor ).getType();
|
||||
}
|
||||
@ -593,6 +592,8 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Sourc
|
||||
targetType = typeFactory.getReturnType( targetAcessor );
|
||||
}
|
||||
|
||||
String targetPropertyName = Executables.getPropertyName( targetAcessor );
|
||||
|
||||
String mappedElement = "property '" + Executables.getPropertyName( sourceAccessor ) + "'";
|
||||
MethodReference mappingMethodReference = getMappingMethodReference(
|
||||
method,
|
||||
@ -601,6 +602,7 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Sourc
|
||||
methods,
|
||||
sourceType,
|
||||
targetType,
|
||||
targetPropertyName,
|
||||
dateFormat
|
||||
);
|
||||
|
||||
@ -655,6 +657,7 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Sourc
|
||||
methods,
|
||||
sourceElementType,
|
||||
targetElementType,
|
||||
null, // there is no targetPropertyName
|
||||
dateFormat
|
||||
);
|
||||
|
||||
@ -697,6 +700,7 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Sourc
|
||||
methods,
|
||||
keySourceType,
|
||||
keyTargetType,
|
||||
null, // there is no targetPropertyName
|
||||
keyDateFormat
|
||||
);
|
||||
TypeConversion keyConversion = getConversion( keySourceType, keyTargetType, keyDateFormat, "entry.getKey()" );
|
||||
@ -725,6 +729,7 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Sourc
|
||||
methods,
|
||||
valueSourceType,
|
||||
valueTargetType,
|
||||
null, // there is no targetPropertyName
|
||||
valueDateFormat
|
||||
);
|
||||
TypeConversion valueConversion = getConversion(
|
||||
@ -907,12 +912,23 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Sourc
|
||||
/**
|
||||
* Returns a reference to a method mapping the given source type to the given target type, if such a method exists.
|
||||
*/
|
||||
private MethodReference getMappingMethodReference(SourceMethod method, String mappedElement,
|
||||
private MethodReference getMappingMethodReference(SourceMethod method,
|
||||
String mappedElement,
|
||||
List<MapperReference> mapperReferences,
|
||||
List<SourceMethod> methods, Type sourceType, Type targetType,
|
||||
List<SourceMethod> methods,
|
||||
Type sourceType,
|
||||
Type targetType,
|
||||
String targetPropertyName,
|
||||
String dateFormat) {
|
||||
// first try to find a matching source method
|
||||
SourceMethod matchingSourceMethod = getBestMatch( method, mappedElement, methods, sourceType, targetType );
|
||||
SourceMethod matchingSourceMethod = getBestMatch(
|
||||
method,
|
||||
mappedElement,
|
||||
methods,
|
||||
sourceType,
|
||||
targetType,
|
||||
targetPropertyName
|
||||
);
|
||||
|
||||
if ( matchingSourceMethod != null ) {
|
||||
return getMappingMethodReference( matchingSourceMethod, mapperReferences );
|
||||
@ -924,16 +940,20 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Sourc
|
||||
mappedElement,
|
||||
builtInMethods.getBuiltInMethods(),
|
||||
sourceType,
|
||||
targetType
|
||||
targetType,
|
||||
targetPropertyName
|
||||
);
|
||||
|
||||
return matchingBuiltInMethod != null ?
|
||||
getMappingMethodReference( matchingBuiltInMethod, targetType, dateFormat ) : null;
|
||||
}
|
||||
|
||||
private <T extends Method> T getBestMatch(SourceMethod mappingMethod, String mappedElement,
|
||||
Iterable<T> methods, Type parameterType,
|
||||
Type returnType) {
|
||||
private <T extends Method> T getBestMatch(SourceMethod mappingMethod,
|
||||
String mappedElement,
|
||||
Iterable<T> methods,
|
||||
Type parameterType,
|
||||
Type returnType,
|
||||
String targetPropertyName) {
|
||||
List<T> candidatesWithMathingTargetType = new ArrayList<T>();
|
||||
|
||||
for ( T method : methods ) {
|
||||
@ -965,6 +985,17 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Sourc
|
||||
|
||||
// print a warning if we find more than one method with minimum getParameter type distance
|
||||
if ( candidatesWithBestMatchingSourceType.size() > 1 ) {
|
||||
|
||||
// OK, we have more candidats. Lets see if we can use additional criteria to determine which is better
|
||||
T result = getBestMatchBasedOnXmlElementDecl(
|
||||
candidatesWithMathingTargetType,
|
||||
mappingMethod,
|
||||
targetPropertyName
|
||||
);
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
|
||||
messager.printMessage(
|
||||
Kind.ERROR,
|
||||
String.format(
|
||||
@ -1177,4 +1208,39 @@ public class MapperCreationProcessor implements ModelElementProcessor<List<Sourc
|
||||
|
||||
return alternativeTargetAccessorsMethods;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method uses the {@link javax.xml.bind.annotation.XmlElementDecl } annotation to determine if the scope
|
||||
* of the mapping method matches the mapper method
|
||||
* @param <T> can be SourceMethod or BuildInType. Only SourceMethods qualify
|
||||
* @param candidates list with potential matches
|
||||
* @param mapperMethod mapper method for which this is analyzed
|
||||
* @param targetPropertyName the property name of the target
|
||||
* @return a method (always SourceMethod) when there's a scope that matches
|
||||
*/
|
||||
private <T extends Method> T getBestMatchBasedOnXmlElementDecl(
|
||||
List<T> candidates,
|
||||
SourceMethod mapperMethod,
|
||||
String targetPropertyName) {
|
||||
for (T candidate : candidates ) {
|
||||
if (candidate instanceof SourceMethod) {
|
||||
SourceMethod candiateMethod = (SourceMethod) candidate;
|
||||
XmlElementDeclPrism xmlElememtDecl =
|
||||
XmlElementDeclPrism.getInstanceOn( candiateMethod.getExecutable() );
|
||||
if ( xmlElememtDecl != null ) {
|
||||
String name = xmlElememtDecl.name();
|
||||
TypeMirror scope = xmlElememtDecl.scope();
|
||||
TypeMirror target = mapperMethod.getExecutable().getReturnType();
|
||||
if ( scope != null && typeUtils.isSameType( scope, target ) ) {
|
||||
if ( ( name != null ) && ( name.equals( targetPropertyName ) ) ) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,78 @@
|
||||
/**
|
||||
* Copyright 2012-2014 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.jaxb.selection;
|
||||
|
||||
import org.mapstruct.ap.test.jaxb.selection.test1.OrderType;
|
||||
import org.mapstruct.ap.test.jaxb.selection.test2.OrderShippingDetailsType;
|
||||
import org.mapstruct.ap.test.jaxb.selection.test2.ObjectFactory;
|
||||
import org.mapstruct.ap.testutil.IssueKey;
|
||||
import org.mapstruct.ap.testutil.MapperTestBase;
|
||||
import org.mapstruct.ap.testutil.WithClasses;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
import static org.fest.assertions.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author Sjaak Derksen
|
||||
*/
|
||||
@IssueKey("135")
|
||||
@WithClasses({ org.mapstruct.ap.test.jaxb.selection.test1.ObjectFactory.class, ObjectFactory.class,
|
||||
OrderDto.class, OrderShippingDetailsDto.class, OrderType.class, OrderShippingDetailsType.class,
|
||||
SourceTargetMapper.class
|
||||
})
|
||||
public class JaxbFactoryMethodSelectionTest extends MapperTestBase {
|
||||
|
||||
|
||||
@Test
|
||||
public void shouldMatchOnNameAndOrScope() {
|
||||
OrderType target = SourceTargetMapper.INSTANCE.targetToSource( createSource() );
|
||||
|
||||
// qname and value should match for orderNumbers (distinct 1, 2)
|
||||
assertThat( target.getOrderNumber1().getValue() ).isEqualTo( 15L );
|
||||
assertThat( target.getOrderNumber1().getName() ).isEqualTo(
|
||||
org.mapstruct.ap.test.jaxb.selection.test1.ObjectFactory.ORDER_TYPE_ORDER_NUMBER1_QNAME );
|
||||
assertThat( target.getOrderNumber2().getValue() ).isEqualTo( 31L );
|
||||
assertThat( target.getOrderNumber2().getName() ).isEqualTo(
|
||||
org.mapstruct.ap.test.jaxb.selection.test1.ObjectFactory.ORDER_TYPE_ORDER_NUMBER2_QNAME );
|
||||
|
||||
// qname should match for shipping details
|
||||
assertThat( target.getShippingDetails().getName() ).isEqualTo(
|
||||
org.mapstruct.ap.test.jaxb.selection.test1.ObjectFactory.ORDER_TYPE_SHIPPING_DETAILS_QNAME );
|
||||
|
||||
OrderShippingDetailsType shippingDetals = target.getShippingDetails().getValue();
|
||||
|
||||
// qname and value should match (ObjectFactory = test2.ObjectFactory)
|
||||
assertThat( shippingDetals.getOrderShippedFrom().getValue() ).isEqualTo( "from" );
|
||||
assertThat( shippingDetals.getOrderShippedFrom().getName() ).isEqualTo(
|
||||
ObjectFactory.ORDER_SHIPPING_DETAILS_TYPE_ORDER_SHIPPED_FROM_QNAME );
|
||||
assertThat( shippingDetals.getOrderShippedTo().getValue() ).isEqualTo( "to" );
|
||||
assertThat( shippingDetals.getOrderShippedTo().getName() ).isEqualTo(
|
||||
ObjectFactory.ORDER_SHIPPING_DETAILS_TYPE_ORDER_SHIPPED_TO_QNAME );
|
||||
}
|
||||
|
||||
private OrderDto createSource() {
|
||||
OrderDto order = new OrderDto();
|
||||
order.setShippingDetails( new OrderShippingDetailsDto() );
|
||||
order.setOrderNumber1( 15L );
|
||||
order.setOrderNumber2( 31L );
|
||||
order.getShippingDetails().setOrderShippedFrom( "from" );
|
||||
order.getShippingDetails().setOrderShippedTo( "to" );
|
||||
return order;
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
/**
|
||||
* Copyright 2012-2014 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.jaxb.selection;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sjaak Derksen
|
||||
*/
|
||||
public class OrderDto {
|
||||
|
||||
private Long orderNumber1;
|
||||
private Long orderNumber2;
|
||||
private OrderShippingDetailsDto shippingDetails;
|
||||
|
||||
public Long getOrderNumber1() {
|
||||
return orderNumber1;
|
||||
}
|
||||
|
||||
public void setOrderNumber1( Long orderNumber1 ) {
|
||||
this.orderNumber1 = orderNumber1;
|
||||
}
|
||||
|
||||
public Long getOrderNumber2() {
|
||||
return orderNumber2;
|
||||
}
|
||||
|
||||
public void setOrderNumber2( Long orderNumber2 ) {
|
||||
this.orderNumber2 = orderNumber2;
|
||||
}
|
||||
|
||||
public OrderShippingDetailsDto getShippingDetails() {
|
||||
return shippingDetails;
|
||||
}
|
||||
|
||||
public void setShippingDetails( OrderShippingDetailsDto shippingDetails ) {
|
||||
this.shippingDetails = shippingDetails;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
/**
|
||||
* Copyright 2012-2014 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.jaxb.selection;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sjaak Derksen
|
||||
*/
|
||||
public class OrderShippingDetailsDto {
|
||||
|
||||
private String orderShippedFrom;
|
||||
private String orderShippedTo;
|
||||
|
||||
public String getOrderShippedFrom() {
|
||||
return orderShippedFrom;
|
||||
}
|
||||
|
||||
public void setOrderShippedFrom( String orderShippedFrom ) {
|
||||
this.orderShippedFrom = orderShippedFrom;
|
||||
}
|
||||
|
||||
public String getOrderShippedTo() {
|
||||
return orderShippedTo;
|
||||
}
|
||||
|
||||
public void setOrderShippedTo( String orderShippedTo ) {
|
||||
this.orderShippedTo = orderShippedTo;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
/**
|
||||
* Copyright 2012-2014 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.jaxb.selection;
|
||||
|
||||
import javax.xml.bind.JAXBElement;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.ap.test.jaxb.selection.test1.ObjectFactory;
|
||||
import org.mapstruct.ap.test.jaxb.selection.test2.OrderShippingDetailsType;
|
||||
import org.mapstruct.ap.test.jaxb.selection.test1.OrderType;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sjaak Derksen
|
||||
*/
|
||||
@Mapper(uses = { ObjectFactory.class,
|
||||
org.mapstruct.ap.test.jaxb.selection.test2.ObjectFactory.class } )
|
||||
public abstract class SourceTargetMapper {
|
||||
|
||||
public static final SourceTargetMapper INSTANCE = Mappers.getMapper( SourceTargetMapper.class );
|
||||
|
||||
// target 2 source methods
|
||||
public abstract OrderType targetToSource(OrderDto target);
|
||||
public abstract OrderShippingDetailsType dtoToOrderShippingDetailsType(OrderShippingDetailsDto target);
|
||||
|
||||
// TODO, remove this method when #134 is fixed
|
||||
public JAXBElement<OrderShippingDetailsType> dtoToOrderShippingDetailsTypeJB(OrderShippingDetailsDto target) {
|
||||
ObjectFactory of1 = new ObjectFactory();
|
||||
return of1.createOrderTypeShippingDetails( INSTANCE.dtoToOrderShippingDetailsType( target ) );
|
||||
}
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
/**
|
||||
* Copyright 2012-2014 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.jaxb.selection.test1;
|
||||
|
||||
import javax.xml.bind.JAXBElement;
|
||||
import javax.xml.bind.annotation.XmlElementDecl;
|
||||
import javax.xml.bind.annotation.XmlRegistry;
|
||||
import javax.xml.namespace.QName;
|
||||
import org.mapstruct.ap.test.jaxb.selection.test2.OrderShippingDetailsType;
|
||||
|
||||
@XmlRegistry
|
||||
public class ObjectFactory {
|
||||
|
||||
public static final QName ORDER_QNAME =
|
||||
new QName("http://www.mapstruct.org/ap/test/jaxb/selection/test1", "Order");
|
||||
public static final QName ORDER_TYPE_ORDER_NUMBER1_QNAME =
|
||||
new QName("http://www.mapstruct.org/ap/test/jaxb/selection/test1", "orderNumber1");
|
||||
public static final QName ORDER_TYPE_ORDER_NUMBER2_QNAME =
|
||||
new QName("http://www.mapstruct.org/ap/test/jaxb/selection/test1", "orderNumber2");
|
||||
public static final QName ORDER_TYPE_SHIPPING_DETAILS_QNAME =
|
||||
new QName("http://www.mapstruct.org/ap/test/jaxb/selection/test1", "shippingDetails");
|
||||
|
||||
|
||||
public ObjectFactory() {
|
||||
}
|
||||
|
||||
public OrderType createOrderType() {
|
||||
return new OrderType();
|
||||
}
|
||||
|
||||
@XmlElementDecl(namespace = "http://www.mapstruct.org/ap/test/jaxb/selection/test1", name = "Order")
|
||||
public JAXBElement<OrderType> createOrder(OrderType value) {
|
||||
return new JAXBElement<OrderType>(ORDER_QNAME, OrderType.class, null, value);
|
||||
}
|
||||
|
||||
@XmlElementDecl(namespace = "http://www.mapstruct.org/ap/test/jaxb/selection/test1",
|
||||
name = "orderNumber1", scope = OrderType.class)
|
||||
public JAXBElement<Long> createOrderTypeOrderNumber1(Long value) {
|
||||
return new JAXBElement<Long>(ORDER_TYPE_ORDER_NUMBER1_QNAME, Long.class, OrderType.class, value);
|
||||
}
|
||||
|
||||
@XmlElementDecl(namespace = "http://www.mapstruct.org/ap/test/jaxb/selection/test1",
|
||||
name = "orderNumber2", scope = OrderType.class)
|
||||
public JAXBElement<Long> createOrderTypeOrderNumber2(Long value) {
|
||||
return new JAXBElement<Long>(ORDER_TYPE_ORDER_NUMBER2_QNAME, Long.class, OrderType.class, value);
|
||||
}
|
||||
|
||||
@XmlElementDecl(namespace = "http://www.mapstruct.org/ap/test/jaxb/selection/test1",
|
||||
name = "shippingDetails", scope = OrderType.class)
|
||||
public JAXBElement<OrderShippingDetailsType> createOrderTypeShippingDetails(OrderShippingDetailsType value) {
|
||||
return new JAXBElement<OrderShippingDetailsType>(ORDER_TYPE_SHIPPING_DETAILS_QNAME,
|
||||
OrderShippingDetailsType.class, OrderType.class, value);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
/**
|
||||
* Copyright 2012-2014 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.jaxb.selection.test1;
|
||||
|
||||
import javax.xml.bind.JAXBElement;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElementRef;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
import org.mapstruct.ap.test.jaxb.selection.test2.OrderShippingDetailsType;
|
||||
|
||||
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "OrderType", propOrder = {
|
||||
"orderNumber1",
|
||||
"orderNumber2",
|
||||
"shippingDetails"
|
||||
})
|
||||
public class OrderType {
|
||||
|
||||
@XmlElementRef(name = "orderNumber1", namespace = "http://www.mapstruct.org/ap/test/jaxb/selection/test1",
|
||||
type = JAXBElement.class)
|
||||
private JAXBElement<Long> orderNumber1;
|
||||
@XmlElementRef(name = "orderNumber2", namespace = "http://www.mapstruct.org/ap/test/jaxb/selection/test1",
|
||||
type = JAXBElement.class)
|
||||
private JAXBElement<Long> orderNumber2;
|
||||
@XmlElementRef(name = "shippingDetails", namespace = "http://www.mapstruct.org/ap/test/jaxb/selection/test1",
|
||||
type = JAXBElement.class)
|
||||
private JAXBElement<OrderShippingDetailsType> shippingDetails;
|
||||
|
||||
public JAXBElement<Long> getOrderNumber1() {
|
||||
return orderNumber1;
|
||||
}
|
||||
|
||||
public void setOrderNumber1(JAXBElement<Long> value) {
|
||||
this.orderNumber1 = value;
|
||||
}
|
||||
|
||||
public JAXBElement<Long> getOrderNumber2() {
|
||||
return orderNumber2;
|
||||
}
|
||||
|
||||
public void setOrderNumber2(JAXBElement<Long> value) {
|
||||
this.orderNumber2 = value;
|
||||
}
|
||||
|
||||
public JAXBElement<OrderShippingDetailsType> getShippingDetails() {
|
||||
return shippingDetails;
|
||||
}
|
||||
|
||||
public void setShippingDetails(JAXBElement<OrderShippingDetailsType> value) {
|
||||
this.shippingDetails = value;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
/**
|
||||
* Copyright 2012-2014 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.jaxb.selection.test2;
|
||||
|
||||
import javax.xml.bind.JAXBElement;
|
||||
import javax.xml.bind.annotation.XmlElementDecl;
|
||||
import javax.xml.bind.annotation.XmlRegistry;
|
||||
import javax.xml.namespace.QName;
|
||||
|
||||
@XmlRegistry
|
||||
public class ObjectFactory {
|
||||
|
||||
public static final QName ORDER_SHIPPING_DETAILS_QNAME =
|
||||
new QName("http://www.mapstruct.org/ap/test/jaxb/selection/test2", "OrderShippingDetails");
|
||||
public static final QName ORDER_SHIPPING_DETAILS_TYPE_ORDER_SHIPPED_FROM_QNAME =
|
||||
new QName("http://www.mapstruct.org/ap/test/jaxb/selection/test2", "orderShippedFrom");
|
||||
public static final QName ORDER_SHIPPING_DETAILS_TYPE_ORDER_SHIPPED_TO_QNAME =
|
||||
new QName("http://www.mapstruct.org/ap/test/jaxb/selection/test2", "orderShippedTo");
|
||||
|
||||
public ObjectFactory() {
|
||||
}
|
||||
|
||||
public OrderShippingDetailsType createOrderShippingDetailsType() {
|
||||
return new OrderShippingDetailsType();
|
||||
}
|
||||
|
||||
|
||||
@XmlElementDecl(namespace = "http://www.mapstruct.org/ap/test/jaxb/selection/test2", name = "OrderShippingDetails")
|
||||
public JAXBElement<OrderShippingDetailsType> createOrderShippingDetails(OrderShippingDetailsType value) {
|
||||
return new JAXBElement<OrderShippingDetailsType>(ORDER_SHIPPING_DETAILS_QNAME,
|
||||
OrderShippingDetailsType.class, null, value);
|
||||
}
|
||||
|
||||
@XmlElementDecl(namespace = "http://www.mapstruct.org/ap/test/jaxb/selection/test2", name = "orderShippedFrom",
|
||||
scope = OrderShippingDetailsType.class)
|
||||
public JAXBElement<String> createOrderShippingDetailsTypeOrderShippedFrom(String value) {
|
||||
return new JAXBElement<String>(ORDER_SHIPPING_DETAILS_TYPE_ORDER_SHIPPED_FROM_QNAME, String.class,
|
||||
OrderShippingDetailsType.class, value);
|
||||
}
|
||||
|
||||
@XmlElementDecl(namespace = "http://www.mapstruct.org/ap/test/jaxb/selection/test2", name = "orderShippedTo",
|
||||
scope = OrderShippingDetailsType.class)
|
||||
public JAXBElement<String> createOrderShippingDetailsTypeOrderShippedTo(String value) {
|
||||
return new JAXBElement<String>(ORDER_SHIPPING_DETAILS_TYPE_ORDER_SHIPPED_TO_QNAME, String.class,
|
||||
OrderShippingDetailsType.class, value);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
/**
|
||||
* Copyright 2012-2014 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.jaxb.selection.test2;
|
||||
|
||||
import javax.xml.bind.JAXBElement;
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElementRef;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlType(name = "OrderShippingDetailsType", propOrder = {
|
||||
"orderShippedFrom",
|
||||
"orderShippedTo"
|
||||
})
|
||||
public class OrderShippingDetailsType {
|
||||
|
||||
@XmlElementRef(name = "orderShippedFrom",
|
||||
namespace = "http://www.mapstruct.org/ap/test/jaxb/selection/test2", type = JAXBElement.class)
|
||||
private JAXBElement<String> orderShippedFrom;
|
||||
@XmlElementRef(name = "orderShippedTo",
|
||||
namespace = "http://www.mapstruct.org/ap/test/jaxb/selection/test2", type = JAXBElement.class)
|
||||
private JAXBElement<String> orderShippedTo;
|
||||
|
||||
public JAXBElement<String> getOrderShippedFrom() {
|
||||
return orderShippedFrom;
|
||||
}
|
||||
|
||||
public void setOrderShippedFrom(JAXBElement<String> value) {
|
||||
this.orderShippedFrom = value;
|
||||
}
|
||||
|
||||
public JAXBElement<String> getOrderShippedTo() {
|
||||
return orderShippedTo;
|
||||
}
|
||||
|
||||
public void setOrderShippedTo(JAXBElement<String> value) {
|
||||
this.orderShippedTo = value;
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user