-
-
Notifications
You must be signed in to change notification settings - Fork 80
Open
Description
Simple proto:
syntax = "proto3"; package protobuf; option java_package = "example.org.protobuf"; option java_outer_classname = "ProtobufModels"; message Course { int32 id = 1; string course_name = 2; }
Using protoc-jar-maven-plugin (4.28.3+) -
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>4.28.3</version>
</dependency>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protoc</artifactId>
<version>4.28.3</version>
<type>pom</type>
</dependency>
...
...
<plugin>
<groupId>com.github.os72</groupId>
<artifactId>protoc-jar-maven-plugin</artifactId>
<version>3.11.4</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<optimizeCodegen>false</optimizeCodegen>
<includeStdTypes>true</includeStdTypes>
<outputDirectory>src/main/java</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
Maven execution creates a class with a windows 10 x64 java sdk 19.0.2 compilation error: makeExtensionsImmutable() symbol not found
// Generated by the protocol buffer compiler. DO NOT EDIT! // source: course.proto package org.example.protobuf; public final class ProtobufModels { private ProtobufModels() {} public static void registerAllExtensions( com.google.protobuf.ExtensionRegistryLite registry) { } public static void registerAllExtensions( com.google.protobuf.ExtensionRegistry registry) { registerAllExtensions( (com.google.protobuf.ExtensionRegistryLite) registry); } public interface CourseOrBuilder extends // @@protoc_insertion_point(interface_extends:protobuf.Course) com.google.protobuf.MessageOrBuilder { /** *int32 id = 1;
* @return The id. */ int getId(); /** *string course_name = 2;
* @return The courseName. */ java.lang.String getCourseName(); /** *string course_name = 2;
* @return The bytes for courseName. */ com.google.protobuf.ByteString getCourseNameBytes(); } /** * Protobuf type {@code protobuf.Course} */ public static final class Course extends com.google.protobuf.GeneratedMessageV3 implements // @@protoc_insertion_point(message_implements:protobuf.Course) CourseOrBuilder { private static final long serialVersionUID = 0L; // Use Course.newBuilder() to construct. private Course(com.google.protobuf.GeneratedMessageV3.Builder builder) { super(builder); } private Course() { courseName_ = ""; } @java.lang.Override @SuppressWarnings({"unused"}) protected java.lang.Object newInstance( UnusedPrivateParameter unused) { return new Course(); } @java.lang.Override public final com.google.protobuf.UnknownFieldSet getUnknownFields() { return this.unknownFields; } private Course( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { this(); if (extensionRegistry == null) { throw new java.lang.NullPointerException(); } 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: { id_ = input.readInt32(); break; } case 18: { java.lang.String s = input.readStringRequireUtf8(); courseName_ = s; break; } default: { if (!parseUnknownField( input, unknownFields, extensionRegistry, tag)) { done = true; } break; } } } } catch (com.google.protobuf.InvalidProtocolBufferException e) { throw e.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.example.protobuf.ProtobufModels.internal_static_protobuf_Course_descriptor; } @java.lang.Override protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable() { return org.example.protobuf.ProtobufModels.internal_static_protobuf_Course_fieldAccessorTable .ensureFieldAccessorsInitialized( org.example.protobuf.ProtobufModels.Course.class, org.example.protobuf.ProtobufModels.Course.Builder.class); } public static final int ID_FIELD_NUMBER = 1; private int id_; /** *int32 id = 1;
* @return The id. */ public int getId() { return id_; } public static final int COURSE_NAME_FIELD_NUMBER = 2; private volatile java.lang.Object courseName_; /** *string course_name = 2;
* @return The courseName. */ public java.lang.String getCourseName() { java.lang.Object ref = courseName_; if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); courseName_ = s; return s; } } /** *string course_name = 2;
* @return The bytes for courseName. */ public com.google.protobuf.ByteString getCourseNameBytes() { java.lang.Object ref = courseName_; if (ref instanceof java.lang.String) { com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); courseName_ = b; return b; } else { return (com.google.protobuf.ByteString) ref; } } 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 { if (id_ != 0) { output.writeInt32(1, id_); } if (!getCourseNameBytes().isEmpty()) { com.google.protobuf.GeneratedMessageV3.writeString(output, 2, courseName_); } unknownFields.writeTo(output); } @java.lang.Override public int getSerializedSize() { int size = memoizedSize; if (size != -1) return size; size = 0; if (id_ != 0) { size += com.google.protobuf.CodedOutputStream .computeInt32Size(1, id_); } if (!getCourseNameBytes().isEmpty()) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, courseName_); } 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.example.protobuf.ProtobufModels.Course)) { return super.equals(obj); } org.example.protobuf.ProtobufModels.Course other = (org.example.protobuf.ProtobufModels.Course) obj; if (getId() != other.getId()) return false; if (!getCourseName() .equals(other.getCourseName())) 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(); hash = (37 * hash) + ID_FIELD_NUMBER; hash = (53 * hash) + getId(); hash = (37 * hash) + COURSE_NAME_FIELD_NUMBER; hash = (53 * hash) + getCourseName().hashCode(); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; } public static org.example.protobuf.ProtobufModels.Course parseFrom( java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } public static org.example.protobuf.ProtobufModels.Course parseFrom( java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } public static org.example.protobuf.ProtobufModels.Course parseFrom( com.google.protobuf.ByteString data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } public static org.example.protobuf.ProtobufModels.Course parseFrom( com.google.protobuf.ByteString data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } public static org.example.protobuf.ProtobufModels.Course parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } public static org.example.protobuf.ProtobufModels.Course parseFrom( byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } public static org.example.protobuf.ProtobufModels.Course parseFrom(java.io.InputStream input) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3 .parseWithIOException(PARSER, input); } public static org.example.protobuf.ProtobufModels.Course 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.example.protobuf.ProtobufModels.Course parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3 .parseDelimitedWithIOException(PARSER, input); } public static org.example.protobuf.ProtobufModels.Course 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.example.protobuf.ProtobufModels.Course parseFrom( com.google.protobuf.CodedInputStream input) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3 .parseWithIOException(PARSER, input); } public static org.example.protobuf.ProtobufModels.Course 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.example.protobuf.ProtobufModels.Course 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 protobuf.Course} */ public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder implements // @@protoc_insertion_point(builder_implements:protobuf.Course) org.example.protobuf.ProtobufModels.CourseOrBuilder { public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { return org.example.protobuf.ProtobufModels.internal_static_protobuf_Course_descriptor; } @java.lang.Override protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable() { return org.example.protobuf.ProtobufModels.internal_static_protobuf_Course_fieldAccessorTable .ensureFieldAccessorsInitialized( org.example.protobuf.ProtobufModels.Course.class, org.example.protobuf.ProtobufModels.Course.Builder.class); } // Construct using org.example.protobuf.ProtobufModels.Course.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(); id_ = 0; courseName_ = ""; return this; } @java.lang.Override public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { return org.example.protobuf.ProtobufModels.internal_static_protobuf_Course_descriptor; } @java.lang.Override public org.example.protobuf.ProtobufModels.Course getDefaultInstanceForType() { return org.example.protobuf.ProtobufModels.Course.getDefaultInstance(); } @java.lang.Override public org.example.protobuf.ProtobufModels.Course build() { org.example.protobuf.ProtobufModels.Course result = buildPartial(); if (!result.isInitialized()) { throw newUninitializedMessageException(result); } return result; } @java.lang.Override public org.example.protobuf.ProtobufModels.Course buildPartial() { org.example.protobuf.ProtobufModels.Course result = new org.example.protobuf.ProtobufModels.Course(this); result.id_ = id_; result.courseName_ = courseName_; 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.example.protobuf.ProtobufModels.Course) { return mergeFrom((org.example.protobuf.ProtobufModels.Course)other); } else { super.mergeFrom(other); return this; } } public Builder mergeFrom(org.example.protobuf.ProtobufModels.Course other) { if (other == org.example.protobuf.ProtobufModels.Course.getDefaultInstance()) return this; if (other.getId() != 0) { setId(other.getId()); } if (!other.getCourseName().isEmpty()) { courseName_ = other.courseName_; 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.example.protobuf.ProtobufModels.Course parsedMessage = null; try { parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); } catch (com.google.protobuf.InvalidProtocolBufferException e) { parsedMessage = (org.example.protobuf.ProtobufModels.Course) e.getUnfinishedMessage(); throw e.unwrapIOException(); } finally { if (parsedMessage != null) { mergeFrom(parsedMessage); } } return this; } private int id_ ; /** *int32 id = 1;
* @return The id. */ public int getId() { return id_; } /** *int32 id = 1;
* @param value The id to set. * @return This builder for chaining. */ public Builder setId(int value) { id_ = value; onChanged(); return this; } /** *int32 id = 1;
* @return This builder for chaining. */ public Builder clearId() { id_ = 0; onChanged(); return this; } private java.lang.Object courseName_ = ""; /** *string course_name = 2;
* @return The courseName. */ public java.lang.String getCourseName() { java.lang.Object ref = courseName_; if (!(ref instanceof java.lang.String)) { com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); courseName_ = s; return s; } else { return (java.lang.String) ref; } } /** *string course_name = 2;
* @return The bytes for courseName. */ public com.google.protobuf.ByteString getCourseNameBytes() { java.lang.Object ref = courseName_; if (ref instanceof String) { com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); courseName_ = b; return b; } else { return (com.google.protobuf.ByteString) ref; } } /** *string course_name = 2;
* @param value The courseName to set. * @return This builder for chaining. */ public Builder setCourseName( java.lang.String value) { if (value == null) { throw new NullPointerException(); } courseName_ = value; onChanged(); return this; } /** *string course_name = 2;
* @return This builder for chaining. */ public Builder clearCourseName() { courseName_ = getDefaultInstance().getCourseName(); onChanged(); return this; } /** *string course_name = 2;
* @param value The bytes for courseName to set. * @return This builder for chaining. */ public Builder setCourseNameBytes( com.google.protobuf.ByteString value) { if (value == null) { throw new NullPointerException(); } checkByteStringIsUtf8(value); courseName_ = 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:protobuf.Course) } // @@protoc_insertion_point(class_scope:protobuf.Course) private static final org.example.protobuf.ProtobufModels.Course DEFAULT_INSTANCE; static { DEFAULT_INSTANCE = new org.example.protobuf.ProtobufModels.Course(); } public static org.example.protobuf.ProtobufModels.Course getDefaultInstance() { return DEFAULT_INSTANCE; } private static final com.google.protobuf.Parser PARSER = new com.google.protobuf.AbstractParser() { @java.lang.Override public Course parsePartialFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return new Course(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.example.protobuf.ProtobufModels.Course getDefaultInstanceForType() { return DEFAULT_INSTANCE; } } private static final com.google.protobuf.Descriptors.Descriptor internal_static_protobuf_Course_descriptor; private static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_protobuf_Course_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\014course.proto\022\010protobuf\")\n\006Course\022\n\n\002id" + "\030\001 \001(\005\022\023\n\013course_name\030\002 \001(\tB&\n\024org.examp" + "le.protobufB\016ProtobufModelsb\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor .internalBuildGeneratedFileFrom(descriptorData, new com.google.protobuf.Descriptors.FileDescriptor[] { }); internal_static_protobuf_Course_descriptor = getDescriptor().getMessageTypes().get(0); internal_static_protobuf_Course_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_protobuf_Course_descriptor, new java.lang.String[] { "Id", "CourseName", }); } // @@protoc_insertion_point(outer_class_scope) }
Using windows x64 binary, protoc-28.3-win64.zip distro from https://github.com/protocolbuffers/protobuf/releases -
protoc -IC:/Example/src/main/protobuf C:/Example/src/main/protobuf/course.proto --java_out=C:/Example/src/main/java
The class generated is very different and java compiles, below:
// Generated by the protocol buffer compiler. DO NOT EDIT! // NO CHECKED-IN PROTOBUF GENCODE // source: course.proto // Protobuf Java Version: 4.28.3 package org.example.protobuf; public final class ProtobufModels { private ProtobufModels() {} static { com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, /* major= */ 4, /* minor= */ 28, /* patch= */ 3, /* suffix= */ "", ProtobufModels.class.getName()); } public static void registerAllExtensions( com.google.protobuf.ExtensionRegistryLite registry) { } public static void registerAllExtensions( com.google.protobuf.ExtensionRegistry registry) { registerAllExtensions( (com.google.protobuf.ExtensionRegistryLite) registry); } public interface CourseOrBuilder extends // @@protoc_insertion_point(interface_extends:protobuf.Course) com.google.protobuf.MessageOrBuilder { /** *int32 id = 1;
* @return The id. */ int getId(); /** *string course_name = 2;
* @return The courseName. */ java.lang.String getCourseName(); /** *string course_name = 2;
* @return The bytes for courseName. */ com.google.protobuf.ByteString getCourseNameBytes(); } /** * Protobuf type {@code protobuf.Course} */ public static final class Course extends com.google.protobuf.GeneratedMessage implements // @@protoc_insertion_point(message_implements:protobuf.Course) CourseOrBuilder { private static final long serialVersionUID = 0L; static { com.google.protobuf.RuntimeVersion.validateProtobufGencodeVersion( com.google.protobuf.RuntimeVersion.RuntimeDomain.PUBLIC, /* major= */ 4, /* minor= */ 28, /* patch= */ 3, /* suffix= */ "", Course.class.getName()); } // Use Course.newBuilder() to construct. private Course(com.google.protobuf.GeneratedMessage.Builder builder) { super(builder); } private Course() { courseName_ = ""; } public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { return org.example.protobuf.ProtobufModels.internal_static_protobuf_Course_descriptor; } @java.lang.Override protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { return org.example.protobuf.ProtobufModels.internal_static_protobuf_Course_fieldAccessorTable .ensureFieldAccessorsInitialized( org.example.protobuf.ProtobufModels.Course.class, org.example.protobuf.ProtobufModels.Course.Builder.class); } public static final int ID_FIELD_NUMBER = 1; private int id_ = 0; /** *int32 id = 1;
* @return The id. */ @java.lang.Override public int getId() { return id_; } public static final int COURSE_NAME_FIELD_NUMBER = 2; @SuppressWarnings("serial") private volatile java.lang.Object courseName_ = ""; /** *string course_name = 2;
* @return The courseName. */ @java.lang.Override public java.lang.String getCourseName() { java.lang.Object ref = courseName_; if (ref instanceof java.lang.String) { return (java.lang.String) ref; } else { com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); courseName_ = s; return s; } } /** *string course_name = 2;
* @return The bytes for courseName. */ @java.lang.Override public com.google.protobuf.ByteString getCourseNameBytes() { java.lang.Object ref = courseName_; if (ref instanceof java.lang.String) { com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); courseName_ = b; return b; } else { return (com.google.protobuf.ByteString) ref; } } 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 { if (id_ != 0) { output.writeInt32(1, id_); } if (!com.google.protobuf.GeneratedMessage.isStringEmpty(courseName_)) { com.google.protobuf.GeneratedMessage.writeString(output, 2, courseName_); } getUnknownFields().writeTo(output); } @java.lang.Override public int getSerializedSize() { int size = memoizedSize; if (size != -1) return size; size = 0; if (id_ != 0) { size += com.google.protobuf.CodedOutputStream .computeInt32Size(1, id_); } if (!com.google.protobuf.GeneratedMessage.isStringEmpty(courseName_)) { size += com.google.protobuf.GeneratedMessage.computeStringSize(2, courseName_); } size += getUnknownFields().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.example.protobuf.ProtobufModels.Course)) { return super.equals(obj); } org.example.protobuf.ProtobufModels.Course other = (org.example.protobuf.ProtobufModels.Course) obj; if (getId() != other.getId()) return false; if (!getCourseName() .equals(other.getCourseName())) return false; if (!getUnknownFields().equals(other.getUnknownFields())) return false; return true; } @java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); hash = (37 * hash) + ID_FIELD_NUMBER; hash = (53 * hash) + getId(); hash = (37 * hash) + COURSE_NAME_FIELD_NUMBER; hash = (53 * hash) + getCourseName().hashCode(); hash = (29 * hash) + getUnknownFields().hashCode(); memoizedHashCode = hash; return hash; } public static org.example.protobuf.ProtobufModels.Course parseFrom( java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } public static org.example.protobuf.ProtobufModels.Course parseFrom( java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } public static org.example.protobuf.ProtobufModels.Course parseFrom( com.google.protobuf.ByteString data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } public static org.example.protobuf.ProtobufModels.Course parseFrom( com.google.protobuf.ByteString data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } public static org.example.protobuf.ProtobufModels.Course parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } public static org.example.protobuf.ProtobufModels.Course parseFrom( byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } public static org.example.protobuf.ProtobufModels.Course parseFrom(java.io.InputStream input) throws java.io.IOException { return com.google.protobuf.GeneratedMessage .parseWithIOException(PARSER, input); } public static org.example.protobuf.ProtobufModels.Course parseFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { return com.google.protobuf.GeneratedMessage .parseWithIOException(PARSER, input, extensionRegistry); } public static org.example.protobuf.ProtobufModels.Course parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { return com.google.protobuf.GeneratedMessage .parseDelimitedWithIOException(PARSER, input); } public static org.example.protobuf.ProtobufModels.Course parseDelimitedFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { return com.google.protobuf.GeneratedMessage .parseDelimitedWithIOException(PARSER, input, extensionRegistry); } public static org.example.protobuf.ProtobufModels.Course parseFrom( com.google.protobuf.CodedInputStream input) throws java.io.IOException { return com.google.protobuf.GeneratedMessage .parseWithIOException(PARSER, input); } public static org.example.protobuf.ProtobufModels.Course parseFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { return com.google.protobuf.GeneratedMessage .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.example.protobuf.ProtobufModels.Course 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.GeneratedMessage.BuilderParent parent) { Builder builder = new Builder(parent); return builder; } /** * Protobuf type {@code protobuf.Course} */ public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder implements // @@protoc_insertion_point(builder_implements:protobuf.Course) org.example.protobuf.ProtobufModels.CourseOrBuilder { public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { return org.example.protobuf.ProtobufModels.internal_static_protobuf_Course_descriptor; } @java.lang.Override protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { return org.example.protobuf.ProtobufModels.internal_static_protobuf_Course_fieldAccessorTable .ensureFieldAccessorsInitialized( org.example.protobuf.ProtobufModels.Course.class, org.example.protobuf.ProtobufModels.Course.Builder.class); } // Construct using org.example.protobuf.ProtobufModels.Course.newBuilder() private Builder() { } private Builder( com.google.protobuf.GeneratedMessage.BuilderParent parent) { super(parent); } @java.lang.Override public Builder clear() { super.clear(); bitField0_ = 0; id_ = 0; courseName_ = ""; return this; } @java.lang.Override public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { return org.example.protobuf.ProtobufModels.internal_static_protobuf_Course_descriptor; } @java.lang.Override public org.example.protobuf.ProtobufModels.Course getDefaultInstanceForType() { return org.example.protobuf.ProtobufModels.Course.getDefaultInstance(); } @java.lang.Override public org.example.protobuf.ProtobufModels.Course build() { org.example.protobuf.ProtobufModels.Course result = buildPartial(); if (!result.isInitialized()) { throw newUninitializedMessageException(result); } return result; } @java.lang.Override public org.example.protobuf.ProtobufModels.Course buildPartial() { org.example.protobuf.ProtobufModels.Course result = new org.example.protobuf.ProtobufModels.Course(this); if (bitField0_ != 0) { buildPartial0(result); } onBuilt(); return result; } private void buildPartial0(org.example.protobuf.ProtobufModels.Course result) { int from_bitField0_ = bitField0_; if (((from_bitField0_ & 0x00000001) != 0)) { result.id_ = id_; } if (((from_bitField0_ & 0x00000002) != 0)) { result.courseName_ = courseName_; } } @java.lang.Override public Builder mergeFrom(com.google.protobuf.Message other) { if (other instanceof org.example.protobuf.ProtobufModels.Course) { return mergeFrom((org.example.protobuf.ProtobufModels.Course)other); } else { super.mergeFrom(other); return this; } } public Builder mergeFrom(org.example.protobuf.ProtobufModels.Course other) { if (other == org.example.protobuf.ProtobufModels.Course.getDefaultInstance()) return this; if (other.getId() != 0) { setId(other.getId()); } if (!other.getCourseName().isEmpty()) { courseName_ = other.courseName_; bitField0_ |= 0x00000002; onChanged(); } this.mergeUnknownFields(other.getUnknownFields()); 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 { if (extensionRegistry == null) { throw new java.lang.NullPointerException(); } try { boolean done = false; while (!done) { int tag = input.readTag(); switch (tag) { case 0: done = true; break; case 8: { id_ = input.readInt32(); bitField0_ |= 0x00000001; break; } // case 8 case 18: { courseName_ = input.readStringRequireUtf8(); bitField0_ |= 0x00000002; break; } // case 18 default: { if (!super.parseUnknownField(input, extensionRegistry, tag)) { done = true; // was an endgroup tag } break; } // default: } // switch (tag) } // while (!done) } catch (com.google.protobuf.InvalidProtocolBufferException e) { throw e.unwrapIOException(); } finally { onChanged(); } // finally return this; } private int bitField0_; private int id_ ; /** *int32 id = 1;
* @return The id. */ @java.lang.Override public int getId() { return id_; } /** *int32 id = 1;
* @param value The id to set. * @return This builder for chaining. */ public Builder setId(int value) { id_ = value; bitField0_ |= 0x00000001; onChanged(); return this; } /** *int32 id = 1;
* @return This builder for chaining. */ public Builder clearId() { bitField0_ = (bitField0_ & ~0x00000001); id_ = 0; onChanged(); return this; } private java.lang.Object courseName_ = ""; /** *string course_name = 2;
* @return The courseName. */ public java.lang.String getCourseName() { java.lang.Object ref = courseName_; if (!(ref instanceof java.lang.String)) { com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; java.lang.String s = bs.toStringUtf8(); courseName_ = s; return s; } else { return (java.lang.String) ref; } } /** *string course_name = 2;
* @return The bytes for courseName. */ public com.google.protobuf.ByteString getCourseNameBytes() { java.lang.Object ref = courseName_; if (ref instanceof String) { com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8( (java.lang.String) ref); courseName_ = b; return b; } else { return (com.google.protobuf.ByteString) ref; } } /** *string course_name = 2;
* @param value The courseName to set. * @return This builder for chaining. */ public Builder setCourseName( java.lang.String value) { if (value == null) { throw new NullPointerException(); } courseName_ = value; bitField0_ |= 0x00000002; onChanged(); return this; } /** *string course_name = 2;
* @return This builder for chaining. */ public Builder clearCourseName() { courseName_ = getDefaultInstance().getCourseName(); bitField0_ = (bitField0_ & ~0x00000002); onChanged(); return this; } /** *string course_name = 2;
* @param value The bytes for courseName to set. * @return This builder for chaining. */ public Builder setCourseNameBytes( com.google.protobuf.ByteString value) { if (value == null) { throw new NullPointerException(); } checkByteStringIsUtf8(value); courseName_ = value; bitField0_ |= 0x00000002; onChanged(); return this; } // @@protoc_insertion_point(builder_scope:protobuf.Course) } // @@protoc_insertion_point(class_scope:protobuf.Course) private static final org.example.protobuf.ProtobufModels.Course DEFAULT_INSTANCE; static { DEFAULT_INSTANCE = new org.example.protobuf.ProtobufModels.Course(); } public static org.example.protobuf.ProtobufModels.Course getDefaultInstance() { return DEFAULT_INSTANCE; } private static final com.google.protobuf.Parser PARSER = new com.google.protobuf.AbstractParser() { @java.lang.Override public Course parsePartialFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { Builder builder = newBuilder(); try { builder.mergeFrom(input, extensionRegistry); } catch (com.google.protobuf.InvalidProtocolBufferException e) { throw e.setUnfinishedMessage(builder.buildPartial()); } catch (com.google.protobuf.UninitializedMessageException e) { throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); } catch (java.io.IOException e) { throw new com.google.protobuf.InvalidProtocolBufferException(e) .setUnfinishedMessage(builder.buildPartial()); } return builder.buildPartial(); } }; 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.example.protobuf.ProtobufModels.Course getDefaultInstanceForType() { return DEFAULT_INSTANCE; } } private static final com.google.protobuf.Descriptors.Descriptor internal_static_protobuf_Course_descriptor; private static final com.google.protobuf.GeneratedMessage.FieldAccessorTable internal_static_protobuf_Course_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\014course.proto\022\010protobuf\")\n\006Course\022\n\n\002id" + "\030\001 \001(\005\022\023\n\013course_name\030\002 \001(\tB&\n\024org.examp" + "le.protobufB\016ProtobufModelsb\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor .internalBuildGeneratedFileFrom(descriptorData, new com.google.protobuf.Descriptors.FileDescriptor[] { }); internal_static_protobuf_Course_descriptor = getDescriptor().getMessageTypes().get(0); internal_static_protobuf_Course_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable( internal_static_protobuf_Course_descriptor, new java.lang.String[] { "Id", "CourseName", }); descriptor.resolveAllFeaturesImmutable(); } // @@protoc_insertion_point(outer_class_scope) }
Metadata
Metadata
Assignees
Labels
No labels