diff --git a/build-config/pom.xml b/build-config/pom.xml index 0bdec734cb..ce50cd522f 100644 --- a/build-config/pom.xml +++ b/build-config/pom.xml @@ -10,12 +10,13 @@ 4.0.0 - org.mapstruct + com.gitee.jmash mapstruct-parent - 1.6.0-SNAPSHOT + 1.6.0 ../parent/pom.xml + com.gitee.jmash mapstruct-build-config jar MapStruct Build Configuration diff --git a/core-jdk8/pom.xml b/core-jdk8/pom.xml index 160f963adf..4efde4dffa 100644 --- a/core-jdk8/pom.xml +++ b/core-jdk8/pom.xml @@ -10,12 +10,12 @@ 4.0.0 - org.mapstruct + com.gitee.jmash mapstruct-parent - 1.6.0-SNAPSHOT + 1.6.0 ../parent/pom.xml - + com.gitee.jmash mapstruct-jdk8 MapStruct Core JDK 8 Deprecated MapStruct artifact containing annotations to be used with JDK 8 and later - diff --git a/core/pom.xml b/core/pom.xml index ac993c73d6..4e2899052f 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -10,12 +10,12 @@ 4.0.0 - org.mapstruct + com.gitee.jmash mapstruct-parent - 1.6.0-SNAPSHOT + 1.6.0 ../parent/pom.xml - + com.gitee.jmash mapstruct jar MapStruct Core @@ -35,19 +35,6 @@ - - org.apache.maven.plugins - maven-checkstyle-plugin - - - check-style - verify - - checkstyle - - - - org.apache.maven.plugins maven-source-plugin @@ -101,10 +88,6 @@ - - com.github.siom79.japicmp - japicmp-maven-plugin - diff --git a/distribution/pom.xml b/distribution/pom.xml index be82f52b3c..94de24d31d 100644 --- a/distribution/pom.xml +++ b/distribution/pom.xml @@ -10,24 +10,27 @@ 4.0.0 - org.mapstruct + com.gitee.jmash mapstruct-parent - 1.6.0-SNAPSHOT + 1.6.0 ../parent/pom.xml + com.gitee.jmash mapstruct-distribution jar MapStruct Distribution - org.mapstruct + com.gitee.jmash mapstruct + 1.6.0 - org.mapstruct + com.gitee.jmash mapstruct-processor + 1.6.0 diff --git a/documentation/pom.xml b/documentation/pom.xml index 0a62a3ef3c..15e54068bb 100644 --- a/documentation/pom.xml +++ b/documentation/pom.xml @@ -10,12 +10,13 @@ 4.0.0 - org.mapstruct + com.gitee.jmash mapstruct-parent - 1.6.0-SNAPSHOT + 1.6.0 ../parent/pom.xml + com.gitee.jmash mapstruct-documentation pom MapStruct Documentation diff --git a/integrationtest/pom.xml b/integrationtest/pom.xml index f888e226ff..ccaf5e2a8b 100644 --- a/integrationtest/pom.xml +++ b/integrationtest/pom.xml @@ -10,12 +10,13 @@ 4.0.0 - org.mapstruct + com.gitee.jmash mapstruct-parent - 1.6.0-SNAPSHOT + 1.6.0 ../parent/pom.xml + com.gitee.jmash mapstruct-integrationtest jar MapStruct Integration Test @@ -23,6 +24,7 @@ ${project.version} true + true diff --git a/parent/pom.xml b/parent/pom.xml index e87db14551..b69e828d37 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -9,9 +9,9 @@ 4.0.0 - org.mapstruct + com.gitee.jmash mapstruct-parent - 1.6.0-SNAPSHOT + 1.6.0 pom MapStruct Parent @@ -76,9 +76,8 @@ - sonatype-nexus-staging - Nexus Release Repository - https://oss.sonatype.org/service/local/staging/deploy/maven2/ + ossrh + https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/ sonatype-nexus-snapshots @@ -314,14 +313,14 @@ - ${project.groupId} + com.gitee.jmash mapstruct - ${project.version} + 1.6.0 - ${project.groupId} + com.gitee.jmash mapstruct-processor - ${project.version} + 1.6.0 org.apache.maven.shared @@ -368,7 +367,7 @@ specified as patterns within a source folder, so we can't exclude generated-sources altogether --> - **/*Gem.java,*/itest/jaxb/xsd/* + **/*Gem.java,*/itest/jaxb/xsd/*,**/protobuf/test/_target/*.java diff --git a/pom.xml b/pom.xml index 25a5ead6bc..06c0c89223 100644 --- a/pom.xml +++ b/pom.xml @@ -11,9 +11,9 @@ 4.0.0 - org.mapstruct + com.gitee.jmash mapstruct-parent - 1.6.0-SNAPSHOT + 1.6.0 parent/pom.xml diff --git a/processor/pom.xml b/processor/pom.xml index 12fc615f5f..06c4531b97 100644 --- a/processor/pom.xml +++ b/processor/pom.xml @@ -10,12 +10,13 @@ 4.0.0 - org.mapstruct + com.gitee.jmash mapstruct-parent - 1.6.0-SNAPSHOT + 1.6.0 ../parent/pom.xml + com.gitee.jmash mapstruct-processor jar MapStruct Processor @@ -25,6 +26,7 @@ Therefore we set this empty property here--> 11 + true @@ -38,10 +40,15 @@ gem-api - ${project.groupId} + com.gitee.jmash mapstruct provided + + com.google.protobuf + protobuf-java + test + org.eclipse.tycho tycho-compiler-jdt @@ -296,19 +303,6 @@ - - org.apache.maven.plugins - maven-checkstyle-plugin - - - check-style - verify - - checkstyle - - - - org.jacoco jacoco-maven-plugin @@ -354,21 +348,6 @@ - - com.github.siom79.japicmp - japicmp-maven-plugin - - - - org.mapstruct.ap - - - org.mapstruct.ap.internal - org.mapstruct.ap.shaded - - - - diff --git a/processor/src/main/java/org/mapstruct/ap/internal/model/common/Type.java b/processor/src/main/java/org/mapstruct/ap/internal/model/common/Type.java index 6894906266..697d1475a3 100644 --- a/processor/src/main/java/org/mapstruct/ap/internal/model/common/Type.java +++ b/processor/src/main/java/org/mapstruct/ap/internal/model/common/Type.java @@ -348,6 +348,20 @@ public boolean isCollectionOrMapType() { return isCollectionType || isMapType; } + /** + * Only Protobuf Message , Not Protobuf Builder. + */ + public boolean isProtobufMessageReturnType() { + TypeElement builderType = elementUtils.getTypeElement( "com.google.protobuf.Message.Builder" ); + TypeElement messageOrBuilderType = elementUtils.getTypeElement( "com.google.protobuf.MessageOrBuilder" ); + if (null == builderType || null == messageOrBuilderType) { + return false; + } + boolean isBuilder = typeUtils.isAssignable( this.typeMirror, builderType.asType() ); + boolean isMessageOrBuilderType = typeUtils.isAssignable( this.typeMirror, messageOrBuilderType.asType() ); + return isMessageOrBuilderType && !isBuilder; + } + public boolean isArrayType() { return componentType != null; } diff --git a/processor/src/main/java/org/mapstruct/ap/internal/util/AnnotationProcessorContext.java b/processor/src/main/java/org/mapstruct/ap/internal/util/AnnotationProcessorContext.java index 7421dfde7a..3f6ac9afd8 100644 --- a/processor/src/main/java/org/mapstruct/ap/internal/util/AnnotationProcessorContext.java +++ b/processor/src/main/java/org/mapstruct/ap/internal/util/AnnotationProcessorContext.java @@ -32,6 +32,7 @@ import org.mapstruct.ap.spi.ImmutablesBuilderProvider; import org.mapstruct.ap.spi.MapStructProcessingEnvironment; import org.mapstruct.ap.spi.NoOpBuilderProvider; +import org.mapstruct.ap.spi.ProtobufAccessorNamingStrategy; /** * Keeps contextual data in the scope of the entire annotation processor ("application scope"). @@ -94,6 +95,13 @@ else if ( elementUtils.getTypeElement( FreeBuilderConstants.FREE_BUILDER_FQN ) ! messager.printMessage( Diagnostic.Kind.NOTE, "MapStruct: Freebuilder found on classpath" ); } } + else if ( elementUtils.getTypeElement( ProtobufConstants.PROTOBUF_FQN ) != null ) { + defaultAccessorNamingStrategy = new ProtobufAccessorNamingStrategy(); + defaultBuilderProvider = new DefaultBuilderProvider(); + if ( verbose ) { + messager.printMessage( Diagnostic.Kind.NOTE, "MapStruct: Protobuf Java Util found on classpath" ); + } + } else { defaultAccessorNamingStrategy = new DefaultAccessorNamingStrategy(); defaultBuilderProvider = new DefaultBuilderProvider(); diff --git a/processor/src/main/java/org/mapstruct/ap/internal/util/ProtobufConstants.java b/processor/src/main/java/org/mapstruct/ap/internal/util/ProtobufConstants.java new file mode 100644 index 0000000000..6a43dabbb8 --- /dev/null +++ b/processor/src/main/java/org/mapstruct/ap/internal/util/ProtobufConstants.java @@ -0,0 +1,20 @@ +/* + * Copyright MapStruct Authors. + * + * Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 + */ +package org.mapstruct.ap.internal.util; + +/** + * Helper for holding Protobuf FQN. + * + * @author CGD + */ +public class ProtobufConstants { + + public static final String PROTOBUF_FQN = "com.google.protobuf.util.Timestamps"; + + private ProtobufConstants() { + + } +} diff --git a/processor/src/main/java/org/mapstruct/ap/spi/ProtobufAccessorNamingStrategy.java b/processor/src/main/java/org/mapstruct/ap/spi/ProtobufAccessorNamingStrategy.java new file mode 100644 index 0000000000..fcdd8dbaba --- /dev/null +++ b/processor/src/main/java/org/mapstruct/ap/spi/ProtobufAccessorNamingStrategy.java @@ -0,0 +1,102 @@ +/* + * Copyright MapStruct Authors. + * + * Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 + */ +package org.mapstruct.ap.spi; + +import java.util.List; +import java.util.Map; + +import javax.lang.model.element.Element; +import javax.lang.model.element.ExecutableElement; +import javax.lang.model.element.TypeElement; +import javax.lang.model.type.TypeMirror; + +import org.mapstruct.util.Experimental; + +/** + * @author Thomas Kratz + * @author Filip Hrisafov + */ +@Experimental("The Protobuf accessor naming strategy might change in a subsequent release") +public class ProtobufAccessorNamingStrategy extends DefaultAccessorNamingStrategy { + + public static final String PROTOBUF_MESSAGE_OR_BUILDER = "com.google.protobuf.MessageOrBuilder"; + public static final String LIST_SUFFIX = "List"; + public static final String MAP_SUFFIX = "Map"; + protected TypeMirror protobufType; + + @Override + public void init(MapStructProcessingEnvironment processingEnvironment) { + super.init( processingEnvironment ); + TypeElement typeElement = elementUtils.getTypeElement( PROTOBUF_MESSAGE_OR_BUILDER ); + if (typeElement != null) { + protobufType = typeElement.asType(); + } + } + + @Override + public boolean isGetterMethod(ExecutableElement method) { + boolean getterMethod = super.isGetterMethod( method ); + if (!isProtobufMethod( method )) { + return getterMethod; + } + String methodName = method.getSimpleName().toString(); + String returnTypeName = typeUtils.erasure( method.getReturnType() ).toString(); + if (getterMethod && isProtobufMethod( method ) && !methodName.endsWith( "List" ) + && isGetterListMethod( returnTypeName )) { + return false; + } + if (getterMethod && isProtobufMethod( method ) && !methodName.endsWith( "Map" ) + && returnTypeName.equals( Map.class.getName() )) { + return false; + } + return getterMethod; + } + + @Override + public String getPropertyName(ExecutableElement getterOrSetterMethod) { + String propertyName = super.getPropertyName( getterOrSetterMethod ); + if (!isProtobufMethod( getterOrSetterMethod )) { + return propertyName; + } + + String returnTypeName = typeUtils.erasure( getterOrSetterMethod.getReturnType() ).toString(); + if (isProtobufMethod( getterOrSetterMethod ) && propertyName.endsWith( "List" ) + && isGetterListMethod( returnTypeName )) { + propertyName = propertyName.substring( 0, propertyName.length() - 4 ); + return propertyName; + } + if (isProtobufMethod( getterOrSetterMethod ) && propertyName.endsWith( "Map" ) + && returnTypeName.equals( Map.class.getName() )) { + propertyName = propertyName.substring( 0, propertyName.length() - 3 ); + return propertyName; + } + return propertyName; + } + + /** + * is Getter List Method? + * @param returnTypeName + * @return + */ + protected boolean isGetterListMethod(String returnTypeName) { + return returnTypeName.equals( List.class.getName() ) + || returnTypeName.equals( "com.google.protobuf.ProtocolStringList" ); + } + + /** + * is protobuf method? + * @param method + * @return + */ + public boolean isProtobufMethod(ExecutableElement method) { + Element receiver = method.getEnclosingElement(); + if (receiver != null && protobufType != null && typeUtils.isAssignable( receiver.asType(), protobufType )) { + return true; + } + return false; + } + +} diff --git a/processor/src/main/resources/org/mapstruct/ap/internal/model/BeanMappingMethod.ftl b/processor/src/main/resources/org/mapstruct/ap/internal/model/BeanMappingMethod.ftl index 1b402a57f0..ad05e0f4c6 100644 --- a/processor/src/main/resources/org/mapstruct/ap/internal/model/BeanMappingMethod.ftl +++ b/processor/src/main/resources/org/mapstruct/ap/internal/model/BeanMappingMethod.ftl @@ -87,6 +87,11 @@ + + <#if existingInstanceMapping && returnType.protobufMessageReturnType > + throw new IllegalArgumentException("Only Support ${returnType?string}.Builder , Use Message.toBuilder() Convert , Not Support Protobuf Message. "); + + <#list beforeMappingReferencesWithMappingTarget as callback> <@includeModel object=callback targetBeanName=resultName targetType=targetType/> <#if !callback_has_next> diff --git a/processor/src/main/resources/org/mapstruct/ap/internal/model/assignment/GetterWrapperForCollectionsAndMaps.ftl b/processor/src/main/resources/org/mapstruct/ap/internal/model/assignment/GetterWrapperForCollectionsAndMaps.ftl index 4ef55f3b40..99e9c26660 100644 --- a/processor/src/main/resources/org/mapstruct/ap/internal/model/assignment/GetterWrapperForCollectionsAndMaps.ftl +++ b/processor/src/main/resources/org/mapstruct/ap/internal/model/assignment/GetterWrapperForCollectionsAndMaps.ftl @@ -11,10 +11,18 @@ if ( ${ext.targetBeanName}.${ext.targetWriteAccessorName}<@lib.handleWriteAccesing /> != null ) { <@lib.handleExceptions> <#if ext.existingInstanceMapping> + <#if ( "${ext.targetWriteAccessorName}" == "get${ext.targetPropertyName?cap_first}Map" || "${ext.targetWriteAccessorName}" == "get${ext.targetPropertyName?cap_first}List" ) > + ${ext.targetBeanName}.clear${ext.targetPropertyName?cap_first}(); + <#else> ${ext.targetBeanName}.${ext.targetWriteAccessorName}<@lib.handleWriteAccesing />.clear(); + <@lib.handleLocalVarNullCheck needs_explicit_local_var=false> + <#if ( "${ext.targetWriteAccessorName}" == "get${ext.targetPropertyName?cap_first}Map" || "${ext.targetWriteAccessorName}" == "get${ext.targetPropertyName?cap_first}List" ) > + ${ext.targetBeanName}.<#if ext.targetType.collectionType>addAll${ext.targetPropertyName?cap_first}<#else>putAll${ext.targetPropertyName?cap_first}( <@lib.handleWithAssignmentOrNullCheckVar/> ); + <#else> ${ext.targetBeanName}.${ext.targetWriteAccessorName}<@lib.handleWriteAccesing />.<#if ext.targetType.collectionType>addAll<#else>putAll( <@lib.handleWithAssignmentOrNullCheckVar/> ); + } diff --git a/processor/src/test/java/org/mapstruct/ap/protobuf/test/_target/BasicTestIntMessageList.java b/processor/src/test/java/org/mapstruct/ap/protobuf/test/_target/BasicTestIntMessageList.java new file mode 100644 index 0000000000..e05efa8590 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/protobuf/test/_target/BasicTestIntMessageList.java @@ -0,0 +1,606 @@ +/* + * Copyright MapStruct Authors. + * + * Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: crenjoy/protobuf/basic_test.proto + +package org.mapstruct.ap.protobuf.test._target; + +/** + * Protobuf type {@code crenjoy.protobuf.BasicTestIntMessageList} + */ +public final class BasicTestIntMessageList extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:crenjoy.protobuf.BasicTestIntMessageList) + BasicTestIntMessageListOrBuilder { +private static final long serialVersionUID = 0L; + // Use BasicTestIntMessageList.newBuilder() to construct. + private BasicTestIntMessageList(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private BasicTestIntMessageList() { + testIntList_ = emptyIntList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new BasicTestIntMessageList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private BasicTestIntMessageList( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 8: { + if (!((mutable_bitField0_ & 0x00000001) != 0)) { + testIntList_ = newIntList(); + mutable_bitField0_ |= 0x00000001; + } + testIntList_.addInt(input.readInt32()); + break; + } + case 10: { + int length = input.readRawVarint32(); + int limit = input.pushLimit(length); + if (!((mutable_bitField0_ & 0x00000001) != 0) && input.getBytesUntilLimit() > 0) { + testIntList_ = newIntList(); + mutable_bitField0_ |= 0x00000001; + } + while (input.getBytesUntilLimit() > 0) { + testIntList_.addInt(input.readInt32()); + } + input.popLimit(limit); + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) != 0)) { + testIntList_.makeImmutable(); // C + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.mapstruct.ap.protobuf.test._target.BasicTestMessageProto.internal_static_crenjoy_protobuf_BasicTestIntMessageList_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.mapstruct.ap.protobuf.test._target.BasicTestMessageProto.internal_static_crenjoy_protobuf_BasicTestIntMessageList_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.mapstruct.ap.protobuf.test._target.BasicTestIntMessageList.class, org.mapstruct.ap.protobuf.test._target.BasicTestIntMessageList.Builder.class); + } + + public static final int TEST_INT_LIST_FIELD_NUMBER = 1; + private com.google.protobuf.Internal.IntList testIntList_; + /** + * repeated int32 test_int_list = 1; + * @return A list containing the testIntList. + */ + @java.lang.Override + public java.util.List + getTestIntListList() { + return testIntList_; + } + /** + * repeated int32 test_int_list = 1; + * @return The count of testIntList. + */ + public int getTestIntListCount() { + return testIntList_.size(); + } + /** + * repeated int32 test_int_list = 1; + * @param index The index of the element to return. + * @return The testIntList at the given index. + */ + public int getTestIntList(int index) { + return testIntList_.getInt(index); + } + private int testIntListMemoizedSerializedSize = -1; + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + getSerializedSize(); + if (getTestIntListList().size() > 0) { + output.writeUInt32NoTag(10); + output.writeUInt32NoTag(testIntListMemoizedSerializedSize); + } + for (int i = 0; i < testIntList_.size(); i++) { + output.writeInt32NoTag(testIntList_.getInt(i)); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + { + int dataSize = 0; + for (int i = 0; i < testIntList_.size(); i++) { + dataSize += com.google.protobuf.CodedOutputStream + .computeInt32SizeNoTag(testIntList_.getInt(i)); + } + size += dataSize; + if (!getTestIntListList().isEmpty()) { + size += 1; + size += com.google.protobuf.CodedOutputStream + .computeInt32SizeNoTag(dataSize); + } + testIntListMemoizedSerializedSize = dataSize; + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.mapstruct.ap.protobuf.test._target.BasicTestIntMessageList)) { + return super.equals(obj); + } + org.mapstruct.ap.protobuf.test._target.BasicTestIntMessageList other = (org.mapstruct.ap.protobuf.test._target.BasicTestIntMessageList) obj; + + if (!getTestIntListList() + .equals(other.getTestIntListList())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getTestIntListCount() > 0) { + hash = (37 * hash) + TEST_INT_LIST_FIELD_NUMBER; + hash = (53 * hash) + getTestIntListList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.mapstruct.ap.protobuf.test._target.BasicTestIntMessageList parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.mapstruct.ap.protobuf.test._target.BasicTestIntMessageList parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.mapstruct.ap.protobuf.test._target.BasicTestIntMessageList parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.mapstruct.ap.protobuf.test._target.BasicTestIntMessageList parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.mapstruct.ap.protobuf.test._target.BasicTestIntMessageList parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.mapstruct.ap.protobuf.test._target.BasicTestIntMessageList parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.mapstruct.ap.protobuf.test._target.BasicTestIntMessageList parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.mapstruct.ap.protobuf.test._target.BasicTestIntMessageList parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.mapstruct.ap.protobuf.test._target.BasicTestIntMessageList parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.mapstruct.ap.protobuf.test._target.BasicTestIntMessageList parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.mapstruct.ap.protobuf.test._target.BasicTestIntMessageList parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.mapstruct.ap.protobuf.test._target.BasicTestIntMessageList parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.mapstruct.ap.protobuf.test._target.BasicTestIntMessageList prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code crenjoy.protobuf.BasicTestIntMessageList} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:crenjoy.protobuf.BasicTestIntMessageList) + org.mapstruct.ap.protobuf.test._target.BasicTestIntMessageListOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.mapstruct.ap.protobuf.test._target.BasicTestMessageProto.internal_static_crenjoy_protobuf_BasicTestIntMessageList_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.mapstruct.ap.protobuf.test._target.BasicTestMessageProto.internal_static_crenjoy_protobuf_BasicTestIntMessageList_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.mapstruct.ap.protobuf.test._target.BasicTestIntMessageList.class, org.mapstruct.ap.protobuf.test._target.BasicTestIntMessageList.Builder.class); + } + + // Construct using org.mapstruct.ap.protobuf.test._target.BasicTestIntMessageList.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + testIntList_ = emptyIntList(); + bitField0_ = (bitField0_ & ~0x00000001); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.mapstruct.ap.protobuf.test._target.BasicTestMessageProto.internal_static_crenjoy_protobuf_BasicTestIntMessageList_descriptor; + } + + @java.lang.Override + public org.mapstruct.ap.protobuf.test._target.BasicTestIntMessageList getDefaultInstanceForType() { + return org.mapstruct.ap.protobuf.test._target.BasicTestIntMessageList.getDefaultInstance(); + } + + @java.lang.Override + public org.mapstruct.ap.protobuf.test._target.BasicTestIntMessageList build() { + org.mapstruct.ap.protobuf.test._target.BasicTestIntMessageList result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public org.mapstruct.ap.protobuf.test._target.BasicTestIntMessageList buildPartial() { + org.mapstruct.ap.protobuf.test._target.BasicTestIntMessageList result = new org.mapstruct.ap.protobuf.test._target.BasicTestIntMessageList(this); + int from_bitField0_ = bitField0_; + if (((bitField0_ & 0x00000001) != 0)) { + testIntList_.makeImmutable(); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.testIntList_ = testIntList_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.mapstruct.ap.protobuf.test._target.BasicTestIntMessageList) { + return mergeFrom((org.mapstruct.ap.protobuf.test._target.BasicTestIntMessageList)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.mapstruct.ap.protobuf.test._target.BasicTestIntMessageList other) { + if (other == org.mapstruct.ap.protobuf.test._target.BasicTestIntMessageList.getDefaultInstance()) return this; + if (!other.testIntList_.isEmpty()) { + if (testIntList_.isEmpty()) { + testIntList_ = other.testIntList_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureTestIntListIsMutable(); + testIntList_.addAll(other.testIntList_); + } + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.mapstruct.ap.protobuf.test._target.BasicTestIntMessageList parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.mapstruct.ap.protobuf.test._target.BasicTestIntMessageList) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private com.google.protobuf.Internal.IntList testIntList_ = emptyIntList(); + private void ensureTestIntListIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + testIntList_ = mutableCopy(testIntList_); + bitField0_ |= 0x00000001; + } + } + /** + * repeated int32 test_int_list = 1; + * @return A list containing the testIntList. + */ + public java.util.List + getTestIntListList() { + return ((bitField0_ & 0x00000001) != 0) ? + java.util.Collections.unmodifiableList(testIntList_) : testIntList_; + } + /** + * repeated int32 test_int_list = 1; + * @return The count of testIntList. + */ + public int getTestIntListCount() { + return testIntList_.size(); + } + /** + * repeated int32 test_int_list = 1; + * @param index The index of the element to return. + * @return The testIntList at the given index. + */ + public int getTestIntList(int index) { + return testIntList_.getInt(index); + } + /** + * repeated int32 test_int_list = 1; + * @param index The index to set the value at. + * @param value The testIntList to set. + * @return This builder for chaining. + */ + public Builder setTestIntList( + int index, int value) { + ensureTestIntListIsMutable(); + testIntList_.setInt(index, value); + onChanged(); + return this; + } + /** + * repeated int32 test_int_list = 1; + * @param value The testIntList to add. + * @return This builder for chaining. + */ + public Builder addTestIntList(int value) { + ensureTestIntListIsMutable(); + testIntList_.addInt(value); + onChanged(); + return this; + } + /** + * repeated int32 test_int_list = 1; + * @param values The testIntList to add. + * @return This builder for chaining. + */ + public Builder addAllTestIntList( + java.lang.Iterable values) { + ensureTestIntListIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, testIntList_); + onChanged(); + return this; + } + /** + * repeated int32 test_int_list = 1; + * @return This builder for chaining. + */ + public Builder clearTestIntList() { + testIntList_ = emptyIntList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:crenjoy.protobuf.BasicTestIntMessageList) + } + + // @@protoc_insertion_point(class_scope:crenjoy.protobuf.BasicTestIntMessageList) + private static final org.mapstruct.ap.protobuf.test._target.BasicTestIntMessageList DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.mapstruct.ap.protobuf.test._target.BasicTestIntMessageList(); + } + + public static org.mapstruct.ap.protobuf.test._target.BasicTestIntMessageList getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public BasicTestIntMessageList parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new BasicTestIntMessageList(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public org.mapstruct.ap.protobuf.test._target.BasicTestIntMessageList getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/processor/src/test/java/org/mapstruct/ap/protobuf/test/_target/BasicTestIntMessageListOrBuilder.java b/processor/src/test/java/org/mapstruct/ap/protobuf/test/_target/BasicTestIntMessageListOrBuilder.java new file mode 100644 index 0000000000..c53ad72719 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/protobuf/test/_target/BasicTestIntMessageListOrBuilder.java @@ -0,0 +1,31 @@ +/* + * Copyright MapStruct Authors. + * + * Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: crenjoy/protobuf/basic_test.proto + +package org.mapstruct.ap.protobuf.test._target; + +public interface BasicTestIntMessageListOrBuilder extends + // @@protoc_insertion_point(interface_extends:crenjoy.protobuf.BasicTestIntMessageList) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated int32 test_int_list = 1; + * @return A list containing the testIntList. + */ + java.util.List getTestIntListList(); + /** + * repeated int32 test_int_list = 1; + * @return The count of testIntList. + */ + int getTestIntListCount(); + /** + * repeated int32 test_int_list = 1; + * @param index The index of the element to return. + * @return The testIntList at the given index. + */ + int getTestIntList(int index); +} diff --git a/processor/src/test/java/org/mapstruct/ap/protobuf/test/_target/BasicTestMessageList.java b/processor/src/test/java/org/mapstruct/ap/protobuf/test/_target/BasicTestMessageList.java new file mode 100644 index 0000000000..69c1f8f67f --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/protobuf/test/_target/BasicTestMessageList.java @@ -0,0 +1,621 @@ +/* + * Copyright MapStruct Authors. + * + * Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: crenjoy/protobuf/basic_test.proto + +package org.mapstruct.ap.protobuf.test._target; + +/** + * Protobuf type {@code crenjoy.protobuf.BasicTestMessageList} + */ +public final class BasicTestMessageList extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:crenjoy.protobuf.BasicTestMessageList) + BasicTestMessageListOrBuilder { +private static final long serialVersionUID = 0L; + // Use BasicTestMessageList.newBuilder() to construct. + private BasicTestMessageList(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private BasicTestMessageList() { + testStrList_ = com.google.protobuf.LazyStringArrayList.EMPTY; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new BasicTestMessageList(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private BasicTestMessageList( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + java.lang.String s = input.readStringRequireUtf8(); + if (!((mutable_bitField0_ & 0x00000001) != 0)) { + testStrList_ = new com.google.protobuf.LazyStringArrayList(); + mutable_bitField0_ |= 0x00000001; + } + testStrList_.add(s); + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + if (((mutable_bitField0_ & 0x00000001) != 0)) { + testStrList_ = testStrList_.getUnmodifiableView(); + } + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.mapstruct.ap.protobuf.test._target.BasicTestMessageProto.internal_static_crenjoy_protobuf_BasicTestMessageList_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.mapstruct.ap.protobuf.test._target.BasicTestMessageProto.internal_static_crenjoy_protobuf_BasicTestMessageList_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.mapstruct.ap.protobuf.test._target.BasicTestMessageList.class, org.mapstruct.ap.protobuf.test._target.BasicTestMessageList.Builder.class); + } + + public static final int TEST_STR_LIST_FIELD_NUMBER = 1; + private com.google.protobuf.LazyStringList testStrList_; + /** + * repeated string test_str_list = 1; + * @return A list containing the testStrList. + */ + public com.google.protobuf.ProtocolStringList + getTestStrListList() { + return testStrList_; + } + /** + * repeated string test_str_list = 1; + * @return The count of testStrList. + */ + public int getTestStrListCount() { + return testStrList_.size(); + } + /** + * repeated string test_str_list = 1; + * @param index The index of the element to return. + * @return The testStrList at the given index. + */ + public java.lang.String getTestStrList(int index) { + return testStrList_.get(index); + } + /** + * repeated string test_str_list = 1; + * @param index The index of the value to return. + * @return The bytes of the testStrList at the given index. + */ + public com.google.protobuf.ByteString + getTestStrListBytes(int index) { + return testStrList_.getByteString(index); + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + for (int i = 0; i < testStrList_.size(); i++) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, testStrList_.getRaw(i)); + } + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + { + int dataSize = 0; + for (int i = 0; i < testStrList_.size(); i++) { + dataSize += computeStringSizeNoTag(testStrList_.getRaw(i)); + } + size += dataSize; + size += 1 * getTestStrListList().size(); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.mapstruct.ap.protobuf.test._target.BasicTestMessageList)) { + return super.equals(obj); + } + org.mapstruct.ap.protobuf.test._target.BasicTestMessageList other = (org.mapstruct.ap.protobuf.test._target.BasicTestMessageList) obj; + + if (!getTestStrListList() + .equals(other.getTestStrListList())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (getTestStrListCount() > 0) { + hash = (37 * hash) + TEST_STR_LIST_FIELD_NUMBER; + hash = (53 * hash) + getTestStrListList().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.mapstruct.ap.protobuf.test._target.BasicTestMessageList parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.mapstruct.ap.protobuf.test._target.BasicTestMessageList parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.mapstruct.ap.protobuf.test._target.BasicTestMessageList parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.mapstruct.ap.protobuf.test._target.BasicTestMessageList parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.mapstruct.ap.protobuf.test._target.BasicTestMessageList parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.mapstruct.ap.protobuf.test._target.BasicTestMessageList parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.mapstruct.ap.protobuf.test._target.BasicTestMessageList parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.mapstruct.ap.protobuf.test._target.BasicTestMessageList parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.mapstruct.ap.protobuf.test._target.BasicTestMessageList parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.mapstruct.ap.protobuf.test._target.BasicTestMessageList parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.mapstruct.ap.protobuf.test._target.BasicTestMessageList parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.mapstruct.ap.protobuf.test._target.BasicTestMessageList parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.mapstruct.ap.protobuf.test._target.BasicTestMessageList prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code crenjoy.protobuf.BasicTestMessageList} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:crenjoy.protobuf.BasicTestMessageList) + org.mapstruct.ap.protobuf.test._target.BasicTestMessageListOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.mapstruct.ap.protobuf.test._target.BasicTestMessageProto.internal_static_crenjoy_protobuf_BasicTestMessageList_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.mapstruct.ap.protobuf.test._target.BasicTestMessageProto.internal_static_crenjoy_protobuf_BasicTestMessageList_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.mapstruct.ap.protobuf.test._target.BasicTestMessageList.class, org.mapstruct.ap.protobuf.test._target.BasicTestMessageList.Builder.class); + } + + // Construct using org.mapstruct.ap.protobuf.test.target.BasicTestMessageList.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + testStrList_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000001); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.mapstruct.ap.protobuf.test._target.BasicTestMessageProto.internal_static_crenjoy_protobuf_BasicTestMessageList_descriptor; + } + + @java.lang.Override + public org.mapstruct.ap.protobuf.test._target.BasicTestMessageList getDefaultInstanceForType() { + return org.mapstruct.ap.protobuf.test._target.BasicTestMessageList.getDefaultInstance(); + } + + @java.lang.Override + public org.mapstruct.ap.protobuf.test._target.BasicTestMessageList build() { + org.mapstruct.ap.protobuf.test._target.BasicTestMessageList result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public org.mapstruct.ap.protobuf.test._target.BasicTestMessageList buildPartial() { + org.mapstruct.ap.protobuf.test._target.BasicTestMessageList result = new org.mapstruct.ap.protobuf.test._target.BasicTestMessageList(this); + int from_bitField0_ = bitField0_; + if (((bitField0_ & 0x00000001) != 0)) { + testStrList_ = testStrList_.getUnmodifiableView(); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.testStrList_ = testStrList_; + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.mapstruct.ap.protobuf.test._target.BasicTestMessageList) { + return mergeFrom((org.mapstruct.ap.protobuf.test._target.BasicTestMessageList)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.mapstruct.ap.protobuf.test._target.BasicTestMessageList other) { + if (other == org.mapstruct.ap.protobuf.test._target.BasicTestMessageList.getDefaultInstance()) return this; + if (!other.testStrList_.isEmpty()) { + if (testStrList_.isEmpty()) { + testStrList_ = other.testStrList_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureTestStrListIsMutable(); + testStrList_.addAll(other.testStrList_); + } + onChanged(); + } + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.mapstruct.ap.protobuf.test._target.BasicTestMessageList parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.mapstruct.ap.protobuf.test._target.BasicTestMessageList) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private com.google.protobuf.LazyStringList testStrList_ = com.google.protobuf.LazyStringArrayList.EMPTY; + private void ensureTestStrListIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + testStrList_ = new com.google.protobuf.LazyStringArrayList(testStrList_); + bitField0_ |= 0x00000001; + } + } + /** + * repeated string test_str_list = 1; + * @return A list containing the testStrList. + */ + public com.google.protobuf.ProtocolStringList + getTestStrListList() { + return testStrList_.getUnmodifiableView(); + } + /** + * repeated string test_str_list = 1; + * @return The count of testStrList. + */ + public int getTestStrListCount() { + return testStrList_.size(); + } + /** + * repeated string test_str_list = 1; + * @param index The index of the element to return. + * @return The testStrList at the given index. + */ + public java.lang.String getTestStrList(int index) { + return testStrList_.get(index); + } + /** + * repeated string test_str_list = 1; + * @param index The index of the value to return. + * @return The bytes of the testStrList at the given index. + */ + public com.google.protobuf.ByteString + getTestStrListBytes(int index) { + return testStrList_.getByteString(index); + } + /** + * repeated string test_str_list = 1; + * @param index The index to set the value at. + * @param value The testStrList to set. + * @return This builder for chaining. + */ + public Builder setTestStrList( + int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureTestStrListIsMutable(); + testStrList_.set(index, value); + onChanged(); + return this; + } + /** + * repeated string test_str_list = 1; + * @param value The testStrList to add. + * @return This builder for chaining. + */ + public Builder addTestStrList( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureTestStrListIsMutable(); + testStrList_.add(value); + onChanged(); + return this; + } + /** + * repeated string test_str_list = 1; + * @param values The testStrList to add. + * @return This builder for chaining. + */ + public Builder addAllTestStrList( + java.lang.Iterable values) { + ensureTestStrListIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll( + values, testStrList_); + onChanged(); + return this; + } + /** + * repeated string test_str_list = 1; + * @return This builder for chaining. + */ + public Builder clearTestStrList() { + testStrList_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + * repeated string test_str_list = 1; + * @param value The bytes of the testStrList to add. + * @return This builder for chaining. + */ + public Builder addTestStrListBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureTestStrListIsMutable(); + testStrList_.add(value); + onChanged(); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:crenjoy.protobuf.BasicTestMessageList) + } + + // @@protoc_insertion_point(class_scope:crenjoy.protobuf.BasicTestMessageList) + private static final org.mapstruct.ap.protobuf.test._target.BasicTestMessageList DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.mapstruct.ap.protobuf.test._target.BasicTestMessageList(); + } + + public static org.mapstruct.ap.protobuf.test._target.BasicTestMessageList getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public BasicTestMessageList parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new BasicTestMessageList(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public org.mapstruct.ap.protobuf.test._target.BasicTestMessageList getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/processor/src/test/java/org/mapstruct/ap/protobuf/test/_target/BasicTestMessageListOrBuilder.java b/processor/src/test/java/org/mapstruct/ap/protobuf/test/_target/BasicTestMessageListOrBuilder.java new file mode 100644 index 0000000000..b9bfbb71f6 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/protobuf/test/_target/BasicTestMessageListOrBuilder.java @@ -0,0 +1,39 @@ +/* + * Copyright MapStruct Authors. + * + * Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: crenjoy/protobuf/basic_test.proto + +package org.mapstruct.ap.protobuf.test._target; + +public interface BasicTestMessageListOrBuilder extends + // @@protoc_insertion_point(interface_extends:crenjoy.protobuf.BasicTestMessageList) + com.google.protobuf.MessageOrBuilder { + + /** + * repeated string test_str_list = 1; + * @return A list containing the testStrList. + */ + java.util.List + getTestStrListList(); + /** + * repeated string test_str_list = 1; + * @return The count of testStrList. + */ + int getTestStrListCount(); + /** + * repeated string test_str_list = 1; + * @param index The index of the element to return. + * @return The testStrList at the given index. + */ + java.lang.String getTestStrList(int index); + /** + * repeated string test_str_list = 1; + * @param index The index of the value to return. + * @return The bytes of the testStrList at the given index. + */ + com.google.protobuf.ByteString + getTestStrListBytes(int index); +} diff --git a/processor/src/test/java/org/mapstruct/ap/protobuf/test/_target/BasicTestMessageMap.java b/processor/src/test/java/org/mapstruct/ap/protobuf/test/_target/BasicTestMessageMap.java new file mode 100644 index 0000000000..0fb7d6dcef --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/protobuf/test/_target/BasicTestMessageMap.java @@ -0,0 +1,715 @@ +/* + * Copyright MapStruct Authors. + * + * Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: crenjoy/protobuf/basic_test.proto + +package org.mapstruct.ap.protobuf.test._target; + +/** + * Protobuf type {@code crenjoy.protobuf.BasicTestMessageMap} + */ +public final class BasicTestMessageMap extends + com.google.protobuf.GeneratedMessageV3 implements + // @@protoc_insertion_point(message_implements:crenjoy.protobuf.BasicTestMessageMap) + BasicTestMessageMapOrBuilder { +private static final long serialVersionUID = 0L; + // Use BasicTestMessageMap.newBuilder() to construct. + private BasicTestMessageMap(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + private BasicTestMessageMap() { + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance( + UnusedPrivateParameter unused) { + return new BasicTestMessageMap(); + } + + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet + getUnknownFields() { + return this.unknownFields; + } + private BasicTestMessageMap( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + this(); + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + int mutable_bitField0_ = 0; + com.google.protobuf.UnknownFieldSet.Builder unknownFields = + com.google.protobuf.UnknownFieldSet.newBuilder(); + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: { + if (!((mutable_bitField0_ & 0x00000001) != 0)) { + testStrMap_ = com.google.protobuf.MapField.newMapField( + TestStrMapDefaultEntryHolder.defaultEntry); + mutable_bitField0_ |= 0x00000001; + } + com.google.protobuf.MapEntry + testStrMap__ = input.readMessage( + TestStrMapDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry); + testStrMap_.getMutableMap().put( + testStrMap__.getKey(), testStrMap__.getValue()); + break; + } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } + } + } + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(this); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException( + e).setUnfinishedMessage(this); + } finally { + this.unknownFields = unknownFields.build(); + makeExtensionsImmutable(); + } + } + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.mapstruct.ap.protobuf.test._target.BasicTestMessageProto.internal_static_crenjoy_protobuf_BasicTestMessageMap_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + @java.lang.Override + protected com.google.protobuf.MapField internalGetMapField( + int number) { + switch (number) { + case 1: + return internalGetTestStrMap(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.mapstruct.ap.protobuf.test._target.BasicTestMessageProto.internal_static_crenjoy_protobuf_BasicTestMessageMap_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.mapstruct.ap.protobuf.test._target.BasicTestMessageMap.class, org.mapstruct.ap.protobuf.test._target.BasicTestMessageMap.Builder.class); + } + + public static final int TEST_STR_MAP_FIELD_NUMBER = 1; + private static final class TestStrMapDefaultEntryHolder { + static final com.google.protobuf.MapEntry< + java.lang.String, java.lang.String> defaultEntry = + com.google.protobuf.MapEntry + .newDefaultInstance( + org.mapstruct.ap.protobuf.test._target.BasicTestMessageProto.internal_static_crenjoy_protobuf_BasicTestMessageMap_TestStrMapEntry_descriptor, + com.google.protobuf.WireFormat.FieldType.STRING, + "", + com.google.protobuf.WireFormat.FieldType.STRING, + ""); + } + private com.google.protobuf.MapField< + java.lang.String, java.lang.String> testStrMap_; + private com.google.protobuf.MapField + internalGetTestStrMap() { + if (testStrMap_ == null) { + return com.google.protobuf.MapField.emptyMapField( + TestStrMapDefaultEntryHolder.defaultEntry); + } + return testStrMap_; + } + + public int getTestStrMapCount() { + return internalGetTestStrMap().getMap().size(); + } + /** + * map<string, string> test_str_map = 1; + */ + + @java.lang.Override + public boolean containsTestStrMap( + java.lang.String key) { + if (key == null) { throw new NullPointerException("map key"); } + return internalGetTestStrMap().getMap().containsKey(key); + } + /** + * Use {@link #getTestStrMapMap()} instead. + */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getTestStrMap() { + return getTestStrMapMap(); + } + /** + * map<string, string> test_str_map = 1; + */ + @java.lang.Override + + public java.util.Map getTestStrMapMap() { + return internalGetTestStrMap().getMap(); + } + /** + * map<string, string> test_str_map = 1; + */ + @java.lang.Override + + public java.lang.String getTestStrMapOrDefault( + java.lang.String key, + java.lang.String defaultValue) { + if (key == null) { throw new NullPointerException("map key"); } + java.util.Map map = + internalGetTestStrMap().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * map<string, string> test_str_map = 1; + */ + @java.lang.Override + + public java.lang.String getTestStrMapOrThrow( + java.lang.String key) { + if (key == null) { throw new NullPointerException("map key"); } + java.util.Map map = + internalGetTestStrMap().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + private byte memoizedIsInitialized = -1; + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) + throws java.io.IOException { + com.google.protobuf.GeneratedMessageV3 + .serializeStringMapTo( + output, + internalGetTestStrMap(), + TestStrMapDefaultEntryHolder.defaultEntry, + 1); + unknownFields.writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (java.util.Map.Entry entry + : internalGetTestStrMap().getMap().entrySet()) { + com.google.protobuf.MapEntry + testStrMap__ = TestStrMapDefaultEntryHolder.defaultEntry.newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + size += com.google.protobuf.CodedOutputStream + .computeMessageSize(1, testStrMap__); + } + size += unknownFields.getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof org.mapstruct.ap.protobuf.test._target.BasicTestMessageMap)) { + return super.equals(obj); + } + org.mapstruct.ap.protobuf.test._target.BasicTestMessageMap other = (org.mapstruct.ap.protobuf.test._target.BasicTestMessageMap) obj; + + if (!internalGetTestStrMap().equals( + other.internalGetTestStrMap())) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (!internalGetTestStrMap().getMap().isEmpty()) { + hash = (37 * hash) + TEST_STR_MAP_FIELD_NUMBER; + hash = (53 * hash) + internalGetTestStrMap().hashCode(); + } + hash = (29 * hash) + unknownFields.hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static org.mapstruct.ap.protobuf.test._target.BasicTestMessageMap parseFrom( + java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.mapstruct.ap.protobuf.test._target.BasicTestMessageMap parseFrom( + java.nio.ByteBuffer data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.mapstruct.ap.protobuf.test._target.BasicTestMessageMap parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.mapstruct.ap.protobuf.test._target.BasicTestMessageMap parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.mapstruct.ap.protobuf.test._target.BasicTestMessageMap parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + public static org.mapstruct.ap.protobuf.test._target.BasicTestMessageMap parseFrom( + byte[] data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + public static org.mapstruct.ap.protobuf.test._target.BasicTestMessageMap parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.mapstruct.ap.protobuf.test._target.BasicTestMessageMap parseFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + public static org.mapstruct.ap.protobuf.test._target.BasicTestMessageMap parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input); + } + public static org.mapstruct.ap.protobuf.test._target.BasicTestMessageMap parseDelimitedFrom( + java.io.InputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + public static org.mapstruct.ap.protobuf.test._target.BasicTestMessageMap parseFrom( + com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input); + } + public static org.mapstruct.ap.protobuf.test._target.BasicTestMessageMap parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3 + .parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { return newBuilder(); } + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + public static Builder newBuilder(org.mapstruct.ap.protobuf.test._target.BasicTestMessageMap prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE + ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * Protobuf type {@code crenjoy.protobuf.BasicTestMessageMap} + */ + public static final class Builder extends + com.google.protobuf.GeneratedMessageV3.Builder implements + // @@protoc_insertion_point(builder_implements:crenjoy.protobuf.BasicTestMessageMap) + org.mapstruct.ap.protobuf.test._target.BasicTestMessageMapOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor + getDescriptor() { + return org.mapstruct.ap.protobuf.test._target.BasicTestMessageProto.internal_static_crenjoy_protobuf_BasicTestMessageMap_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMapField( + int number) { + switch (number) { + case 1: + return internalGetTestStrMap(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapField internalGetMutableMapField( + int number) { + switch (number) { + case 1: + return internalGetMutableTestStrMap(); + default: + throw new RuntimeException( + "Invalid map field number: " + number); + } + } + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return org.mapstruct.ap.protobuf.test._target.BasicTestMessageProto.internal_static_crenjoy_protobuf_BasicTestMessageMap_fieldAccessorTable + .ensureFieldAccessorsInitialized( + org.mapstruct.ap.protobuf.test._target.BasicTestMessageMap.class, org.mapstruct.ap.protobuf.test._target.BasicTestMessageMap.Builder.class); + } + + // Construct using org.mapstruct.ap.protobuf.test.target.BasicTestMessageMap.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder( + com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3 + .alwaysUseFieldBuilders) { + } + } + @java.lang.Override + public Builder clear() { + super.clear(); + internalGetMutableTestStrMap().clear(); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor + getDescriptorForType() { + return org.mapstruct.ap.protobuf.test._target.BasicTestMessageProto.internal_static_crenjoy_protobuf_BasicTestMessageMap_descriptor; + } + + @java.lang.Override + public org.mapstruct.ap.protobuf.test._target.BasicTestMessageMap getDefaultInstanceForType() { + return org.mapstruct.ap.protobuf.test._target.BasicTestMessageMap.getDefaultInstance(); + } + + @java.lang.Override + public org.mapstruct.ap.protobuf.test._target.BasicTestMessageMap build() { + org.mapstruct.ap.protobuf.test._target.BasicTestMessageMap result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public org.mapstruct.ap.protobuf.test._target.BasicTestMessageMap buildPartial() { + org.mapstruct.ap.protobuf.test._target.BasicTestMessageMap result = new org.mapstruct.ap.protobuf.test._target.BasicTestMessageMap(this); + int from_bitField0_ = bitField0_; + result.testStrMap_ = internalGetTestStrMap(); + result.testStrMap_.makeImmutable(); + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.setField(field, value); + } + @java.lang.Override + public Builder clearField( + com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + @java.lang.Override + public Builder clearOneof( + com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + java.lang.Object value) { + return super.addRepeatedField(field, value); + } + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof org.mapstruct.ap.protobuf.test._target.BasicTestMessageMap) { + return mergeFrom((org.mapstruct.ap.protobuf.test._target.BasicTestMessageMap)other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(org.mapstruct.ap.protobuf.test._target.BasicTestMessageMap other) { + if (other == org.mapstruct.ap.protobuf.test._target.BasicTestMessageMap.getDefaultInstance()) return this; + internalGetMutableTestStrMap().mergeFrom( + other.internalGetTestStrMap()); + this.mergeUnknownFields(other.unknownFields); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + org.mapstruct.ap.protobuf.test._target.BasicTestMessageMap parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (org.mapstruct.ap.protobuf.test._target.BasicTestMessageMap) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + private int bitField0_; + + private com.google.protobuf.MapField< + java.lang.String, java.lang.String> testStrMap_; + private com.google.protobuf.MapField + internalGetTestStrMap() { + if (testStrMap_ == null) { + return com.google.protobuf.MapField.emptyMapField( + TestStrMapDefaultEntryHolder.defaultEntry); + } + return testStrMap_; + } + private com.google.protobuf.MapField + internalGetMutableTestStrMap() { + onChanged();; + if (testStrMap_ == null) { + testStrMap_ = com.google.protobuf.MapField.newMapField( + TestStrMapDefaultEntryHolder.defaultEntry); + } + if (!testStrMap_.isMutable()) { + testStrMap_ = testStrMap_.copy(); + } + return testStrMap_; + } + + public int getTestStrMapCount() { + return internalGetTestStrMap().getMap().size(); + } + /** + * map<string, string> test_str_map = 1; + */ + + @java.lang.Override + public boolean containsTestStrMap( + java.lang.String key) { + if (key == null) { throw new NullPointerException("map key"); } + return internalGetTestStrMap().getMap().containsKey(key); + } + /** + * Use {@link #getTestStrMapMap()} instead. + */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getTestStrMap() { + return getTestStrMapMap(); + } + /** + * map<string, string> test_str_map = 1; + */ + @java.lang.Override + + public java.util.Map getTestStrMapMap() { + return internalGetTestStrMap().getMap(); + } + /** + * map<string, string> test_str_map = 1; + */ + @java.lang.Override + + public java.lang.String getTestStrMapOrDefault( + java.lang.String key, + java.lang.String defaultValue) { + if (key == null) { throw new NullPointerException("map key"); } + java.util.Map map = + internalGetTestStrMap().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + /** + * map<string, string> test_str_map = 1; + */ + @java.lang.Override + + public java.lang.String getTestStrMapOrThrow( + java.lang.String key) { + if (key == null) { throw new NullPointerException("map key"); } + java.util.Map map = + internalGetTestStrMap().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + public Builder clearTestStrMap() { + internalGetMutableTestStrMap().getMutableMap() + .clear(); + return this; + } + /** + * map<string, string> test_str_map = 1; + */ + + public Builder removeTestStrMap( + java.lang.String key) { + if (key == null) { throw new NullPointerException("map key"); } + internalGetMutableTestStrMap().getMutableMap() + .remove(key); + return this; + } + /** + * Use alternate mutation accessors instead. + */ + @java.lang.Deprecated + public java.util.Map + getMutableTestStrMap() { + return internalGetMutableTestStrMap().getMutableMap(); + } + /** + * map<string, string> test_str_map = 1; + */ + public Builder putTestStrMap( + java.lang.String key, + java.lang.String value) { + if (key == null) { throw new NullPointerException("map key"); } + if (value == null) { + throw new NullPointerException("map value"); +} + + internalGetMutableTestStrMap().getMutableMap() + .put(key, value); + return this; + } + /** + * map<string, string> test_str_map = 1; + */ + + public Builder putAllTestStrMap( + java.util.Map values) { + internalGetMutableTestStrMap().getMutableMap() + .putAll(values); + return this; + } + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + + // @@protoc_insertion_point(builder_scope:crenjoy.protobuf.BasicTestMessageMap) + } + + // @@protoc_insertion_point(class_scope:crenjoy.protobuf.BasicTestMessageMap) + private static final org.mapstruct.ap.protobuf.test._target.BasicTestMessageMap DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new org.mapstruct.ap.protobuf.test._target.BasicTestMessageMap(); + } + + public static org.mapstruct.ap.protobuf.test._target.BasicTestMessageMap getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser + PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override + public BasicTestMessageMap parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return new BasicTestMessageMap(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public org.mapstruct.ap.protobuf.test._target.BasicTestMessageMap getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + +} + diff --git a/processor/src/test/java/org/mapstruct/ap/protobuf/test/_target/BasicTestMessageMapOrBuilder.java b/processor/src/test/java/org/mapstruct/ap/protobuf/test/_target/BasicTestMessageMapOrBuilder.java new file mode 100644 index 0000000000..642b804e09 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/protobuf/test/_target/BasicTestMessageMapOrBuilder.java @@ -0,0 +1,50 @@ +/* + * Copyright MapStruct Authors. + * + * Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: crenjoy/protobuf/basic_test.proto + +package org.mapstruct.ap.protobuf.test._target; + +public interface BasicTestMessageMapOrBuilder extends + // @@protoc_insertion_point(interface_extends:crenjoy.protobuf.BasicTestMessageMap) + com.google.protobuf.MessageOrBuilder { + + /** + * map<string, string> test_str_map = 1; + */ + int getTestStrMapCount(); + /** + * map<string, string> test_str_map = 1; + */ + boolean containsTestStrMap( + java.lang.String key); + /** + * Use {@link #getTestStrMapMap()} instead. + */ + @java.lang.Deprecated + java.util.Map + getTestStrMap(); + /** + * map<string, string> test_str_map = 1; + */ + java.util.Map + getTestStrMapMap(); + /** + * map<string, string> test_str_map = 1; + */ + + /* nullable */ +java.lang.String getTestStrMapOrDefault( + java.lang.String key, + /* nullable */ +java.lang.String defaultValue); + /** + * map<string, string> test_str_map = 1; + */ + + java.lang.String getTestStrMapOrThrow( + java.lang.String key); +} diff --git a/processor/src/test/java/org/mapstruct/ap/protobuf/test/_target/BasicTestMessageProto.java b/processor/src/test/java/org/mapstruct/ap/protobuf/test/_target/BasicTestMessageProto.java new file mode 100644 index 0000000000..8fac588058 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/protobuf/test/_target/BasicTestMessageProto.java @@ -0,0 +1,234 @@ +/* + * Copyright MapStruct Authors. + * + * Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: crenjoy/protobuf/basic_test.proto + +package org.mapstruct.ap.protobuf.test._target; + +public final class BasicTestMessageProto { + private BasicTestMessageProto() {} + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistryLite registry) { + } + + public static void registerAllExtensions( + com.google.protobuf.ExtensionRegistry registry) { + registerAllExtensions( + (com.google.protobuf.ExtensionRegistryLite) registry); + } + static final com.google.protobuf.Descriptors.Descriptor + internal_static_crenjoy_protobuf_Basic1TestMessage_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_crenjoy_protobuf_Basic1TestMessage_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_crenjoy_protobuf_Basic2TestMessage_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_crenjoy_protobuf_Basic2TestMessage_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_crenjoy_protobuf_BasicTestMessageMap_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_crenjoy_protobuf_BasicTestMessageMap_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_crenjoy_protobuf_BasicTestMessageMap_TestStrMapEntry_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_crenjoy_protobuf_BasicTestMessageMap_TestStrMapEntry_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_crenjoy_protobuf_BasicTestMessageList_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_crenjoy_protobuf_BasicTestMessageList_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_crenjoy_protobuf_BasicTestIntMessageList_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_crenjoy_protobuf_BasicTestIntMessageList_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_crenjoy_protobuf_TestMessageMap_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_crenjoy_protobuf_TestMessageMap_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_crenjoy_protobuf_TestMessageMap_TestBasicMapEntry_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_crenjoy_protobuf_TestMessageMap_TestBasicMapEntry_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_crenjoy_protobuf_TestMessageList_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_crenjoy_protobuf_TestMessageList_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_crenjoy_protobuf_NestedTestMessage_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_crenjoy_protobuf_NestedTestMessage_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_crenjoy_protobuf_NestedTestMessage_TestStrMapEntry_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_crenjoy_protobuf_NestedTestMessage_TestStrMapEntry_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_crenjoy_protobuf_NestedTestMessage_TestBasicMapEntry_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_crenjoy_protobuf_NestedTestMessage_TestBasicMapEntry_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_crenjoy_protobuf_ConvertTestMessage_descriptor; + static final + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_crenjoy_protobuf_ConvertTestMessage_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor + getDescriptor() { + return descriptor; + } + private static com.google.protobuf.Descriptors.FileDescriptor + descriptor; + static { + java.lang.String[] descriptorData = { + "\n!crenjoy/protobuf/basic_test.proto\022\020cre" + + "njoy.protobuf\"\316\002\n\021Basic1TestMessage\022\023\n\013t" + + "est_double\030\001 \001(\001\022\022\n\ntest_float\030\002 \001(\002\022\022\n\n" + + "test_int32\030\003 \001(\005\022\022\n\ntest_int64\030\004 \001(\003\022\023\n\013" + + "test_uint32\030\005 \001(\r\022\023\n\013test_uint64\030\006 \001(\004\022\023" + + "\n\013test_sint32\030\007 \001(\021\022\023\n\013test_sint64\030\010 \001(\022" + + "\022\024\n\014test_fixed32\030\t \001(\007\022\024\n\014test_fixed64\030\n" + + " \001(\006\022\025\n\rtest_sfixed32\030\013 \001(\017\022\025\n\rtest_sfix" + + "ed64\030\014 \001(\020\022\021\n\ttest_bool\030\r \001(\010\022\023\n\013test_st" + + "ring\030\016 \001(\t\022\022\n\ntest_bytes\030\017 \001(\014\"c\n\021Basic2" + + "TestMessage\022\023\n\013test_string\030\001 \001(\t\022\022\n\ntest" + + "_int32\030\002 \001(\005\022\021\n\ttest_bool\030\003 \001(\010\022\022\n\ntest_" + + "float\030\004 \001(\002\"\225\001\n\023BasicTestMessageMap\022K\n\014t" + + "est_str_map\030\001 \003(\01325.crenjoy.protobuf.Bas" + + "icTestMessageMap.TestStrMapEntry\0321\n\017Test" + + "StrMapEntry\022\013\n\003key\030\001 \001(\t\022\r\n\005value\030\002 \001(\t:" + + "\0028\001\"-\n\024BasicTestMessageList\022\025\n\rtest_str_" + + "list\030\001 \003(\t\"0\n\027BasicTestIntMessageList\022\025\n" + + "\rtest_int_list\030\001 \003(\005\"\266\001\n\016TestMessageMap\022" + + "J\n\016test_basic_map\030\001 \003(\01322.crenjoy.protob" + + "uf.TestMessageMap.TestBasicMapEntry\032X\n\021T" + + "estBasicMapEntry\022\013\n\003key\030\001 \001(\t\0222\n\005value\030\002" + + " \001(\0132#.crenjoy.protobuf.Basic2TestMessag" + + "e:\0028\001\"O\n\017TestMessageList\022<\n\017test_basic_l" + + "ist\030\001 \003(\0132#.crenjoy.protobuf.Basic2TestM" + + "essage\"\204\005\n\021NestedTestMessage\022\023\n\013test_str" + + "ing\030\001 \001(\t\022\023\n\013test_double\030\002 \001(\001\022\021\n\ttest_b" + + "ool\030\003 \001(\010\022<\n\017test_basic_bean\030\004 \001(\0132#.cre" + + "njoy.protobuf.Basic2TestMessage\022I\n\014test_" + + "str_map\030\005 \003(\01323.crenjoy.protobuf.NestedT" + + "estMessage.TestStrMapEntry\022\025\n\rtest_str_l" + + "ist\030\006 \003(\t\022M\n\016test_basic_map\030\007 \003(\01325.cren" + + "joy.protobuf.NestedTestMessage.TestBasic" + + "MapEntry\022<\n\017test_basic_list\030\010 \003(\0132#.cren" + + "joy.protobuf.Basic2TestMessage\022<\n\021test_m" + + "essage_list\030\t \001(\0132!.crenjoy.protobuf.Tes" + + "tMessageList\022:\n\020test_message_map\030\n \001(\0132 " + + ".crenjoy.protobuf.TestMessageMap\0321\n\017Test" + + "StrMapEntry\022\013\n\003key\030\001 \001(\t\022\r\n\005value\030\002 \001(\t:" + + "\0028\001\032X\n\021TestBasicMapEntry\022\013\n\003key\030\001 \001(\t\0222\n" + + "\005value\030\002 \001(\0132#.crenjoy.protobuf.Basic2Te" + + "stMessage:\0028\001\"\335\002\n\022ConvertTestMessage\022\034\n\024" + + "test_local_date_time\030\001 \001(\t\022\027\n\017test_local" + + "_date\030\002 \001(\t\022\027\n\017test_local_time\030\003 \001(\t\022\024\n\014" + + "test_instant\030\004 \001(\t\022\025\n\rtest_duration\030\005 \001(" + + "\t\022\035\n\025test_offset_date_time\030\006 \001(\t\022\030\n\020test" + + "_offset_time\030\007 \001(\t\022\034\n\024test_zoned_date_ti" + + "me\030\010 \001(\t\022\025\n\rtest_str_enum\030\t \001(\t\022\025\n\rtest_" + + "int_enum\030\n \001(\005\022\030\n\020test_big_decimal\030\013 \001(\t" + + "\022\030\n\020test_big_integer\030\014 \001(\t\022\021\n\ttest_uuid\030" + + "\r \001(\tBA\n&org.mapstruct.ap.protobuf.test." + + "_targetB\025BasicTestMessageProtoP\001b\006proto3" + }; + descriptor = com.google.protobuf.Descriptors.FileDescriptor + .internalBuildGeneratedFileFrom(descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + }); + internal_static_crenjoy_protobuf_Basic1TestMessage_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_crenjoy_protobuf_Basic1TestMessage_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_crenjoy_protobuf_Basic1TestMessage_descriptor, + new java.lang.String[] { "TestDouble", "TestFloat", "TestInt32", "TestInt64", "TestUint32", "TestUint64", "TestSint32", "TestSint64", "TestFixed32", "TestFixed64", "TestSfixed32", "TestSfixed64", "TestBool", "TestString", "TestBytes", }); + internal_static_crenjoy_protobuf_Basic2TestMessage_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_crenjoy_protobuf_Basic2TestMessage_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_crenjoy_protobuf_Basic2TestMessage_descriptor, + new java.lang.String[] { "TestString", "TestInt32", "TestBool", "TestFloat", }); + internal_static_crenjoy_protobuf_BasicTestMessageMap_descriptor = + getDescriptor().getMessageTypes().get(2); + internal_static_crenjoy_protobuf_BasicTestMessageMap_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_crenjoy_protobuf_BasicTestMessageMap_descriptor, + new java.lang.String[] { "TestStrMap", }); + internal_static_crenjoy_protobuf_BasicTestMessageMap_TestStrMapEntry_descriptor = + internal_static_crenjoy_protobuf_BasicTestMessageMap_descriptor.getNestedTypes().get(0); + internal_static_crenjoy_protobuf_BasicTestMessageMap_TestStrMapEntry_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_crenjoy_protobuf_BasicTestMessageMap_TestStrMapEntry_descriptor, + new java.lang.String[] { "Key", "Value", }); + internal_static_crenjoy_protobuf_BasicTestMessageList_descriptor = + getDescriptor().getMessageTypes().get(3); + internal_static_crenjoy_protobuf_BasicTestMessageList_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_crenjoy_protobuf_BasicTestMessageList_descriptor, + new java.lang.String[] { "TestStrList", }); + internal_static_crenjoy_protobuf_BasicTestIntMessageList_descriptor = + getDescriptor().getMessageTypes().get(4); + internal_static_crenjoy_protobuf_BasicTestIntMessageList_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_crenjoy_protobuf_BasicTestIntMessageList_descriptor, + new java.lang.String[] { "TestIntList", }); + internal_static_crenjoy_protobuf_TestMessageMap_descriptor = + getDescriptor().getMessageTypes().get(5); + internal_static_crenjoy_protobuf_TestMessageMap_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_crenjoy_protobuf_TestMessageMap_descriptor, + new java.lang.String[] { "TestBasicMap", }); + internal_static_crenjoy_protobuf_TestMessageMap_TestBasicMapEntry_descriptor = + internal_static_crenjoy_protobuf_TestMessageMap_descriptor.getNestedTypes().get(0); + internal_static_crenjoy_protobuf_TestMessageMap_TestBasicMapEntry_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_crenjoy_protobuf_TestMessageMap_TestBasicMapEntry_descriptor, + new java.lang.String[] { "Key", "Value", }); + internal_static_crenjoy_protobuf_TestMessageList_descriptor = + getDescriptor().getMessageTypes().get(6); + internal_static_crenjoy_protobuf_TestMessageList_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_crenjoy_protobuf_TestMessageList_descriptor, + new java.lang.String[] { "TestBasicList", }); + internal_static_crenjoy_protobuf_NestedTestMessage_descriptor = + getDescriptor().getMessageTypes().get(7); + internal_static_crenjoy_protobuf_NestedTestMessage_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_crenjoy_protobuf_NestedTestMessage_descriptor, + new java.lang.String[] { "TestString", "TestDouble", "TestBool", "TestBasicBean", "TestStrMap", "TestStrList", "TestBasicMap", "TestBasicList", "TestMessageList", "TestMessageMap", }); + internal_static_crenjoy_protobuf_NestedTestMessage_TestStrMapEntry_descriptor = + internal_static_crenjoy_protobuf_NestedTestMessage_descriptor.getNestedTypes().get(0); + internal_static_crenjoy_protobuf_NestedTestMessage_TestStrMapEntry_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_crenjoy_protobuf_NestedTestMessage_TestStrMapEntry_descriptor, + new java.lang.String[] { "Key", "Value", }); + internal_static_crenjoy_protobuf_NestedTestMessage_TestBasicMapEntry_descriptor = + internal_static_crenjoy_protobuf_NestedTestMessage_descriptor.getNestedTypes().get(1); + internal_static_crenjoy_protobuf_NestedTestMessage_TestBasicMapEntry_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_crenjoy_protobuf_NestedTestMessage_TestBasicMapEntry_descriptor, + new java.lang.String[] { "Key", "Value", }); + internal_static_crenjoy_protobuf_ConvertTestMessage_descriptor = + getDescriptor().getMessageTypes().get(8); + internal_static_crenjoy_protobuf_ConvertTestMessage_fieldAccessorTable = new + com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_crenjoy_protobuf_ConvertTestMessage_descriptor, + new java.lang.String[] { "TestLocalDateTime", "TestLocalDate", "TestLocalTime", "TestInstant", "TestDuration", "TestOffsetDateTime", "TestOffsetTime", "TestZonedDateTime", "TestStrEnum", "TestIntEnum", "TestBigDecimal", "TestBigInteger", "TestUuid", }); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/processor/src/test/java/org/mapstruct/ap/protobuf/test/_target/ProtoMapListBuilder.java b/processor/src/test/java/org/mapstruct/ap/protobuf/test/_target/ProtoMapListBuilder.java new file mode 100644 index 0000000000..079c751ada --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/protobuf/test/_target/ProtoMapListBuilder.java @@ -0,0 +1,84 @@ +/* + * Copyright MapStruct Authors. + * + * Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 + */ + +package org.mapstruct.ap.protobuf.test._target; + +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Bean Map List Builder. + * + * @author CGD + * + */ +public class ProtoMapListBuilder { + + protected ProtoMapListBuilder() { + throw new UnsupportedOperationException(); + } + + /** Null Map . */ + public static BasicTestMessageMap getMapNull() { + return BasicTestMessageMap.newBuilder().build(); + } + + /** Empty Map . */ + public static BasicTestMessageMap getMapEmpty() { + return BasicTestMessageMap.newBuilder().putAllTestStrMap( Collections.emptyMap() ).build(); + } + + /** Full Map . */ + public static BasicTestMessageMap getMapFull() { + Map maps = new HashMap() { + private static final long serialVersionUID = 1L; + { + put( "a", "a----a" ); + put( "b", "b----b" ); + put( "c", "c----c" ); + } + }; + BasicTestMessageMap map = BasicTestMessageMap.newBuilder().putAllTestStrMap( maps ).build(); + return map; + } + + /** Default Map . */ + public static BasicTestMessageMap getMapDefault() { + Map maps = new HashMap() { + private static final long serialVersionUID = 1L; + { + put( "a", "a----a" ); + put( "b", "b----b" ); + put( "c", "c----c" ); + put( "d", "" ); + put( "", "IS NULL" ); + } + }; + BasicTestMessageMap map = BasicTestMessageMap.newBuilder().putAllTestStrMap( maps ).build(); + return map; + } + + public static BasicTestMessageList getListNull() { + return BasicTestMessageList.newBuilder().build(); + } + + public static BasicTestMessageList getListEmpty() { + return BasicTestMessageList.newBuilder().addAllTestStrList( Collections.emptyList() ).build(); + } + + public static BasicTestMessageList getListFull() { + List list = Arrays.asList( "a", "b", "c" ); + return BasicTestMessageList.newBuilder().addAllTestStrList( list ).build(); + } + + public static BasicTestMessageList getListDefault() { + List list = Arrays.asList( "a", "b", "c", "" ); + return BasicTestMessageList.newBuilder().addAllTestStrList( list ).build(); + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/protobuf/test/map/ProtoListMapper.java b/processor/src/test/java/org/mapstruct/ap/protobuf/test/map/ProtoListMapper.java new file mode 100644 index 0000000000..5d2e282841 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/protobuf/test/map/ProtoListMapper.java @@ -0,0 +1,55 @@ +/* + * Copyright MapStruct Authors. + * + * Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 + */ + +package org.mapstruct.ap.protobuf.test.map; + +import com.google.protobuf.LazyStringArrayList; +import com.google.protobuf.ProtocolStringList; + +import java.util.List; + +import org.mapstruct.ap.protobuf.test._target.BasicTestIntMessageList; +import org.mapstruct.ap.protobuf.test._target.BasicTestMessageList; +import org.mapstruct.ap.protobuf.test.source.BasicTestBeanList; +import org.mapstruct.ap.protobuf.test.source.BasicTestIntBeanList; +import org.mapstruct.factory.Mappers; + +@org.mapstruct.Mapper +public interface ProtoListMapper { + + ProtoListMapper INSTANCE = Mappers.getMapper( ProtoListMapper.class ); + + BasicTestIntMessageList toIntList(BasicTestIntBeanList beanList); + + void updateIntList(@org.mapstruct.MappingTarget BasicTestIntMessageList.Builder mlist, BasicTestIntBeanList blist); + + BasicTestMessageList toList(BasicTestBeanList beanList); + + /** + * List Update Proto List Message. + */ + default BasicTestMessageList updateList(BasicTestMessageList msgList, + BasicTestBeanList beanList) { + BasicTestMessageList.Builder builder = msgList.toBuilder(); + updateList( builder, beanList ); + return builder.build(); + } + + void updateList(@org.mapstruct.MappingTarget BasicTestMessageList.Builder msgList, BasicTestBeanList beanList); + + /** ProtocolStringList is List String SubClass. */ + default List toListString(ProtocolStringList value) { + return (List) value; + } + + /** List String To ProtocolStringList. */ + default ProtocolStringList toListString(List value) { + ProtocolStringList protoList = new LazyStringArrayList(); + protoList.addAll( value ); + return protoList; + } + +} diff --git a/processor/src/test/java/org/mapstruct/ap/protobuf/test/map/ProtoListTest.java b/processor/src/test/java/org/mapstruct/ap/protobuf/test/map/ProtoListTest.java new file mode 100644 index 0000000000..738315a4e4 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/protobuf/test/map/ProtoListTest.java @@ -0,0 +1,50 @@ +/* + * Copyright MapStruct Authors. + * + * Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 + */ + +package org.mapstruct.ap.protobuf.test.map; + +import org.junit.jupiter.api.Assertions; +import org.mapstruct.ap.protobuf.test._target.BasicTestIntMessageList; +import org.mapstruct.ap.protobuf.test._target.BasicTestIntMessageListOrBuilder; +import org.mapstruct.ap.protobuf.test._target.BasicTestMessageList; +import org.mapstruct.ap.protobuf.test._target.BasicTestMessageListOrBuilder; +import org.mapstruct.ap.protobuf.test._target.BasicTestMessageProto; +import org.mapstruct.ap.protobuf.test._target.ProtoMapListBuilder; +import org.mapstruct.ap.protobuf.test.source.BasicTestBeanList; +import org.mapstruct.ap.protobuf.test.source.BasicTestBeanMap; +import org.mapstruct.ap.protobuf.test.source.BasicTestIntBeanList; +import org.mapstruct.ap.protobuf.test.source.BeanMapListBuilder; +import org.mapstruct.ap.spi.AccessorNamingStrategy; +import org.mapstruct.ap.spi.ProtobufAccessorNamingStrategy; +import org.mapstruct.ap.testutil.ProcessorTest; +import org.mapstruct.ap.testutil.WithClasses; +import org.mapstruct.ap.testutil.WithServiceImplementation; + +@WithClasses({ BasicTestBeanMap.class, BasicTestBeanList.class, BasicTestIntBeanList.class, + BeanMapListBuilder.class, BasicTestMessageProto.class, BasicTestMessageListOrBuilder.class, + BasicTestMessageList.class, BasicTestIntMessageList.class, + BasicTestIntMessageListOrBuilder.class, ProtoListMapper.class }) +@WithServiceImplementation(provides = AccessorNamingStrategy.class, value = ProtobufAccessorNamingStrategy.class) +public class ProtoListTest { + + @ProcessorTest + public void testToList() { + BasicTestBeanList source = BeanMapListBuilder.getListFull(); + BasicTestMessageList actual = ProtoListMapper.INSTANCE.toList( source ); + Assertions.assertEquals( ProtoMapListBuilder.getListFull().getTestStrListList(), + actual.getTestStrListList() ); + } + + @ProcessorTest + public void testUpdateList() { + BasicTestBeanList source = BeanMapListBuilder.getListFull(); + BasicTestMessageList actual = ProtoMapListBuilder.getListNull(); + actual = ProtoListMapper.INSTANCE.updateList( actual, source ); + Assertions.assertEquals( ProtoMapListBuilder.getListFull().getTestStrListList(), + actual.getTestStrListList() ); + } + +} diff --git a/processor/src/test/java/org/mapstruct/ap/protobuf/test/map/ProtoMapMapper.java b/processor/src/test/java/org/mapstruct/ap/protobuf/test/map/ProtoMapMapper.java new file mode 100644 index 0000000000..1472d3b6c0 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/protobuf/test/map/ProtoMapMapper.java @@ -0,0 +1,30 @@ +/* + * Copyright MapStruct Authors. + * + * Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 + */ + +package org.mapstruct.ap.protobuf.test.map; + +import org.mapstruct.ap.protobuf.test._target.BasicTestMessageMap; +import org.mapstruct.ap.protobuf.test.source.BasicTestBeanMap; +import org.mapstruct.factory.Mappers; + +@org.mapstruct.Mapper +public interface ProtoMapMapper { + + ProtoMapMapper INSTANCE = Mappers.getMapper( ProtoMapMapper.class ); + + BasicTestMessageMap toMap(BasicTestBeanMap beanMap); + + /** + * Map Update Proto Map Message. + */ + default BasicTestMessageMap updateMap(BasicTestMessageMap msgMap, BasicTestBeanMap beanMap) { + BasicTestMessageMap.Builder builder = msgMap.toBuilder(); + updateMap( builder, beanMap ); + return builder.build(); + } + + void updateMap(@org.mapstruct.MappingTarget BasicTestMessageMap.Builder msgMap, BasicTestBeanMap beanMap); +} diff --git a/processor/src/test/java/org/mapstruct/ap/protobuf/test/map/ProtoMapTest.java b/processor/src/test/java/org/mapstruct/ap/protobuf/test/map/ProtoMapTest.java new file mode 100644 index 0000000000..f727e80487 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/protobuf/test/map/ProtoMapTest.java @@ -0,0 +1,46 @@ +/* + * Copyright MapStruct Authors. + * + * Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 + */ + +package org.mapstruct.ap.protobuf.test.map; + +import org.junit.jupiter.api.Assertions; +import org.mapstruct.ap.protobuf.test._target.BasicTestMessageMap; +import org.mapstruct.ap.protobuf.test._target.BasicTestMessageMapOrBuilder; +import org.mapstruct.ap.protobuf.test._target.BasicTestMessageProto; +import org.mapstruct.ap.protobuf.test._target.ProtoMapListBuilder; +import org.mapstruct.ap.protobuf.test.source.BasicTestBeanList; +import org.mapstruct.ap.protobuf.test.source.BasicTestBeanMap; +import org.mapstruct.ap.protobuf.test.source.BeanMapListBuilder; +import org.mapstruct.ap.spi.AccessorNamingStrategy; +import org.mapstruct.ap.spi.ProtobufAccessorNamingStrategy; +import org.mapstruct.ap.testutil.ProcessorTest; +import org.mapstruct.ap.testutil.WithClasses; +import org.mapstruct.ap.testutil.WithServiceImplementation; + +@WithClasses({ BasicTestBeanMap.class, BasicTestBeanList.class, BeanMapListBuilder.class, + BasicTestMessageProto.class, BasicTestMessageMapOrBuilder.class, BasicTestMessageMap.class, + ProtoMapMapper.class }) +@WithServiceImplementation(provides = AccessorNamingStrategy.class, value = ProtobufAccessorNamingStrategy.class) +public class ProtoMapTest { + + @ProcessorTest + public void testToMap() { + BasicTestBeanMap source = BeanMapListBuilder.getMapFull(); + BasicTestMessageMap actual = ProtoMapMapper.INSTANCE.toMap( source ); + Assertions.assertEquals( ProtoMapListBuilder.getMapFull().getTestStrMapMap(), + actual.getTestStrMapMap() ); + } + + @ProcessorTest + public void testUpdateMap() { + BasicTestBeanMap source = BeanMapListBuilder.getMapFull(); + BasicTestMessageMap actual = ProtoMapListBuilder.getMapNull(); + actual = ProtoMapMapper.INSTANCE.updateMap( actual, source ); + Assertions.assertEquals( ProtoMapListBuilder.getMapFull().getTestStrMapMap(), + actual.getTestStrMapMap() ); + } + +} diff --git a/processor/src/test/java/org/mapstruct/ap/protobuf/test/source/BasicTestBeanList.java b/processor/src/test/java/org/mapstruct/ap/protobuf/test/source/BasicTestBeanList.java new file mode 100644 index 0000000000..40f3885f01 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/protobuf/test/source/BasicTestBeanList.java @@ -0,0 +1,29 @@ +/* + * Copyright MapStruct Authors. + * + * Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 + */ + +package org.mapstruct.ap.protobuf.test.source; + +import java.util.List; + +/** + * Basic Map. + * + * @author CGD + * + */ +public class BasicTestBeanList { + + List testStrList; + + public List getTestStrList() { + return testStrList; + } + + public void setTestStrList(List testStrList) { + this.testStrList = testStrList; + } + +} diff --git a/processor/src/test/java/org/mapstruct/ap/protobuf/test/source/BasicTestBeanMap.java b/processor/src/test/java/org/mapstruct/ap/protobuf/test/source/BasicTestBeanMap.java new file mode 100644 index 0000000000..6d776f8e21 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/protobuf/test/source/BasicTestBeanMap.java @@ -0,0 +1,29 @@ +/* + * Copyright MapStruct Authors. + * + * Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 + */ + +package org.mapstruct.ap.protobuf.test.source; + +import java.util.Map; + +/** + * Basic Map. + * + * @author CGD + * + */ +public class BasicTestBeanMap { + + Map testStrMap; + + public Map getTestStrMap() { + return testStrMap; + } + + public void setTestStrMap(Map testStrMap) { + this.testStrMap = testStrMap; + } + +} diff --git a/processor/src/test/java/org/mapstruct/ap/protobuf/test/source/BasicTestIntBeanList.java b/processor/src/test/java/org/mapstruct/ap/protobuf/test/source/BasicTestIntBeanList.java new file mode 100644 index 0000000000..493d54a374 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/protobuf/test/source/BasicTestIntBeanList.java @@ -0,0 +1,29 @@ +/* + * Copyright MapStruct Authors. + * + * Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 + */ + +package org.mapstruct.ap.protobuf.test.source; + +import java.util.List; + +/** + * Basic Map. + * + * @author CGD + * + */ +public class BasicTestIntBeanList { + + List testIntList; + + public List getTestIntList() { + return testIntList; + } + + public void setTestIntList(List testIntList) { + this.testIntList = testIntList; + } + +} diff --git a/processor/src/test/java/org/mapstruct/ap/protobuf/test/source/BeanMapListBuilder.java b/processor/src/test/java/org/mapstruct/ap/protobuf/test/source/BeanMapListBuilder.java new file mode 100644 index 0000000000..ec6f278388 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/protobuf/test/source/BeanMapListBuilder.java @@ -0,0 +1,116 @@ +/* + * Copyright MapStruct Authors. + * + * Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0 + */ + +package org.mapstruct.ap.protobuf.test.source; + +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; + +/** + * Bean Map List Builder. + * + * @author CGD + * + */ +public class BeanMapListBuilder { + + protected BeanMapListBuilder() { + throw new UnsupportedOperationException(); + } + + /** Null Map . */ + public static BasicTestBeanMap getMapNull() { + return new BasicTestBeanMap(); + } + + /** Empty Map. */ + public static BasicTestBeanMap getMapEmpty() { + BasicTestBeanMap map = new BasicTestBeanMap(); + map.testStrMap = Collections.emptyMap(); + return map; + } + + /** Full Map. */ + public static BasicTestBeanMap getMapFull() { + BasicTestBeanMap map = new BasicTestBeanMap(); + map.testStrMap = new HashMap() { + private static final long serialVersionUID = 1L; + { + put( "a", "a----a" ); + put( "b", "b----b" ); + put( "c", "c----c" ); + } + }; + return map; + } + + /** Default Map. */ + public static BasicTestBeanMap getMapDefault() { + BasicTestBeanMap map = new BasicTestBeanMap(); + map.testStrMap = new HashMap() { + private static final long serialVersionUID = 1L; + + { + put( "a", "a----a" ); + put( "b", "b----b" ); + put( "c", "c----c" ); + put( "d", "" ); + put( "", "IS NULL" ); + } + }; + return map; + } + + /** Exception Map. */ + public static BasicTestBeanMap getMapException() { + BasicTestBeanMap map = new BasicTestBeanMap(); + map.testStrMap = new HashMap() { + private static final long serialVersionUID = 1L; + + { + put( "a", "a----a" ); + put( "b", "b----b" ); + put( "c", "c----c" ); + put( "d", null ); + put( null, "IS NULL" ); + } + }; + return map; + } + + public static BasicTestBeanList getListNull() { + return new BasicTestBeanList(); + } + + /** Empty List. */ + public static BasicTestBeanList getListEmpty() { + BasicTestBeanList list = new BasicTestBeanList(); + list.testStrList = Collections.emptyList(); + return list; + } + + /** Full List. */ + public static BasicTestBeanList getListFull() { + BasicTestBeanList list = new BasicTestBeanList(); + list.testStrList = Arrays.asList( "a", "b", "c" ); + return list; + } + + /** Default List. */ + public static BasicTestBeanList getListDefault() { + BasicTestBeanList list = new BasicTestBeanList(); + list.testStrList = Arrays.asList( "a", "b", "c", "" ); + return list; + } + + /** Exception List. */ + public static BasicTestBeanList getListException() { + BasicTestBeanList list = new BasicTestBeanList(); + list.testStrList = Arrays.asList( "a", "b", "c", null ); + return list; + } +} diff --git a/processor/src/test/java/org/mapstruct/ap/testutil/runner/CompilingExtension.java b/processor/src/test/java/org/mapstruct/ap/testutil/runner/CompilingExtension.java index 7c47d2a2e8..fb9646176e 100644 --- a/processor/src/test/java/org/mapstruct/ap/testutil/runner/CompilingExtension.java +++ b/processor/src/test/java/org/mapstruct/ap/testutil/runner/CompilingExtension.java @@ -24,6 +24,8 @@ import java.util.Properties; import java.util.Set; +import javax.tools.Diagnostic.Kind; + import com.puppycrawl.tools.checkstyle.Checker; import com.puppycrawl.tools.checkstyle.ConfigurationLoader; import com.puppycrawl.tools.checkstyle.DefaultLogger; @@ -109,6 +111,7 @@ private static List buildTestCompilationClasspath() { "core" + File.separator + "target", // MapStruct annotations in single module build "org" + File.separator + "mapstruct" + File.separator + "mapstruct" + File.separator, + "com" + File.separator + "google" + File.separator + "protobuf", "guava" ); @@ -178,8 +181,17 @@ private void assertResult(CompilationOutcomeDescriptor actualResult, ExtensionCo "Compilation succeeded but should have failed." ).isEqualTo( CompilationResult.FAILED ); } + //Remove protobuf WARNING + List actualDiagnostics = new ArrayList<>(); + for ( DiagnosticDescriptor diagnosticDescriptor : actualResult.getDiagnostics() ) { + // mergeFrom, clearField, clearOneof, unknownFields, mergeUnknownFields, allFields + if ( !( Kind.WARNING.equals( diagnosticDescriptor.getKind() ) + && diagnosticDescriptor.getMessage().contains( "mergeUnknownFields" ) )) { + actualDiagnostics.add( diagnosticDescriptor ); + } + } - assertDiagnostics( actualResult.getDiagnostics(), expectedResult.getDiagnostics() ); + assertDiagnostics( actualDiagnostics, expectedResult.getDiagnostics() ); assertNotes( actualResult.getNotes(), expectedResult.getNotes() ); if ( !findAnnotation( testClass, DisableCheckstyle.class ).isPresent() ) {