From 2d09c3dc07301b178e41177b029224b73c2441a5 Mon Sep 17 00:00:00 2001 From: digithuman Date: Mon, 7 Nov 2022 08:55:32 +0800 Subject: [PATCH 01/12] support protobuf --- processor/pom.xml | 11 + .../test/_target/BasicTestMessageList.java | 616 +++++++++++++++ .../BasicTestMessageListOrBuilder.java | 34 + .../test/_target/BasicTestMessageMap.java | 710 ++++++++++++++++++ .../_target/BasicTestMessageMapOrBuilder.java | 45 ++ .../test/_target/BasicTestMessageProto.java | 217 ++++++ .../ap/protobuf/test/map/ProtoMapMapper.java | 15 + .../ap/protobuf/test/map/ProtoMapTest.java | 33 + .../test/source/BasicTestBeanList.java | 24 + .../test/source/BasicTestBeanMap.java | 24 + .../test/source/BeanMapListBuilder.java | 106 +++ .../testutil/runner/CompilingExtension.java | 14 +- 12 files changed, 1848 insertions(+), 1 deletion(-) create mode 100644 processor/src/test/java/org/mapstruct/ap/protobuf/test/_target/BasicTestMessageList.java create mode 100644 processor/src/test/java/org/mapstruct/ap/protobuf/test/_target/BasicTestMessageListOrBuilder.java create mode 100644 processor/src/test/java/org/mapstruct/ap/protobuf/test/_target/BasicTestMessageMap.java create mode 100644 processor/src/test/java/org/mapstruct/ap/protobuf/test/_target/BasicTestMessageMapOrBuilder.java create mode 100644 processor/src/test/java/org/mapstruct/ap/protobuf/test/_target/BasicTestMessageProto.java create mode 100644 processor/src/test/java/org/mapstruct/ap/protobuf/test/map/ProtoMapMapper.java create mode 100644 processor/src/test/java/org/mapstruct/ap/protobuf/test/map/ProtoMapTest.java create mode 100644 processor/src/test/java/org/mapstruct/ap/protobuf/test/source/BasicTestBeanList.java create mode 100644 processor/src/test/java/org/mapstruct/ap/protobuf/test/source/BasicTestBeanMap.java create mode 100644 processor/src/test/java/org/mapstruct/ap/protobuf/test/source/BeanMapListBuilder.java diff --git a/processor/pom.xml b/processor/pom.xml index 12fc615f5f..327e885c52 100644 --- a/processor/pom.xml +++ b/processor/pom.xml @@ -42,6 +42,17 @@ mapstruct provided + + com.google.protobuf + protobuf-java + test + + + com.google.protobuf + protobuf-java-util + 3.21.2 + test + org.eclipse.tycho tycho-compiler-jdt 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..a58b92256f --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/protobuf/test/_target/BasicTestMessageList.java @@ -0,0 +1,616 @@ +// 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..0b1fcde372 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/protobuf/test/_target/BasicTestMessageListOrBuilder.java @@ -0,0 +1,34 @@ +// 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..89f7395613 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/protobuf/test/_target/BasicTestMessageMap.java @@ -0,0 +1,710 @@ +// 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..2d3bf05461 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/protobuf/test/_target/BasicTestMessageMapOrBuilder.java @@ -0,0 +1,45 @@ +// 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..af78c1ec16 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/protobuf/test/_target/BasicTestMessageProto.java @@ -0,0 +1,217 @@ +// 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_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\"\266\001\n\016TestMessageMap\022J\n\016test_ba" + + "sic_map\030\001 \003(\01322.crenjoy.protobuf.TestMes" + + "sageMap.TestBasicMapEntry\032X\n\021TestBasicMa" + + "pEntry\022\013\n\003key\030\001 \001(\t\0222\n\005value\030\002 \001(\0132#.cre" + + "njoy.protobuf.Basic2TestMessage:\0028\001\"O\n\017T" + + "estMessageList\022<\n\017test_basic_list\030\001 \003(\0132" + + "#.crenjoy.protobuf.Basic2TestMessage\"\204\005\n" + + "\021NestedTestMessage\022\023\n\013test_string\030\001 \001(\t\022" + + "\023\n\013test_double\030\002 \001(\001\022\021\n\ttest_bool\030\003 \001(\010\022" + + "<\n\017test_basic_bean\030\004 \001(\0132#.crenjoy.proto" + + "buf.Basic2TestMessage\022I\n\014test_str_map\030\005 " + + "\003(\01323.crenjoy.protobuf.NestedTestMessage" + + ".TestStrMapEntry\022\025\n\rtest_str_list\030\006 \003(\t\022" + + "M\n\016test_basic_map\030\007 \003(\01325.crenjoy.protob" + + "uf.NestedTestMessage.TestBasicMapEntry\022<" + + "\n\017test_basic_list\030\010 \003(\0132#.crenjoy.protob" + + "uf.Basic2TestMessage\022<\n\021test_message_lis" + + "t\030\t \001(\0132!.crenjoy.protobuf.TestMessageLi" + + "st\022:\n\020test_message_map\030\n \001(\0132 .crenjoy.p" + + "rotobuf.TestMessageMap\0321\n\017TestStrMapEntr" + + "y\022\013\n\003key\030\001 \001(\t\022\r\n\005value\030\002 \001(\t:\0028\001\032X\n\021Tes" + + "tBasicMapEntry\022\013\n\003key\030\001 \001(\t\0222\n\005value\030\002 \001" + + "(\0132#.crenjoy.protobuf.Basic2TestMessage:" + + "\0028\001\"\335\002\n\022ConvertTestMessage\022\034\n\024test_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\014test_insta" + + "nt\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_ti" + + "me\030\007 \001(\t\022\034\n\024test_zoned_date_time\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_b" + + "ig_integer\030\014 \001(\t\022\021\n\ttest_uuid\030\r \001(\tB@\n%o" + + "rg.mapstruct.ap.protobuf.test.targetB\025Ba" + + "sicTestMessageProtoP\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_TestMessageMap_descriptor = + getDescriptor().getMessageTypes().get(4); + 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(5); + 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(6); + 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(7); + 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/map/ProtoMapMapper.java b/processor/src/test/java/org/mapstruct/ap/protobuf/test/map/ProtoMapMapper.java new file mode 100644 index 0000000000..d5b6741f22 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/protobuf/test/map/ProtoMapMapper.java @@ -0,0 +1,15 @@ + +package org.mapstruct.ap.protobuf.test.map; + +import org.mapstruct.Mapper; +import org.mapstruct.ap.protobuf.test._target.BasicTestMessageMap; +import org.mapstruct.ap.protobuf.test.source.BasicTestBeanMap; +import org.mapstruct.factory.Mappers; + +@Mapper +public interface ProtoMapMapper { + + ProtoMapMapper INSTANCE = Mappers.getMapper(ProtoMapMapper.class); + + BasicTestMessageMap toMap(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..445cdec81f --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/protobuf/test/map/ProtoMapTest.java @@ -0,0 +1,33 @@ + +package org.mapstruct.ap.protobuf.test.map; + +import org.junit.jupiter.api.extension.RegisterExtension; +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.source.BasicTestBeanList; +import org.mapstruct.ap.protobuf.test.source.BasicTestBeanMap; +import org.mapstruct.ap.protobuf.test.source.BeanMapListBuilder; +import org.mapstruct.ap.testutil.IssueKey; +import org.mapstruct.ap.testutil.ProcessorTest; +import org.mapstruct.ap.testutil.WithClasses; +import org.mapstruct.ap.testutil.runner.GeneratedSource; + +@WithClasses({ BasicTestBeanMap.class, BasicTestBeanList.class, BeanMapListBuilder.class, + BasicTestMessageProto.class, BasicTestMessageMapOrBuilder.class,BasicTestMessageMap.class, + ProtoMapMapper.class }) +@IssueKey("108") +public class ProtoMapTest { + + @RegisterExtension + final GeneratedSource generatedSource = new GeneratedSource() + .addComparisonToFixtureFor(ProtoMapMapper.class); + + @ProcessorTest + public void test() { + // com.google.protobuf.ByteString + BasicTestBeanMap source = BeanMapListBuilder.getMapFull(); + BasicTestMessageMap dto = ProtoMapMapper.INSTANCE.toMap(source); + } + +} 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..8a0641c369 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/protobuf/test/source/BasicTestBeanList.java @@ -0,0 +1,24 @@ + +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..dd5ec25de7 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/protobuf/test/source/BasicTestBeanMap.java @@ -0,0 +1,24 @@ + +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/BeanMapListBuilder.java b/processor/src/test/java/org/mapstruct/ap/protobuf/test/source/BeanMapListBuilder.java new file mode 100644 index 0000000000..510145f0b4 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/protobuf/test/source/BeanMapListBuilder.java @@ -0,0 +1,106 @@ + +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 { + + 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..3c8e8efeb9 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() ) { From 550b2d60ff1dbfef4dc33285526bb6ef09c378a7 Mon Sep 17 00:00:00 2001 From: digithuman Date: Mon, 7 Nov 2022 16:09:33 +0800 Subject: [PATCH 02/12] Add ProtobufAccessorNamingStrategy --- .../util/AnnotationProcessorContext.java | 8 ++ .../spi/ProtobufAccessorNamingStrategy.java | 84 +++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 processor/src/main/java/org/mapstruct/ap/spi/ProtobufAccessorNamingStrategy.java 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..cd368afd4c 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( ProtobufAccessorNamingStrategy.PROTOBUF_MESSAGE_OR_BUILDER ) != null ) { + defaultAccessorNamingStrategy = new ProtobufAccessorNamingStrategy(); + defaultBuilderProvider = new DefaultBuilderProvider(); + if ( verbose ) { + messager.printMessage( Diagnostic.Kind.NOTE, "MapStruct: Protobuf found on classpath" ); + } + } else { defaultAccessorNamingStrategy = new DefaultAccessorNamingStrategy(); defaultBuilderProvider = new DefaultBuilderProvider(); 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..d09a7156bd --- /dev/null +++ b/processor/src/main/java/org/mapstruct/ap/spi/ProtobufAccessorNamingStrategy.java @@ -0,0 +1,84 @@ +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; + +/** + * @author Thomas Kratz + * @author Filip Hrisafov + */ +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" ) && returnTypeName.equals( List.class.getName())) { + 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" ) && returnTypeName.equals( List.class.getName())) { + 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 protobuf method? + * @param method + * @return + */ + protected boolean isProtoBufMethod(ExecutableElement method) { + Element receiver = method.getEnclosingElement(); + if (receiver != null && protobufType != null && typeUtils.isAssignable(receiver.asType(), protobufType)) { + return true; + } + return false; + } + +} From 290734b01bdef0240d3f25eb8ab82f0e831fd874 Mon Sep 17 00:00:00 2001 From: digithuman Date: Mon, 7 Nov 2022 18:51:02 +0800 Subject: [PATCH 03/12] Change FreeMarker Fix UnsupportedOperationException --- processor/pom.xml | 6 -- .../GetterWrapperForCollectionsAndMaps.ftl | 8 ++ .../test/_target/ProtoMapListBuilder.java | 73 +++++++++++++++++++ .../ap/protobuf/test/map/ProtoMapMapper.java | 12 +++ .../ap/protobuf/test/map/ProtoMapTest.java | 26 ++++--- 5 files changed, 108 insertions(+), 17 deletions(-) create mode 100644 processor/src/test/java/org/mapstruct/ap/protobuf/test/_target/ProtoMapListBuilder.java diff --git a/processor/pom.xml b/processor/pom.xml index 327e885c52..e4dabf3b04 100644 --- a/processor/pom.xml +++ b/processor/pom.xml @@ -47,12 +47,6 @@ protobuf-java test - - com.google.protobuf - protobuf-java-util - 3.21.2 - test - org.eclipse.tycho tycho-compiler-jdt 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..094265cccf 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<#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/ProtoMapListBuilder.java b/processor/src/test/java/org/mapstruct/ap/protobuf/test/_target/ProtoMapListBuilder.java new file mode 100644 index 0000000000..5bb52564b9 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/protobuf/test/_target/ProtoMapListBuilder.java @@ -0,0 +1,73 @@ + +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 { + + public static BasicTestMessageMap getMapNull() { + return BasicTestMessageMap.newBuilder().build(); + } + + 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/ProtoMapMapper.java b/processor/src/test/java/org/mapstruct/ap/protobuf/test/map/ProtoMapMapper.java index d5b6741f22..891285d91f 100644 --- 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 @@ -2,6 +2,7 @@ package org.mapstruct.ap.protobuf.test.map; import org.mapstruct.Mapper; +import org.mapstruct.MappingTarget; import org.mapstruct.ap.protobuf.test._target.BasicTestMessageMap; import org.mapstruct.ap.protobuf.test.source.BasicTestBeanMap; import org.mapstruct.factory.Mappers; @@ -12,4 +13,15 @@ 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(@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 index 445cdec81f..7094b80887 100644 --- 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 @@ -1,33 +1,37 @@ package org.mapstruct.ap.protobuf.test.map; -import org.junit.jupiter.api.extension.RegisterExtension; +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.testutil.IssueKey; import org.mapstruct.ap.testutil.ProcessorTest; import org.mapstruct.ap.testutil.WithClasses; -import org.mapstruct.ap.testutil.runner.GeneratedSource; @WithClasses({ BasicTestBeanMap.class, BasicTestBeanList.class, BeanMapListBuilder.class, - BasicTestMessageProto.class, BasicTestMessageMapOrBuilder.class,BasicTestMessageMap.class, + BasicTestMessageProto.class, BasicTestMessageMapOrBuilder.class, BasicTestMessageMap.class, ProtoMapMapper.class }) -@IssueKey("108") public class ProtoMapTest { - @RegisterExtension - final GeneratedSource generatedSource = new GeneratedSource() - .addComparisonToFixtureFor(ProtoMapMapper.class); + @ProcessorTest + public void testToMap() { + BasicTestBeanMap source = BeanMapListBuilder.getMapFull(); + BasicTestMessageMap actual = ProtoMapMapper.INSTANCE.toMap(source); + Assertions.assertEquals(ProtoMapListBuilder.getMapFull().getTestStrMapMap(), + actual.getTestStrMapMap()); + } @ProcessorTest - public void test() { - // com.google.protobuf.ByteString + public void testUpdateMap() { BasicTestBeanMap source = BeanMapListBuilder.getMapFull(); - BasicTestMessageMap dto = ProtoMapMapper.INSTANCE.toMap(source); + BasicTestMessageMap actual = ProtoMapListBuilder.getMapNull(); + actual = ProtoMapMapper.INSTANCE.updateMap(actual, source); + Assertions.assertEquals(ProtoMapListBuilder.getMapFull().getTestStrMapMap(), + actual.getTestStrMapMap()); } } From 42d5af9e2db11b95a55cd76272da87720cf94d02 Mon Sep 17 00:00:00 2001 From: digithuman Date: Mon, 7 Nov 2022 20:30:35 +0800 Subject: [PATCH 04/12] BUG --- .../ap/internal/util/AnnotationProcessorContext.java | 7 ------- .../mapstruct/ap/spi/ProtobufAccessorNamingStrategy.java | 3 +++ .../org/mapstruct/ap/protobuf/test/map/ProtoMapTest.java | 4 ++++ .../mapstruct/ap/testutil/runner/CompilingExtension.java | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) 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 cd368afd4c..8a123e2a9f 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 @@ -95,13 +95,6 @@ else if ( elementUtils.getTypeElement( FreeBuilderConstants.FREE_BUILDER_FQN ) ! messager.printMessage( Diagnostic.Kind.NOTE, "MapStruct: Freebuilder found on classpath" ); } } - else if ( elementUtils.getTypeElement( ProtobufAccessorNamingStrategy.PROTOBUF_MESSAGE_OR_BUILDER ) != null ) { - defaultAccessorNamingStrategy = new ProtobufAccessorNamingStrategy(); - defaultBuilderProvider = new DefaultBuilderProvider(); - if ( verbose ) { - messager.printMessage( Diagnostic.Kind.NOTE, "MapStruct: Protobuf found on classpath" ); - } - } else { defaultAccessorNamingStrategy = new DefaultAccessorNamingStrategy(); defaultBuilderProvider = new DefaultBuilderProvider(); diff --git a/processor/src/main/java/org/mapstruct/ap/spi/ProtobufAccessorNamingStrategy.java b/processor/src/main/java/org/mapstruct/ap/spi/ProtobufAccessorNamingStrategy.java index d09a7156bd..d84bca0231 100644 --- a/processor/src/main/java/org/mapstruct/ap/spi/ProtobufAccessorNamingStrategy.java +++ b/processor/src/main/java/org/mapstruct/ap/spi/ProtobufAccessorNamingStrategy.java @@ -8,10 +8,13 @@ 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"; 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 index 7094b80887..5dd7471ea5 100644 --- 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 @@ -9,12 +9,16 @@ 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 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 3c8e8efeb9..d3f45e5986 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 @@ -186,7 +186,7 @@ private void assertResult(CompilationOutcomeDescriptor actualResult, ExtensionCo 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") ) { + if (!(Kind.WARNING.equals(diagnosticDescriptor.getKind()) && diagnosticDescriptor.getMessage().contains("mergeUnknownFields") )) { actualDiagnostics.add(diagnosticDescriptor); } } From dd81de23540639f35c762cefd677ae1293402a81 Mon Sep 17 00:00:00 2001 From: digithuman Date: Mon, 7 Nov 2022 23:32:33 +0800 Subject: [PATCH 05/12] checkstyle --- parent/pom.xml | 2 +- .../util/AnnotationProcessorContext.java | 1 - .../spi/ProtobufAccessorNamingStrategy.java | 45 ++++++++++-------- .../test/_target/BasicTestMessageList.java | 5 ++ .../BasicTestMessageListOrBuilder.java | 5 ++ .../test/_target/BasicTestMessageMap.java | 5 ++ .../_target/BasicTestMessageMapOrBuilder.java | 5 ++ .../test/_target/BasicTestMessageProto.java | 5 ++ .../test/_target/ProtoMapListBuilder.java | 43 ++++++++++------- .../ap/protobuf/test/map/ProtoMapMapper.java | 15 +++--- .../ap/protobuf/test/map/ProtoMapTest.java | 17 ++++--- .../test/source/BasicTestBeanList.java | 5 ++ .../test/source/BasicTestBeanMap.java | 5 ++ .../test/source/BeanMapListBuilder.java | 46 +++++++++++-------- .../testutil/runner/CompilingExtension.java | 18 ++++---- 15 files changed, 145 insertions(+), 77 deletions(-) diff --git a/parent/pom.xml b/parent/pom.xml index e87db14551..2fc3d7cb0e 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -368,7 +368,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/processor/src/main/java/org/mapstruct/ap/internal/util/AnnotationProcessorContext.java b/processor/src/main/java/org/mapstruct/ap/internal/util/AnnotationProcessorContext.java index 8a123e2a9f..7421dfde7a 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,7 +32,6 @@ 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"). diff --git a/processor/src/main/java/org/mapstruct/ap/spi/ProtobufAccessorNamingStrategy.java b/processor/src/main/java/org/mapstruct/ap/spi/ProtobufAccessorNamingStrategy.java index d84bca0231..3afd8d9396 100644 --- a/processor/src/main/java/org/mapstruct/ap/spi/ProtobufAccessorNamingStrategy.java +++ b/processor/src/main/java/org/mapstruct/ap/spi/ProtobufAccessorNamingStrategy.java @@ -1,3 +1,8 @@ +/* + * 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; @@ -20,57 +25,57 @@ public class ProtobufAccessorNamingStrategy extends DefaultAccessorNamingStrateg 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); + 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)) { + 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" ) && returnTypeName.equals( List.class.getName())) { + if (getterMethod && isProtoBufMethod( method ) && !methodName.endsWith( "List" ) + && returnTypeName.equals( List.class.getName() )) { return false; } - if (getterMethod && isProtoBufMethod(method) && !methodName.endsWith( "Map" ) && returnTypeName.equals( Map.class.getName())) { + 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)) { + String propertyName = super.getPropertyName( getterOrSetterMethod ); + if (!isProtoBufMethod( getterOrSetterMethod )) { return propertyName; } - + String returnTypeName = typeUtils.erasure( getterOrSetterMethod.getReturnType() ).toString(); - if (isProtoBufMethod(getterOrSetterMethod) && propertyName.endsWith( "List" ) && returnTypeName.equals( List.class.getName())) { - propertyName = propertyName.substring(0, propertyName.length() - 4); + if (isProtoBufMethod( getterOrSetterMethod ) && propertyName.endsWith( "List" ) + && returnTypeName.equals( List.class.getName() )) { + 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); + if (isProtoBufMethod( getterOrSetterMethod ) && propertyName.endsWith( "Map" ) + && returnTypeName.equals( Map.class.getName() )) { + propertyName = propertyName.substring( 0, propertyName.length() - 3 ); return propertyName; } return propertyName; } - + /** * is protobuf method? * @param method @@ -78,7 +83,7 @@ public String getPropertyName(ExecutableElement getterOrSetterMethod) { */ protected boolean isProtoBufMethod(ExecutableElement method) { Element receiver = method.getEnclosingElement(); - if (receiver != null && protobufType != null && typeUtils.isAssignable(receiver.asType(), protobufType)) { + if (receiver != null && protobufType != null && typeUtils.isAssignable( receiver.asType(), protobufType )) { return true; } return false; 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 index a58b92256f..69c1f8f67f 100644 --- 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 @@ -1,3 +1,8 @@ +/* + * 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 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 index 0b1fcde372..b9bfbb71f6 100644 --- 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 @@ -1,3 +1,8 @@ +/* + * 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 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 index 89f7395613..0fb7d6dcef 100644 --- 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 @@ -1,3 +1,8 @@ +/* + * 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 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 index 2d3bf05461..642b804e09 100644 --- 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 @@ -1,3 +1,8 @@ +/* + * 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 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 index af78c1ec16..2298210d3e 100644 --- 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 @@ -1,3 +1,8 @@ +/* + * 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 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 index 5bb52564b9..079c751ada 100644 --- 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 @@ -1,3 +1,8 @@ +/* + * 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; @@ -15,12 +20,18 @@ */ 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(); + return BasicTestMessageMap.newBuilder().putAllTestStrMap( Collections.emptyMap() ).build(); } /** Full Map . */ @@ -28,12 +39,12 @@ 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"); + put( "a", "a----a" ); + put( "b", "b----b" ); + put( "c", "c----c" ); } }; - BasicTestMessageMap map = BasicTestMessageMap.newBuilder().putAllTestStrMap(maps).build(); + BasicTestMessageMap map = BasicTestMessageMap.newBuilder().putAllTestStrMap( maps ).build(); return map; } @@ -42,14 +53,14 @@ 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"); + put( "a", "a----a" ); + put( "b", "b----b" ); + put( "c", "c----c" ); + put( "d", "" ); + put( "", "IS NULL" ); } }; - BasicTestMessageMap map = BasicTestMessageMap.newBuilder().putAllTestStrMap(maps).build(); + BasicTestMessageMap map = BasicTestMessageMap.newBuilder().putAllTestStrMap( maps ).build(); return map; } @@ -58,16 +69,16 @@ public static BasicTestMessageList getListNull() { } public static BasicTestMessageList getListEmpty() { - return BasicTestMessageList.newBuilder().addAllTestStrList(Collections.emptyList()).build(); + return BasicTestMessageList.newBuilder().addAllTestStrList( Collections.emptyList() ).build(); } public static BasicTestMessageList getListFull() { - List list = Arrays.asList("a", "b", "c"); - return BasicTestMessageList.newBuilder().addAllTestStrList(list).build(); + 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(); + 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/ProtoMapMapper.java b/processor/src/test/java/org/mapstruct/ap/protobuf/test/map/ProtoMapMapper.java index 891285d91f..1472d3b6c0 100644 --- 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 @@ -1,16 +1,19 @@ +/* + * 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.Mapper; -import org.mapstruct.MappingTarget; import org.mapstruct.ap.protobuf.test._target.BasicTestMessageMap; import org.mapstruct.ap.protobuf.test.source.BasicTestBeanMap; import org.mapstruct.factory.Mappers; -@Mapper +@org.mapstruct.Mapper public interface ProtoMapMapper { - ProtoMapMapper INSTANCE = Mappers.getMapper(ProtoMapMapper.class); + ProtoMapMapper INSTANCE = Mappers.getMapper( ProtoMapMapper.class ); BasicTestMessageMap toMap(BasicTestBeanMap beanMap); @@ -19,9 +22,9 @@ public interface ProtoMapMapper { */ default BasicTestMessageMap updateMap(BasicTestMessageMap msgMap, BasicTestBeanMap beanMap) { BasicTestMessageMap.Builder builder = msgMap.toBuilder(); - updateMap(builder, beanMap); + updateMap( builder, beanMap ); return builder.build(); } - void updateMap(@MappingTarget BasicTestMessageMap.Builder msgMap, BasicTestBeanMap beanMap); + 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 index 5dd7471ea5..f727e80487 100644 --- 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 @@ -1,3 +1,8 @@ +/* + * 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; @@ -24,18 +29,18 @@ public class ProtoMapTest { @ProcessorTest public void testToMap() { BasicTestBeanMap source = BeanMapListBuilder.getMapFull(); - BasicTestMessageMap actual = ProtoMapMapper.INSTANCE.toMap(source); - Assertions.assertEquals(ProtoMapListBuilder.getMapFull().getTestStrMapMap(), - actual.getTestStrMapMap()); + 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()); + 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 index 8a0641c369..40f3885f01 100644 --- 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 @@ -1,3 +1,8 @@ +/* + * 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; 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 index dd5ec25de7..6d776f8e21 100644 --- 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 @@ -1,3 +1,8 @@ +/* + * 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; 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 index 510145f0b4..ec6f278388 100644 --- 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 @@ -1,3 +1,8 @@ +/* + * 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; @@ -13,6 +18,11 @@ */ public class BeanMapListBuilder { + protected BeanMapListBuilder() { + throw new UnsupportedOperationException(); + } + + /** Null Map . */ public static BasicTestBeanMap getMapNull() { return new BasicTestBeanMap(); } @@ -30,14 +40,14 @@ public static BasicTestBeanMap getMapFull() { map.testStrMap = new HashMap() { private static final long serialVersionUID = 1L; { - put("a", "a----a"); - put("b", "b----b"); - put("c", "c----c"); + put( "a", "a----a" ); + put( "b", "b----b" ); + put( "c", "c----c" ); } }; return map; } - + /** Default Map. */ public static BasicTestBeanMap getMapDefault() { BasicTestBeanMap map = new BasicTestBeanMap(); @@ -45,11 +55,11 @@ public static BasicTestBeanMap getMapDefault() { private static final long serialVersionUID = 1L; { - put("a", "a----a"); - put("b", "b----b"); - put("c", "c----c"); - put("d", ""); - put("", "IS NULL"); + put( "a", "a----a" ); + put( "b", "b----b" ); + put( "c", "c----c" ); + put( "d", "" ); + put( "", "IS NULL" ); } }; return map; @@ -62,11 +72,11 @@ public static BasicTestBeanMap getMapException() { 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"); + put( "a", "a----a" ); + put( "b", "b----b" ); + put( "c", "c----c" ); + put( "d", null ); + put( null, "IS NULL" ); } }; return map; @@ -86,21 +96,21 @@ public static BasicTestBeanList getListEmpty() { /** Full List. */ public static BasicTestBeanList getListFull() { BasicTestBeanList list = new BasicTestBeanList(); - list.testStrList = Arrays.asList("a", "b", "c"); + 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", ""); + 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); + 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 d3f45e5986..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 @@ -111,7 +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", + "com" + File.separator + "google" + File.separator + "protobuf", "guava" ); @@ -181,17 +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); - } + 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(actualDiagnostics, expectedResult.getDiagnostics() ); + assertDiagnostics( actualDiagnostics, expectedResult.getDiagnostics() ); assertNotes( actualResult.getNotes(), expectedResult.getNotes() ); if ( !findAnnotation( testClass, DisableCheckstyle.class ).isPresent() ) { From d7601043475f034011c92c71b936238ac004ef0e Mon Sep 17 00:00:00 2001 From: digithuman Date: Tue, 8 Nov 2022 00:34:37 +0800 Subject: [PATCH 06/12] protobuf List --- .../spi/ProtobufAccessorNamingStrategy.java | 14 +++++- .../GetterWrapperForCollectionsAndMaps.ftl | 2 +- .../ap/protobuf/test/map/ProtoListMapper.java | 50 +++++++++++++++++++ .../ap/protobuf/test/map/ProtoListTest.java | 46 +++++++++++++++++ 4 files changed, 109 insertions(+), 3 deletions(-) create mode 100644 processor/src/test/java/org/mapstruct/ap/protobuf/test/map/ProtoListMapper.java create mode 100644 processor/src/test/java/org/mapstruct/ap/protobuf/test/map/ProtoListTest.java diff --git a/processor/src/main/java/org/mapstruct/ap/spi/ProtobufAccessorNamingStrategy.java b/processor/src/main/java/org/mapstruct/ap/spi/ProtobufAccessorNamingStrategy.java index 3afd8d9396..a4dfa59a70 100644 --- a/processor/src/main/java/org/mapstruct/ap/spi/ProtobufAccessorNamingStrategy.java +++ b/processor/src/main/java/org/mapstruct/ap/spi/ProtobufAccessorNamingStrategy.java @@ -45,7 +45,7 @@ public boolean isGetterMethod(ExecutableElement method) { String methodName = method.getSimpleName().toString(); String returnTypeName = typeUtils.erasure( method.getReturnType() ).toString(); if (getterMethod && isProtoBufMethod( method ) && !methodName.endsWith( "List" ) - && returnTypeName.equals( List.class.getName() )) { + && isGetterListMethod( returnTypeName )) { return false; } if (getterMethod && isProtoBufMethod( method ) && !methodName.endsWith( "Map" ) @@ -64,7 +64,7 @@ public String getPropertyName(ExecutableElement getterOrSetterMethod) { String returnTypeName = typeUtils.erasure( getterOrSetterMethod.getReturnType() ).toString(); if (isProtoBufMethod( getterOrSetterMethod ) && propertyName.endsWith( "List" ) - && returnTypeName.equals( List.class.getName() )) { + && isGetterListMethod( returnTypeName )) { propertyName = propertyName.substring( 0, propertyName.length() - 4 ); return propertyName; } @@ -75,6 +75,16 @@ public String getPropertyName(ExecutableElement getterOrSetterMethod) { } 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? 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 094265cccf..1eb701b0b4 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 @@ -19,7 +19,7 @@ if ( ${ext.targetBeanName}.${ext.targetWriteAccessorName}<@lib.handleWriteAccesi <@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<#else>putAll${ext.targetPropertyName?cap_first}( <@lib.handleWithAssignmentOrNullCheckVar/> ); + ${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/map/ProtoListMapper.java b/processor/src/test/java/org/mapstruct/ap/protobuf/test/map/ProtoListMapper.java new file mode 100644 index 0000000000..16cd5e772d --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/protobuf/test/map/ProtoListMapper.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 com.google.protobuf.LazyStringArrayList; +import com.google.protobuf.ProtocolStringList; + +import java.util.List; + +import org.mapstruct.MappingTarget; +import org.mapstruct.ap.protobuf.test._target.BasicTestMessageList; +import org.mapstruct.ap.protobuf.test.source.BasicTestBeanList; +import org.mapstruct.factory.Mappers; + +@org.mapstruct.Mapper +public interface ProtoListMapper { + + ProtoListMapper INSTANCE = Mappers.getMapper( ProtoListMapper.class ); + + 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(@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..e7b4252e03 --- /dev/null +++ b/processor/src/test/java/org/mapstruct/ap/protobuf/test/map/ProtoListTest.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.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.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, BasicTestMessageListOrBuilder.class, BasicTestMessageList.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() ); + } + +} From 64b3022cb2722543900a1bacb7cf22ea65111e2a Mon Sep 17 00:00:00 2001 From: digithuman Date: Tue, 8 Nov 2022 00:46:02 +0800 Subject: [PATCH 07/12] checkstyle --- .../ap/spi/ProtobufAccessorNamingStrategy.java | 4 ++-- .../ap/protobuf/test/map/ProtoListMapper.java | 11 +++++------ .../mapstruct/ap/protobuf/test/map/ProtoListTest.java | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/processor/src/main/java/org/mapstruct/ap/spi/ProtobufAccessorNamingStrategy.java b/processor/src/main/java/org/mapstruct/ap/spi/ProtobufAccessorNamingStrategy.java index a4dfa59a70..3cb07705b5 100644 --- a/processor/src/main/java/org/mapstruct/ap/spi/ProtobufAccessorNamingStrategy.java +++ b/processor/src/main/java/org/mapstruct/ap/spi/ProtobufAccessorNamingStrategy.java @@ -75,14 +75,14 @@ && isGetterListMethod( returnTypeName )) { } return propertyName; } - + /** * is Getter List Method? * @param returnTypeName * @return */ protected boolean isGetterListMethod(String returnTypeName) { - return returnTypeName.equals( List.class.getName() ) + return returnTypeName.equals( List.class.getName() ) || returnTypeName.equals( "com.google.protobuf.ProtocolStringList" ); } 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 index 16cd5e772d..766ca52d96 100644 --- 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 @@ -11,7 +11,6 @@ import java.util.List; -import org.mapstruct.MappingTarget; import org.mapstruct.ap.protobuf.test._target.BasicTestMessageList; import org.mapstruct.ap.protobuf.test.source.BasicTestBeanList; import org.mapstruct.factory.Mappers; @@ -33,18 +32,18 @@ default BasicTestMessageList updateList(BasicTestMessageList msgList, return builder.build(); } - void updateList(@MappingTarget BasicTestMessageList.Builder msgList, BasicTestBeanList beanList); - + 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); + 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 index e7b4252e03..eacaa5d49e 100644 --- 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 @@ -25,7 +25,7 @@ ProtoListMapper.class }) @WithServiceImplementation(provides = AccessorNamingStrategy.class, value = ProtobufAccessorNamingStrategy.class) public class ProtoListTest { - + @ProcessorTest public void testToList() { BasicTestBeanList source = BeanMapListBuilder.getListFull(); From ef99d41f46d7d5d575161e2c56b07873817f7acc Mon Sep 17 00:00:00 2001 From: digithuman Date: Tue, 8 Nov 2022 09:36:41 +0800 Subject: [PATCH 08/12] load Protobuf --- .../util/AnnotationProcessorContext.java | 8 ++++++++ .../ap/internal/util/ProtobufConstants.java | 20 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 processor/src/main/java/org/mapstruct/ap/internal/util/ProtobufConstants.java 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() { + + } +} From 1db8290d0b823c45f56041489e94eae4e09265e1 Mon Sep 17 00:00:00 2001 From: digithuman Date: Wed, 9 Nov 2022 08:22:57 +0800 Subject: [PATCH 09/12] isProtobufPrimitiveCollectionType Process --- .../ap/internal/model/common/Type.java | 34 + .../spi/ProtobufAccessorNamingStrategy.java | 14 +- .../GetterWrapperForCollectionsAndMaps.ftl | 6 +- .../test/_target/BasicTestIntMessageList.java | 606 ++++++++++++++++++ .../BasicTestIntMessageListOrBuilder.java | 31 + .../test/_target/BasicTestMessageProto.java | 88 +-- .../ap/protobuf/test/map/ProtoListMapper.java | 6 + .../ap/protobuf/test/map/ProtoListTest.java | 10 +- .../test/source/BasicTestIntBeanList.java | 29 + 9 files changed, 774 insertions(+), 50 deletions(-) create mode 100644 processor/src/test/java/org/mapstruct/ap/protobuf/test/_target/BasicTestIntMessageList.java create mode 100644 processor/src/test/java/org/mapstruct/ap/protobuf/test/_target/BasicTestIntMessageListOrBuilder.java create mode 100644 processor/src/test/java/org/mapstruct/ap/protobuf/test/source/BasicTestIntBeanList.java 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..8fcfe40469 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,40 @@ public boolean isCollectionOrMapType() { return isCollectionType || isMapType; } + /** + * CollectionType and typeParameters is Protobuf Primitive. + */ + public boolean isProtobufPrimitiveCollectionType() { + if (isCollectionType) { + if ("com.google.protobuf.ProtocolStringList".equals( this.qualifiedName )) { + return true; + } + List typeParameters = getTypeParameters(); + if ( typeParameters.size() == 1 && typeParameters.get( 0 ).packageName.equals( "java.lang" ) ) { + return true; + } + } + return false; + } + + /** + * MapType and TypeParameters is Protobuf Primitive. + */ + public boolean isProtobufPrimitiveMapType() { + if (isMapType) { + List typeParameters = getTypeParameters(); + if ( typeParameters.size() == 2 && typeParameters.get( 0 ).packageName.equals( "java.lang" ) + && typeParameters.get( 1 ).packageName.equals( "java.lang" ) ) { + return true; + } + } + return false; + } + + public boolean isProtobufPrimitiveCollectionOrMapType() { + return isProtobufPrimitiveCollectionType() || isProtobufPrimitiveMapType(); + } + public boolean isArrayType() { return componentType != null; } diff --git a/processor/src/main/java/org/mapstruct/ap/spi/ProtobufAccessorNamingStrategy.java b/processor/src/main/java/org/mapstruct/ap/spi/ProtobufAccessorNamingStrategy.java index 3cb07705b5..fcdd8dbaba 100644 --- a/processor/src/main/java/org/mapstruct/ap/spi/ProtobufAccessorNamingStrategy.java +++ b/processor/src/main/java/org/mapstruct/ap/spi/ProtobufAccessorNamingStrategy.java @@ -39,16 +39,16 @@ public void init(MapStructProcessingEnvironment processingEnvironment) { @Override public boolean isGetterMethod(ExecutableElement method) { boolean getterMethod = super.isGetterMethod( method ); - if (!isProtoBufMethod( 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" ) + if (getterMethod && isProtobufMethod( method ) && !methodName.endsWith( "List" ) && isGetterListMethod( returnTypeName )) { return false; } - if (getterMethod && isProtoBufMethod( method ) && !methodName.endsWith( "Map" ) + if (getterMethod && isProtobufMethod( method ) && !methodName.endsWith( "Map" ) && returnTypeName.equals( Map.class.getName() )) { return false; } @@ -58,17 +58,17 @@ && isGetterListMethod( returnTypeName )) { @Override public String getPropertyName(ExecutableElement getterOrSetterMethod) { String propertyName = super.getPropertyName( getterOrSetterMethod ); - if (!isProtoBufMethod( getterOrSetterMethod )) { + if (!isProtobufMethod( getterOrSetterMethod )) { return propertyName; } String returnTypeName = typeUtils.erasure( getterOrSetterMethod.getReturnType() ).toString(); - if (isProtoBufMethod( getterOrSetterMethod ) && propertyName.endsWith( "List" ) + if (isProtobufMethod( getterOrSetterMethod ) && propertyName.endsWith( "List" ) && isGetterListMethod( returnTypeName )) { propertyName = propertyName.substring( 0, propertyName.length() - 4 ); return propertyName; } - if (isProtoBufMethod( getterOrSetterMethod ) && propertyName.endsWith( "Map" ) + if (isProtobufMethod( getterOrSetterMethod ) && propertyName.endsWith( "Map" ) && returnTypeName.equals( Map.class.getName() )) { propertyName = propertyName.substring( 0, propertyName.length() - 3 ); return propertyName; @@ -91,7 +91,7 @@ protected boolean isGetterListMethod(String returnTypeName) { * @param method * @return */ - protected boolean isProtoBufMethod(ExecutableElement method) { + public boolean isProtobufMethod(ExecutableElement method) { Element receiver = method.getEnclosingElement(); if (receiver != null && protobufType != null && typeUtils.isAssignable( receiver.asType(), protobufType )) { return true; 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 1eb701b0b4..8e297189d1 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,14 +11,16 @@ 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" > + <#if ext.targetType.protobufPrimitiveCollectionOrMapType && + ( "${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" > + <#if ext.targetType.protobufPrimitiveCollectionOrMapType && + ( "${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/BasicTestMessageProto.java b/processor/src/test/java/org/mapstruct/ap/protobuf/test/_target/BasicTestMessageProto.java index 2298210d3e..8fac588058 100644 --- 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 @@ -44,6 +44,11 @@ public static void registerAllExtensions( 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 @@ -105,40 +110,41 @@ public static void registerAllExtensions( "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\"\266\001\n\016TestMessageMap\022J\n\016test_ba" + - "sic_map\030\001 \003(\01322.crenjoy.protobuf.TestMes" + - "sageMap.TestBasicMapEntry\032X\n\021TestBasicMa" + - "pEntry\022\013\n\003key\030\001 \001(\t\0222\n\005value\030\002 \001(\0132#.cre" + - "njoy.protobuf.Basic2TestMessage:\0028\001\"O\n\017T" + - "estMessageList\022<\n\017test_basic_list\030\001 \003(\0132" + - "#.crenjoy.protobuf.Basic2TestMessage\"\204\005\n" + - "\021NestedTestMessage\022\023\n\013test_string\030\001 \001(\t\022" + - "\023\n\013test_double\030\002 \001(\001\022\021\n\ttest_bool\030\003 \001(\010\022" + - "<\n\017test_basic_bean\030\004 \001(\0132#.crenjoy.proto" + - "buf.Basic2TestMessage\022I\n\014test_str_map\030\005 " + - "\003(\01323.crenjoy.protobuf.NestedTestMessage" + - ".TestStrMapEntry\022\025\n\rtest_str_list\030\006 \003(\t\022" + - "M\n\016test_basic_map\030\007 \003(\01325.crenjoy.protob" + - "uf.NestedTestMessage.TestBasicMapEntry\022<" + - "\n\017test_basic_list\030\010 \003(\0132#.crenjoy.protob" + - "uf.Basic2TestMessage\022<\n\021test_message_lis" + - "t\030\t \001(\0132!.crenjoy.protobuf.TestMessageLi" + - "st\022:\n\020test_message_map\030\n \001(\0132 .crenjoy.p" + - "rotobuf.TestMessageMap\0321\n\017TestStrMapEntr" + - "y\022\013\n\003key\030\001 \001(\t\022\r\n\005value\030\002 \001(\t:\0028\001\032X\n\021Tes" + - "tBasicMapEntry\022\013\n\003key\030\001 \001(\t\0222\n\005value\030\002 \001" + - "(\0132#.crenjoy.protobuf.Basic2TestMessage:" + - "\0028\001\"\335\002\n\022ConvertTestMessage\022\034\n\024test_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\014test_insta" + - "nt\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_ti" + - "me\030\007 \001(\t\022\034\n\024test_zoned_date_time\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_b" + - "ig_integer\030\014 \001(\t\022\021\n\ttest_uuid\030\r \001(\tB@\n%o" + - "rg.mapstruct.ap.protobuf.test.targetB\025Ba" + - "sicTestMessageProtoP\001b\006proto3" + "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, @@ -174,8 +180,14 @@ public static void registerAllExtensions( com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_crenjoy_protobuf_BasicTestMessageList_descriptor, new java.lang.String[] { "TestStrList", }); - internal_static_crenjoy_protobuf_TestMessageMap_descriptor = + 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, @@ -187,13 +199,13 @@ public static void registerAllExtensions( internal_static_crenjoy_protobuf_TestMessageMap_TestBasicMapEntry_descriptor, new java.lang.String[] { "Key", "Value", }); internal_static_crenjoy_protobuf_TestMessageList_descriptor = - getDescriptor().getMessageTypes().get(5); + 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(6); + getDescriptor().getMessageTypes().get(7); internal_static_crenjoy_protobuf_NestedTestMessage_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_crenjoy_protobuf_NestedTestMessage_descriptor, @@ -211,7 +223,7 @@ public static void registerAllExtensions( internal_static_crenjoy_protobuf_NestedTestMessage_TestBasicMapEntry_descriptor, new java.lang.String[] { "Key", "Value", }); internal_static_crenjoy_protobuf_ConvertTestMessage_descriptor = - getDescriptor().getMessageTypes().get(7); + getDescriptor().getMessageTypes().get(8); internal_static_crenjoy_protobuf_ConvertTestMessage_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_crenjoy_protobuf_ConvertTestMessage_descriptor, 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 index 766ca52d96..5d2e282841 100644 --- 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 @@ -11,8 +11,10 @@ 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 @@ -20,6 +22,10 @@ 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); /** 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 index eacaa5d49e..738315a4e4 100644 --- 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 @@ -7,12 +7,15 @@ 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; @@ -20,9 +23,10 @@ import org.mapstruct.ap.testutil.WithClasses; import org.mapstruct.ap.testutil.WithServiceImplementation; -@WithClasses({ BasicTestBeanMap.class, BasicTestBeanList.class, BeanMapListBuilder.class, - BasicTestMessageProto.class, BasicTestMessageListOrBuilder.class, BasicTestMessageList.class, - ProtoListMapper.class }) +@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 { 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; + } + +} From b2859400d459730dd6b6f2a1ec12eea97f1114f1 Mon Sep 17 00:00:00 2001 From: digithuman Date: Wed, 9 Nov 2022 11:56:49 +0800 Subject: [PATCH 10/12] Protobuf Message Exception --- .../ap/internal/model/common/Type.java | 38 +++++-------------- .../ap/internal/model/BeanMappingMethod.ftl | 5 +++ .../GetterWrapperForCollectionsAndMaps.ftl | 6 +-- 3 files changed, 16 insertions(+), 33 deletions(-) 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 8fcfe40469..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 @@ -349,37 +349,17 @@ public boolean isCollectionOrMapType() { } /** - * CollectionType and typeParameters is Protobuf Primitive. + * Only Protobuf Message , Not Protobuf Builder. */ - public boolean isProtobufPrimitiveCollectionType() { - if (isCollectionType) { - if ("com.google.protobuf.ProtocolStringList".equals( this.qualifiedName )) { - return true; - } - List typeParameters = getTypeParameters(); - if ( typeParameters.size() == 1 && typeParameters.get( 0 ).packageName.equals( "java.lang" ) ) { - return true; - } - } - return false; - } - - /** - * MapType and TypeParameters is Protobuf Primitive. - */ - public boolean isProtobufPrimitiveMapType() { - if (isMapType) { - List typeParameters = getTypeParameters(); - if ( typeParameters.size() == 2 && typeParameters.get( 0 ).packageName.equals( "java.lang" ) - && typeParameters.get( 1 ).packageName.equals( "java.lang" ) ) { - return true; - } + 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; } - return false; - } - - public boolean isProtobufPrimitiveCollectionOrMapType() { - return isProtobufPrimitiveCollectionType() || isProtobufPrimitiveMapType(); + boolean isBuilder = typeUtils.isAssignable( this.typeMirror, builderType.asType() ); + boolean isMessageOrBuilderType = typeUtils.isAssignable( this.typeMirror, messageOrBuilderType.asType() ); + return isMessageOrBuilderType && !isBuilder; } public boolean isArrayType() { 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..efed1eda69 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}.toBuilder() , 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 8e297189d1..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,16 +11,14 @@ if ( ${ext.targetBeanName}.${ext.targetWriteAccessorName}<@lib.handleWriteAccesing /> != null ) { <@lib.handleExceptions> <#if ext.existingInstanceMapping> - <#if ext.targetType.protobufPrimitiveCollectionOrMapType && - ( "${ext.targetWriteAccessorName}" == "get${ext.targetPropertyName?cap_first}Map" || "${ext.targetWriteAccessorName}" == "get${ext.targetPropertyName?cap_first}List" ) > + <#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.targetType.protobufPrimitiveCollectionOrMapType && - ( "${ext.targetWriteAccessorName}" == "get${ext.targetPropertyName?cap_first}Map" || "${ext.targetWriteAccessorName}" == "get${ext.targetPropertyName?cap_first}List" ) > + <#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/> ); From 14daab00557d6484598af7a6b46f3ab8c9012d4d Mon Sep 17 00:00:00 2001 From: digithuman Date: Wed, 9 Nov 2022 12:12:41 +0800 Subject: [PATCH 11/12] Change Tip --- .../org/mapstruct/ap/internal/model/BeanMappingMethod.ftl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 efed1eda69..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 @@ -89,7 +89,7 @@ <#if existingInstanceMapping && returnType.protobufMessageReturnType > - throw new IllegalArgumentException("Only Support ${returnType?string}.toBuilder() , Not Support Protobuf Message. "); + throw new IllegalArgumentException("Only Support ${returnType?string}.Builder , Use Message.toBuilder() Convert , Not Support Protobuf Message. "); <#list beforeMappingReferencesWithMappingTarget as callback> From 0470f773bcba53277148f40200cf8b44ec08621b Mon Sep 17 00:00:00 2001 From: digithuman Date: Mon, 13 Nov 2023 17:15:00 +0800 Subject: [PATCH 12/12] =?UTF-8?q?=E5=8F=91=E5=B8=83=E5=88=B0=E4=B8=AD?= =?UTF-8?q?=E5=A4=AE=E4=BB=93=E5=BA=93=EF=BC=8C=E4=BF=AE=E6=94=B9groupid?= =?UTF-8?q?=20=E5=92=8C=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build-config/pom.xml | 5 +++-- core-jdk8/pom.xml | 6 +++--- core/pom.xml | 23 +++-------------------- distribution/pom.xml | 11 +++++++---- documentation/pom.xml | 5 +++-- integrationtest/pom.xml | 6 ++++-- parent/pom.xml | 17 ++++++++--------- pom.xml | 4 ++-- processor/pom.xml | 36 +++++------------------------------- 9 files changed, 38 insertions(+), 75 deletions(-) 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 2fc3d7cb0e..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 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 e4dabf3b04..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,7 +40,7 @@ gem-api - ${project.groupId} + com.gitee.jmash mapstruct provided @@ -301,19 +303,6 @@ - - org.apache.maven.plugins - maven-checkstyle-plugin - - - check-style - verify - - checkstyle - - - - org.jacoco jacoco-maven-plugin @@ -359,21 +348,6 @@ - - com.github.siom79.japicmp - japicmp-maven-plugin - - - - org.mapstruct.ap - - - org.mapstruct.ap.internal - org.mapstruct.ap.shaded - - - -