From b1bdeb92d68848c26aab5cbaedce50327886854e Mon Sep 17 00:00:00 2001 From: eugenp Date: Sat, 18 Jun 2016 23:52:26 +0300 Subject: [PATCH] minor formatting work --- .../org/baeldung/httpclient/SandboxTest.java | 3 +- .../com/baeldung/protobuf/Application.java | 12 +- .../baeldung/protobuf/BaeldungTraining.java | 5074 ++++++++--------- .../baeldung/protobuf/CourseRepository.java | 6 +- 4 files changed, 2479 insertions(+), 2616 deletions(-) diff --git a/httpclient/src/test/java/org/baeldung/httpclient/SandboxTest.java b/httpclient/src/test/java/org/baeldung/httpclient/SandboxTest.java index 514611d1f9..dc1a206f0d 100644 --- a/httpclient/src/test/java/org/baeldung/httpclient/SandboxTest.java +++ b/httpclient/src/test/java/org/baeldung/httpclient/SandboxTest.java @@ -108,7 +108,7 @@ public class SandboxTest { // Make a client using those creds final CloseableHttpClient client = HttpClients.custom().setDefaultCookieStore(cookieStore).setDefaultCredentialsProvider(credsProvider).build(); - + // And make a call to the URL we are after final HttpGet httpget = new HttpGet("http://httpbin.org/digest-auth/auth/user/passwd"); @@ -127,6 +127,7 @@ public class SandboxTest { try { System.out.println("----------------------------------------"); + System.out.println(responseGood.getStatusLine()); assertEquals(200, responseGood.getStatusLine().getStatusCode()); } finally { responseGood.close(); diff --git a/spring-protobuf/src/main/java/com/baeldung/protobuf/Application.java b/spring-protobuf/src/main/java/com/baeldung/protobuf/Application.java index ce5453af61..234c3e3382 100644 --- a/spring-protobuf/src/main/java/com/baeldung/protobuf/Application.java +++ b/spring-protobuf/src/main/java/com/baeldung/protobuf/Application.java @@ -32,17 +32,9 @@ public class Application { public CourseRepository createStubCourses() { Map courses = new HashMap<>(); - Course course1 = Course.newBuilder() - .setId(1) - .setCourseName("REST with Spring") - .addAllStudent(createStubStudents()) - .build(); + Course course1 = Course.newBuilder().setId(1).setCourseName("REST with Spring").addAllStudent(createStubStudents()).build(); - Course course2 = Course.newBuilder() - .setId(2) - .setCourseName("Learn Spring Security") - .addAllStudent(new ArrayList<>()) - .build(); + Course course2 = Course.newBuilder().setId(2).setCourseName("Learn Spring Security").addAllStudent(new ArrayList<>()).build(); courses.put(course1.getId(), course1); courses.put(course2.getId(), course2); diff --git a/spring-protobuf/src/main/java/com/baeldung/protobuf/BaeldungTraining.java b/spring-protobuf/src/main/java/com/baeldung/protobuf/BaeldungTraining.java index 3869ebfaeb..5cab2ae908 100644 --- a/spring-protobuf/src/main/java/com/baeldung/protobuf/BaeldungTraining.java +++ b/spring-protobuf/src/main/java/com/baeldung/protobuf/BaeldungTraining.java @@ -4,2716 +4,2586 @@ package com.baeldung.protobuf; public final class BaeldungTraining { - private BaeldungTraining() {} - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistry registry) { - } - public interface CourseOrBuilder extends - // @@protoc_insertion_point(interface_extends:baeldung.Course) - com.google.protobuf.MessageOrBuilder { - - /** - * optional int32 id = 1; - */ - int getId(); - - /** - * optional string course_name = 2; - */ - java.lang.String getCourseName(); - /** - * optional string course_name = 2; - */ - com.google.protobuf.ByteString - getCourseNameBytes(); - - /** - * repeated .baeldung.Student student = 3; - */ - java.util.List - getStudentList(); - /** - * repeated .baeldung.Student student = 3; - */ - com.baeldung.protobuf.BaeldungTraining.Student getStudent(int index); - /** - * repeated .baeldung.Student student = 3; - */ - int getStudentCount(); - /** - * repeated .baeldung.Student student = 3; - */ - java.util.List - getStudentOrBuilderList(); - /** - * repeated .baeldung.Student student = 3; - */ - com.baeldung.protobuf.BaeldungTraining.StudentOrBuilder getStudentOrBuilder( - int index); - } - /** - * Protobuf type {@code baeldung.Course} - */ - public static final class Course extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:baeldung.Course) - CourseOrBuilder { - // Use Course.newBuilder() to construct. - private Course(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private Course() { - id_ = 0; - courseName_ = ""; - student_ = java.util.Collections.emptyList(); + private BaeldungTraining() { } - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private Course( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 8: { - - id_ = input.readInt32(); - break; - } - case 18: { - java.lang.String s = input.readStringRequireUtf8(); - - courseName_ = s; - break; - } - case 26: { - if (!((mutable_bitField0_ & 0x00000004) == 0x00000004)) { - student_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000004; - } - student_.add(input.readMessage(com.baeldung.protobuf.BaeldungTraining.Student.parser(), extensionRegistry)); - 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 { - if (((mutable_bitField0_ & 0x00000004) == 0x00000004)) { - student_ = java.util.Collections.unmodifiableList(student_); - } - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.baeldung.protobuf.BaeldungTraining.internal_static_baeldung_Course_descriptor; + public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { } - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.baeldung.protobuf.BaeldungTraining.internal_static_baeldung_Course_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.baeldung.protobuf.BaeldungTraining.Course.class, com.baeldung.protobuf.BaeldungTraining.Course.Builder.class); + public interface CourseOrBuilder extends + // @@protoc_insertion_point(interface_extends:baeldung.Course) + com.google.protobuf.MessageOrBuilder { + + /** + * optional int32 id = 1; + */ + int getId(); + + /** + * optional string course_name = 2; + */ + java.lang.String getCourseName(); + + /** + * optional string course_name = 2; + */ + com.google.protobuf.ByteString getCourseNameBytes(); + + /** + * repeated .baeldung.Student student = 3; + */ + java.util.List getStudentList(); + + /** + * repeated .baeldung.Student student = 3; + */ + com.baeldung.protobuf.BaeldungTraining.Student getStudent(int index); + + /** + * repeated .baeldung.Student student = 3; + */ + int getStudentCount(); + + /** + * repeated .baeldung.Student student = 3; + */ + java.util.List getStudentOrBuilderList(); + + /** + * repeated .baeldung.Student student = 3; + */ + com.baeldung.protobuf.BaeldungTraining.StudentOrBuilder getStudentOrBuilder(int index); } - private int bitField0_; - public static final int ID_FIELD_NUMBER = 1; - private int id_; - /** - * optional int32 id = 1; - */ - public int getId() { - return id_; - } - - public static final int COURSE_NAME_FIELD_NUMBER = 2; - private volatile java.lang.Object courseName_; - /** - * optional string course_name = 2; - */ - 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; - } - } - /** - * optional string course_name = 2; - */ - 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; - } - } - - public static final int STUDENT_FIELD_NUMBER = 3; - private java.util.List student_; - /** - * repeated .baeldung.Student student = 3; - */ - public java.util.List getStudentList() { - return student_; - } - /** - * repeated .baeldung.Student student = 3; - */ - public java.util.List - getStudentOrBuilderList() { - return student_; - } - /** - * repeated .baeldung.Student student = 3; - */ - public int getStudentCount() { - return student_.size(); - } - /** - * repeated .baeldung.Student student = 3; - */ - public com.baeldung.protobuf.BaeldungTraining.Student getStudent(int index) { - return student_.get(index); - } - /** - * repeated .baeldung.Student student = 3; - */ - public com.baeldung.protobuf.BaeldungTraining.StudentOrBuilder getStudentOrBuilder( - int index) { - return student_.get(index); - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - 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.GeneratedMessage.writeString(output, 2, courseName_); - } - for (int i = 0; i < student_.size(); i++) { - output.writeMessage(3, student_.get(i)); - } - } - - 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.GeneratedMessage.computeStringSize(2, courseName_); - } - for (int i = 0; i < student_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(3, student_.get(i)); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.baeldung.protobuf.BaeldungTraining.Course parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.baeldung.protobuf.BaeldungTraining.Course parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.baeldung.protobuf.BaeldungTraining.Course parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.baeldung.protobuf.BaeldungTraining.Course parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.baeldung.protobuf.BaeldungTraining.Course parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessage - .parseWithIOException(PARSER, input); - } - public static com.baeldung.protobuf.BaeldungTraining.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 com.baeldung.protobuf.BaeldungTraining.Course parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessage - .parseDelimitedWithIOException(PARSER, input); - } - public static com.baeldung.protobuf.BaeldungTraining.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 com.baeldung.protobuf.BaeldungTraining.Course parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessage - .parseWithIOException(PARSER, input); - } - public static com.baeldung.protobuf.BaeldungTraining.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); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.baeldung.protobuf.BaeldungTraining.Course prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - 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 baeldung.Course} */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:baeldung.Course) - com.baeldung.protobuf.BaeldungTraining.CourseOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.baeldung.protobuf.BaeldungTraining.internal_static_baeldung_Course_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.baeldung.protobuf.BaeldungTraining.internal_static_baeldung_Course_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.baeldung.protobuf.BaeldungTraining.Course.class, com.baeldung.protobuf.BaeldungTraining.Course.Builder.class); - } - - // Construct using com.baeldung.protobuf.BaeldungTraining.Course.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - getStudentFieldBuilder(); + public static final class Course extends com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:baeldung.Course) + CourseOrBuilder { + // Use Course.newBuilder() to construct. + private Course(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); } - } - public Builder clear() { - super.clear(); - id_ = 0; - courseName_ = ""; - - if (studentBuilder_ == null) { - student_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000004); - } else { - studentBuilder_.clear(); + private Course() { + id_ = 0; + courseName_ = ""; + student_ = java.util.Collections.emptyList(); } - return this; - } - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.baeldung.protobuf.BaeldungTraining.internal_static_baeldung_Course_descriptor; - } - - public com.baeldung.protobuf.BaeldungTraining.Course getDefaultInstanceForType() { - return com.baeldung.protobuf.BaeldungTraining.Course.getDefaultInstance(); - } - - public com.baeldung.protobuf.BaeldungTraining.Course build() { - com.baeldung.protobuf.BaeldungTraining.Course result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); } - return result; - } - public com.baeldung.protobuf.BaeldungTraining.Course buildPartial() { - com.baeldung.protobuf.BaeldungTraining.Course result = new com.baeldung.protobuf.BaeldungTraining.Course(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - result.id_ = id_; - result.courseName_ = courseName_; - if (studentBuilder_ == null) { - if (((bitField0_ & 0x00000004) == 0x00000004)) { - student_ = java.util.Collections.unmodifiableList(student_); - bitField0_ = (bitField0_ & ~0x00000004); - } - result.student_ = student_; - } else { - result.student_ = studentBuilder_.build(); - } - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } + private Course(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 8: { - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.baeldung.protobuf.BaeldungTraining.Course) { - return mergeFrom((com.baeldung.protobuf.BaeldungTraining.Course)other); - } else { - super.mergeFrom(other); - return this; - } - } + id_ = input.readInt32(); + break; + } + case 18: { + java.lang.String s = input.readStringRequireUtf8(); - public Builder mergeFrom(com.baeldung.protobuf.BaeldungTraining.Course other) { - if (other == com.baeldung.protobuf.BaeldungTraining.Course.getDefaultInstance()) return this; - if (other.getId() != 0) { - setId(other.getId()); - } - if (!other.getCourseName().isEmpty()) { - courseName_ = other.courseName_; - onChanged(); - } - if (studentBuilder_ == null) { - if (!other.student_.isEmpty()) { - if (student_.isEmpty()) { - student_ = other.student_; - bitField0_ = (bitField0_ & ~0x00000004); - } else { - ensureStudentIsMutable(); - student_.addAll(other.student_); - } - onChanged(); - } - } else { - if (!other.student_.isEmpty()) { - if (studentBuilder_.isEmpty()) { - studentBuilder_.dispose(); - studentBuilder_ = null; - student_ = other.student_; - bitField0_ = (bitField0_ & ~0x00000004); - studentBuilder_ = - com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? - getStudentFieldBuilder() : null; - } else { - studentBuilder_.addAllMessages(other.student_); - } - } - } - onChanged(); - return this; - } - - public final boolean isInitialized() { - return true; - } - - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.baeldung.protobuf.BaeldungTraining.Course parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.baeldung.protobuf.BaeldungTraining.Course) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - private int id_ ; - /** - * optional int32 id = 1; - */ - public int getId() { - return id_; - } - /** - * optional int32 id = 1; - */ - public Builder setId(int value) { - - id_ = value; - onChanged(); - return this; - } - /** - * optional int32 id = 1; - */ - public Builder clearId() { - - id_ = 0; - onChanged(); - return this; - } - - private java.lang.Object courseName_ = ""; - /** - * optional string course_name = 2; - */ - 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; - } - } - /** - * optional string course_name = 2; - */ - 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; - } - } - /** - * optional string course_name = 2; - */ - public Builder setCourseName( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - courseName_ = value; - onChanged(); - return this; - } - /** - * optional string course_name = 2; - */ - public Builder clearCourseName() { - - courseName_ = getDefaultInstance().getCourseName(); - onChanged(); - return this; - } - /** - * optional string course_name = 2; - */ - public Builder setCourseNameBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - courseName_ = value; - onChanged(); - return this; - } - - private java.util.List student_ = - java.util.Collections.emptyList(); - private void ensureStudentIsMutable() { - if (!((bitField0_ & 0x00000004) == 0x00000004)) { - student_ = new java.util.ArrayList(student_); - bitField0_ |= 0x00000004; - } - } - - private com.google.protobuf.RepeatedFieldBuilder< - com.baeldung.protobuf.BaeldungTraining.Student, com.baeldung.protobuf.BaeldungTraining.Student.Builder, com.baeldung.protobuf.BaeldungTraining.StudentOrBuilder> studentBuilder_; - - /** - * repeated .baeldung.Student student = 3; - */ - public java.util.List getStudentList() { - if (studentBuilder_ == null) { - return java.util.Collections.unmodifiableList(student_); - } else { - return studentBuilder_.getMessageList(); - } - } - /** - * repeated .baeldung.Student student = 3; - */ - public int getStudentCount() { - if (studentBuilder_ == null) { - return student_.size(); - } else { - return studentBuilder_.getCount(); - } - } - /** - * repeated .baeldung.Student student = 3; - */ - public com.baeldung.protobuf.BaeldungTraining.Student getStudent(int index) { - if (studentBuilder_ == null) { - return student_.get(index); - } else { - return studentBuilder_.getMessage(index); - } - } - /** - * repeated .baeldung.Student student = 3; - */ - public Builder setStudent( - int index, com.baeldung.protobuf.BaeldungTraining.Student value) { - if (studentBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureStudentIsMutable(); - student_.set(index, value); - onChanged(); - } else { - studentBuilder_.setMessage(index, value); - } - return this; - } - /** - * repeated .baeldung.Student student = 3; - */ - public Builder setStudent( - int index, com.baeldung.protobuf.BaeldungTraining.Student.Builder builderForValue) { - if (studentBuilder_ == null) { - ensureStudentIsMutable(); - student_.set(index, builderForValue.build()); - onChanged(); - } else { - studentBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .baeldung.Student student = 3; - */ - public Builder addStudent(com.baeldung.protobuf.BaeldungTraining.Student value) { - if (studentBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureStudentIsMutable(); - student_.add(value); - onChanged(); - } else { - studentBuilder_.addMessage(value); - } - return this; - } - /** - * repeated .baeldung.Student student = 3; - */ - public Builder addStudent( - int index, com.baeldung.protobuf.BaeldungTraining.Student value) { - if (studentBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensureStudentIsMutable(); - student_.add(index, value); - onChanged(); - } else { - studentBuilder_.addMessage(index, value); - } - return this; - } - /** - * repeated .baeldung.Student student = 3; - */ - public Builder addStudent( - com.baeldung.protobuf.BaeldungTraining.Student.Builder builderForValue) { - if (studentBuilder_ == null) { - ensureStudentIsMutable(); - student_.add(builderForValue.build()); - onChanged(); - } else { - studentBuilder_.addMessage(builderForValue.build()); - } - return this; - } - /** - * repeated .baeldung.Student student = 3; - */ - public Builder addStudent( - int index, com.baeldung.protobuf.BaeldungTraining.Student.Builder builderForValue) { - if (studentBuilder_ == null) { - ensureStudentIsMutable(); - student_.add(index, builderForValue.build()); - onChanged(); - } else { - studentBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .baeldung.Student student = 3; - */ - public Builder addAllStudent( - java.lang.Iterable values) { - if (studentBuilder_ == null) { - ensureStudentIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, student_); - onChanged(); - } else { - studentBuilder_.addAllMessages(values); - } - return this; - } - /** - * repeated .baeldung.Student student = 3; - */ - public Builder clearStudent() { - if (studentBuilder_ == null) { - student_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000004); - onChanged(); - } else { - studentBuilder_.clear(); - } - return this; - } - /** - * repeated .baeldung.Student student = 3; - */ - public Builder removeStudent(int index) { - if (studentBuilder_ == null) { - ensureStudentIsMutable(); - student_.remove(index); - onChanged(); - } else { - studentBuilder_.remove(index); - } - return this; - } - /** - * repeated .baeldung.Student student = 3; - */ - public com.baeldung.protobuf.BaeldungTraining.Student.Builder getStudentBuilder( - int index) { - return getStudentFieldBuilder().getBuilder(index); - } - /** - * repeated .baeldung.Student student = 3; - */ - public com.baeldung.protobuf.BaeldungTraining.StudentOrBuilder getStudentOrBuilder( - int index) { - if (studentBuilder_ == null) { - return student_.get(index); } else { - return studentBuilder_.getMessageOrBuilder(index); - } - } - /** - * repeated .baeldung.Student student = 3; - */ - public java.util.List - getStudentOrBuilderList() { - if (studentBuilder_ != null) { - return studentBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(student_); - } - } - /** - * repeated .baeldung.Student student = 3; - */ - public com.baeldung.protobuf.BaeldungTraining.Student.Builder addStudentBuilder() { - return getStudentFieldBuilder().addBuilder( - com.baeldung.protobuf.BaeldungTraining.Student.getDefaultInstance()); - } - /** - * repeated .baeldung.Student student = 3; - */ - public com.baeldung.protobuf.BaeldungTraining.Student.Builder addStudentBuilder( - int index) { - return getStudentFieldBuilder().addBuilder( - index, com.baeldung.protobuf.BaeldungTraining.Student.getDefaultInstance()); - } - /** - * repeated .baeldung.Student student = 3; - */ - public java.util.List - getStudentBuilderList() { - return getStudentFieldBuilder().getBuilderList(); - } - private com.google.protobuf.RepeatedFieldBuilder< - com.baeldung.protobuf.BaeldungTraining.Student, com.baeldung.protobuf.BaeldungTraining.Student.Builder, com.baeldung.protobuf.BaeldungTraining.StudentOrBuilder> - getStudentFieldBuilder() { - if (studentBuilder_ == null) { - studentBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - com.baeldung.protobuf.BaeldungTraining.Student, com.baeldung.protobuf.BaeldungTraining.Student.Builder, com.baeldung.protobuf.BaeldungTraining.StudentOrBuilder>( - student_, - ((bitField0_ & 0x00000004) == 0x00000004), - getParentForChildren(), - isClean()); - student_ = null; - } - return studentBuilder_; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } - - - // @@protoc_insertion_point(builder_scope:baeldung.Course) - } - - // @@protoc_insertion_point(class_scope:baeldung.Course) - private static final com.baeldung.protobuf.BaeldungTraining.Course DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.baeldung.protobuf.BaeldungTraining.Course(); - } - - public static com.baeldung.protobuf.BaeldungTraining.Course getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - 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; - } - - public com.baeldung.protobuf.BaeldungTraining.Course getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - - } - - public interface StudentOrBuilder extends - // @@protoc_insertion_point(interface_extends:baeldung.Student) - com.google.protobuf.MessageOrBuilder { - - /** - * optional int32 id = 1; - */ - int getId(); - - /** - * optional string first_name = 2; - */ - java.lang.String getFirstName(); - /** - * optional string first_name = 2; - */ - com.google.protobuf.ByteString - getFirstNameBytes(); - - /** - * optional string last_name = 3; - */ - java.lang.String getLastName(); - /** - * optional string last_name = 3; - */ - com.google.protobuf.ByteString - getLastNameBytes(); - - /** - * optional string email = 4; - */ - java.lang.String getEmail(); - /** - * optional string email = 4; - */ - com.google.protobuf.ByteString - getEmailBytes(); - - /** - * repeated .baeldung.Student.PhoneNumber phone = 5; - */ - java.util.List - getPhoneList(); - /** - * repeated .baeldung.Student.PhoneNumber phone = 5; - */ - com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber getPhone(int index); - /** - * repeated .baeldung.Student.PhoneNumber phone = 5; - */ - int getPhoneCount(); - /** - * repeated .baeldung.Student.PhoneNumber phone = 5; - */ - java.util.List - getPhoneOrBuilderList(); - /** - * repeated .baeldung.Student.PhoneNumber phone = 5; - */ - com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumberOrBuilder getPhoneOrBuilder( - int index); - } - /** - * Protobuf type {@code baeldung.Student} - */ - public static final class Student extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:baeldung.Student) - StudentOrBuilder { - // Use Student.newBuilder() to construct. - private Student(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private Student() { - id_ = 0; - firstName_ = ""; - lastName_ = ""; - email_ = ""; - phone_ = java.util.Collections.emptyList(); - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private Student( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; - } - break; - } - case 8: { - - id_ = input.readInt32(); - break; - } - case 18: { - java.lang.String s = input.readStringRequireUtf8(); - - firstName_ = s; - break; - } - case 26: { - java.lang.String s = input.readStringRequireUtf8(); - - lastName_ = s; - break; - } - case 34: { - java.lang.String s = input.readStringRequireUtf8(); - - email_ = s; - break; - } - case 42: { - if (!((mutable_bitField0_ & 0x00000010) == 0x00000010)) { - phone_ = new java.util.ArrayList(); - mutable_bitField0_ |= 0x00000010; - } - phone_.add(input.readMessage(com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber.parser(), extensionRegistry)); - 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 { - if (((mutable_bitField0_ & 0x00000010) == 0x00000010)) { - phone_ = java.util.Collections.unmodifiableList(phone_); - } - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.baeldung.protobuf.BaeldungTraining.internal_static_baeldung_Student_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.baeldung.protobuf.BaeldungTraining.internal_static_baeldung_Student_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.baeldung.protobuf.BaeldungTraining.Student.class, com.baeldung.protobuf.BaeldungTraining.Student.Builder.class); - } - - /** - * Protobuf enum {@code baeldung.Student.PhoneType} - */ - public enum PhoneType - implements com.google.protobuf.ProtocolMessageEnum { - /** - * MOBILE = 0; - */ - MOBILE(0), - /** - * LANDLINE = 1; - */ - LANDLINE(1), - UNRECOGNIZED(-1), - ; - - /** - * MOBILE = 0; - */ - public static final int MOBILE_VALUE = 0; - /** - * LANDLINE = 1; - */ - public static final int LANDLINE_VALUE = 1; - - - public final int getNumber() { - if (this == UNRECOGNIZED) { - throw new java.lang.IllegalArgumentException( - "Can't get the number of an unknown enum value."); - } - return value; - } - - /** - * @deprecated Use {@link #forNumber(int)} instead. - */ - @java.lang.Deprecated - public static PhoneType valueOf(int value) { - return forNumber(value); - } - - public static PhoneType forNumber(int value) { - switch (value) { - case 0: return MOBILE; - case 1: return LANDLINE; - default: return null; - } - } - - public static com.google.protobuf.Internal.EnumLiteMap - internalGetValueMap() { - return internalValueMap; - } - private static final com.google.protobuf.Internal.EnumLiteMap< - PhoneType> internalValueMap = - new com.google.protobuf.Internal.EnumLiteMap() { - public PhoneType findValueByNumber(int number) { - return PhoneType.forNumber(number); - } - }; - - public final com.google.protobuf.Descriptors.EnumValueDescriptor - getValueDescriptor() { - return getDescriptor().getValues().get(ordinal()); - } - public final com.google.protobuf.Descriptors.EnumDescriptor - getDescriptorForType() { - return getDescriptor(); - } - public static final com.google.protobuf.Descriptors.EnumDescriptor - getDescriptor() { - return com.baeldung.protobuf.BaeldungTraining.Student.getDescriptor().getEnumTypes().get(0); - } - - private static final PhoneType[] VALUES = values(); - - public static PhoneType valueOf( - com.google.protobuf.Descriptors.EnumValueDescriptor desc) { - if (desc.getType() != getDescriptor()) { - throw new java.lang.IllegalArgumentException( - "EnumValueDescriptor is not for this type."); - } - if (desc.getIndex() == -1) { - return UNRECOGNIZED; - } - return VALUES[desc.getIndex()]; - } - - private final int value; - - private PhoneType(int value) { - this.value = value; - } - - // @@protoc_insertion_point(enum_scope:baeldung.Student.PhoneType) - } - - public interface PhoneNumberOrBuilder extends - // @@protoc_insertion_point(interface_extends:baeldung.Student.PhoneNumber) - com.google.protobuf.MessageOrBuilder { - - /** - * optional string number = 1; - */ - java.lang.String getNumber(); - /** - * optional string number = 1; - */ - com.google.protobuf.ByteString - getNumberBytes(); - - /** - * optional .baeldung.Student.PhoneType type = 2; - */ - int getTypeValue(); - /** - * optional .baeldung.Student.PhoneType type = 2; - */ - com.baeldung.protobuf.BaeldungTraining.Student.PhoneType getType(); - } - /** - * Protobuf type {@code baeldung.Student.PhoneNumber} - */ - public static final class PhoneNumber extends - com.google.protobuf.GeneratedMessage implements - // @@protoc_insertion_point(message_implements:baeldung.Student.PhoneNumber) - PhoneNumberOrBuilder { - // Use PhoneNumber.newBuilder() to construct. - private PhoneNumber(com.google.protobuf.GeneratedMessage.Builder builder) { - super(builder); - } - private PhoneNumber() { - number_ = ""; - type_ = 0; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); - } - private PhoneNumber( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - int mutable_bitField0_ = 0; - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - default: { - if (!input.skipField(tag)) { - done = true; + courseName_ = s; + break; + } + case 26: { + if (!((mutable_bitField0_ & 0x00000004) == 0x00000004)) { + student_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000004; + } + student_.add(input.readMessage(com.baeldung.protobuf.BaeldungTraining.Student.parser(), extensionRegistry)); + break; + } + } } - break; - } - case 10: { - java.lang.String s = input.readStringRequireUtf8(); - - number_ = s; - break; - } - case 16: { - int rawValue = input.readEnum(); - - type_ = rawValue; - 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 { + if (((mutable_bitField0_ & 0x00000004) == 0x00000004)) { + student_ = java.util.Collections.unmodifiableList(student_); + } + makeExtensionsImmutable(); } - } - } 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 { - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.baeldung.protobuf.BaeldungTraining.internal_static_baeldung_Student_PhoneNumber_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.baeldung.protobuf.BaeldungTraining.internal_static_baeldung_Student_PhoneNumber_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber.class, com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber.Builder.class); - } - - public static final int NUMBER_FIELD_NUMBER = 1; - private volatile java.lang.Object number_; - /** - * optional string number = 1; - */ - public java.lang.String getNumber() { - java.lang.Object ref = number_; - 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(); - number_ = s; - return s; - } - } - /** - * optional string number = 1; - */ - public com.google.protobuf.ByteString - getNumberBytes() { - java.lang.Object ref = number_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - number_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int TYPE_FIELD_NUMBER = 2; - private int type_; - /** - * optional .baeldung.Student.PhoneType type = 2; - */ - public int getTypeValue() { - return type_; - } - /** - * optional .baeldung.Student.PhoneType type = 2; - */ - public com.baeldung.protobuf.BaeldungTraining.Student.PhoneType getType() { - com.baeldung.protobuf.BaeldungTraining.Student.PhoneType result = com.baeldung.protobuf.BaeldungTraining.Student.PhoneType.forNumber(type_); - return result == null ? com.baeldung.protobuf.BaeldungTraining.Student.PhoneType.UNRECOGNIZED : result; - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getNumberBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 1, number_); - } - if (type_ != com.baeldung.protobuf.BaeldungTraining.Student.PhoneType.MOBILE.getNumber()) { - output.writeEnum(2, type_); - } - } - - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getNumberBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(1, number_); - } - if (type_ != com.baeldung.protobuf.BaeldungTraining.Student.PhoneType.MOBILE.getNumber()) { - size += com.google.protobuf.CodedOutputStream - .computeEnumSize(2, type_); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessage - .parseWithIOException(PARSER, input); - } - public static com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber 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 com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessage - .parseDelimitedWithIOException(PARSER, input); - } - public static com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber 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 com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessage - .parseWithIOException(PARSER, input); - } - public static com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessage - .parseWithIOException(PARSER, input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - 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 baeldung.Student.PhoneNumber} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:baeldung.Student.PhoneNumber) - com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumberOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.baeldung.protobuf.BaeldungTraining.internal_static_baeldung_Student_PhoneNumber_descriptor; } - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.baeldung.protobuf.BaeldungTraining.internal_static_baeldung_Student_PhoneNumber_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber.class, com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber.Builder.class); + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.baeldung.protobuf.BaeldungTraining.internal_static_baeldung_Course_descriptor; } - // Construct using com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { + return com.baeldung.protobuf.BaeldungTraining.internal_static_baeldung_Course_fieldAccessorTable.ensureFieldAccessorsInitialized(com.baeldung.protobuf.BaeldungTraining.Course.class, com.baeldung.protobuf.BaeldungTraining.Course.Builder.class); } - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - } - } - public Builder clear() { - super.clear(); - number_ = ""; + private int bitField0_; + public static final int ID_FIELD_NUMBER = 1; + private int id_; - type_ = 0; - - return this; + /** + * optional int32 id = 1; + */ + public int getId() { + return id_; } - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.baeldung.protobuf.BaeldungTraining.internal_static_baeldung_Student_PhoneNumber_descriptor; + public static final int COURSE_NAME_FIELD_NUMBER = 2; + private volatile java.lang.Object courseName_; + + /** + * optional string course_name = 2; + */ + 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; + } } - public com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber getDefaultInstanceForType() { - return com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber.getDefaultInstance(); + /** + * optional string course_name = 2; + */ + 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; + } } - public com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber build() { - com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; + public static final int STUDENT_FIELD_NUMBER = 3; + private java.util.List student_; + + /** + * repeated .baeldung.Student student = 3; + */ + public java.util.List getStudentList() { + return student_; } - public com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber buildPartial() { - com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber result = new com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber(this); - result.number_ = number_; - result.type_ = type_; - onBuilt(); - return result; + /** + * repeated .baeldung.Student student = 3; + */ + public java.util.List getStudentOrBuilderList() { + return student_; } - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber) { - return mergeFrom((com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber)other); - } else { - super.mergeFrom(other); - return this; - } + /** + * repeated .baeldung.Student student = 3; + */ + public int getStudentCount() { + return student_.size(); } - public Builder mergeFrom(com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber other) { - if (other == com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber.getDefaultInstance()) return this; - if (!other.getNumber().isEmpty()) { - number_ = other.number_; - onChanged(); - } - if (other.type_ != 0) { - setTypeValue(other.getTypeValue()); - } - onChanged(); - return this; + /** + * repeated .baeldung.Student student = 3; + */ + public com.baeldung.protobuf.BaeldungTraining.Student getStudent(int index) { + return student_.get(index); } + /** + * repeated .baeldung.Student student = 3; + */ + public com.baeldung.protobuf.BaeldungTraining.StudentOrBuilder getStudentOrBuilder(int index) { + return student_.get(index); + } + + private byte memoizedIsInitialized = -1; + public final boolean isInitialized() { - return true; + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) + return true; + if (isInitialized == 0) + return false; + + memoizedIsInitialized = 1; + return true; } - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); + 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.GeneratedMessage.writeString(output, 2, courseName_); + } + for (int i = 0; i < student_.size(); i++) { + output.writeMessage(3, student_.get(i)); } - } - return this; } - private java.lang.Object number_ = ""; + 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.GeneratedMessage.computeStringSize(2, courseName_); + } + for (int i = 0; i < student_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, student_.get(i)); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + + public static com.baeldung.protobuf.BaeldungTraining.Course parseFrom(com.google.protobuf.ByteString data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.baeldung.protobuf.BaeldungTraining.Course parseFrom(com.google.protobuf.ByteString data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.baeldung.protobuf.BaeldungTraining.Course parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.baeldung.protobuf.BaeldungTraining.Course parseFrom(byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.baeldung.protobuf.BaeldungTraining.Course parseFrom(java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.baeldung.protobuf.BaeldungTraining.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 com.baeldung.protobuf.BaeldungTraining.Course parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.baeldung.protobuf.BaeldungTraining.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 com.baeldung.protobuf.BaeldungTraining.Course parseFrom(com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.baeldung.protobuf.BaeldungTraining.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); + } + + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.baeldung.protobuf.BaeldungTraining.Course prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + 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; + } + /** - * optional string number = 1; + * Protobuf type {@code baeldung.Course} */ - public java.lang.String getNumber() { - java.lang.Object ref = number_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - number_ = s; - return s; - } else { - return (java.lang.String) ref; - } + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:baeldung.Course) + com.baeldung.protobuf.BaeldungTraining.CourseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.baeldung.protobuf.BaeldungTraining.internal_static_baeldung_Course_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { + return com.baeldung.protobuf.BaeldungTraining.internal_static_baeldung_Course_fieldAccessorTable.ensureFieldAccessorsInitialized(com.baeldung.protobuf.BaeldungTraining.Course.class, com.baeldung.protobuf.BaeldungTraining.Course.Builder.class); + } + + // Construct using com.baeldung.protobuf.BaeldungTraining.Course.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getStudentFieldBuilder(); + } + } + + public Builder clear() { + super.clear(); + id_ = 0; + + courseName_ = ""; + + if (studentBuilder_ == null) { + student_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + } else { + studentBuilder_.clear(); + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.baeldung.protobuf.BaeldungTraining.internal_static_baeldung_Course_descriptor; + } + + public com.baeldung.protobuf.BaeldungTraining.Course getDefaultInstanceForType() { + return com.baeldung.protobuf.BaeldungTraining.Course.getDefaultInstance(); + } + + public com.baeldung.protobuf.BaeldungTraining.Course build() { + com.baeldung.protobuf.BaeldungTraining.Course result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.baeldung.protobuf.BaeldungTraining.Course buildPartial() { + com.baeldung.protobuf.BaeldungTraining.Course result = new com.baeldung.protobuf.BaeldungTraining.Course(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + result.id_ = id_; + result.courseName_ = courseName_; + if (studentBuilder_ == null) { + if (((bitField0_ & 0x00000004) == 0x00000004)) { + student_ = java.util.Collections.unmodifiableList(student_); + bitField0_ = (bitField0_ & ~0x00000004); + } + result.student_ = student_; + } else { + result.student_ = studentBuilder_.build(); + } + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.baeldung.protobuf.BaeldungTraining.Course) { + return mergeFrom((com.baeldung.protobuf.BaeldungTraining.Course) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.baeldung.protobuf.BaeldungTraining.Course other) { + if (other == com.baeldung.protobuf.BaeldungTraining.Course.getDefaultInstance()) + return this; + if (other.getId() != 0) { + setId(other.getId()); + } + if (!other.getCourseName().isEmpty()) { + courseName_ = other.courseName_; + onChanged(); + } + if (studentBuilder_ == null) { + if (!other.student_.isEmpty()) { + if (student_.isEmpty()) { + student_ = other.student_; + bitField0_ = (bitField0_ & ~0x00000004); + } else { + ensureStudentIsMutable(); + student_.addAll(other.student_); + } + onChanged(); + } + } else { + if (!other.student_.isEmpty()) { + if (studentBuilder_.isEmpty()) { + studentBuilder_.dispose(); + studentBuilder_ = null; + student_ = other.student_; + bitField0_ = (bitField0_ & ~0x00000004); + studentBuilder_ = com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? getStudentFieldBuilder() : null; + } else { + studentBuilder_.addAllMessages(other.student_); + } + } + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { + com.baeldung.protobuf.BaeldungTraining.Course parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.baeldung.protobuf.BaeldungTraining.Course) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int bitField0_; + + private int id_; + + /** + * optional int32 id = 1; + */ + public int getId() { + return id_; + } + + /** + * optional int32 id = 1; + */ + public Builder setId(int value) { + + id_ = value; + onChanged(); + return this; + } + + /** + * optional int32 id = 1; + */ + public Builder clearId() { + + id_ = 0; + onChanged(); + return this; + } + + private java.lang.Object courseName_ = ""; + + /** + * optional string course_name = 2; + */ + 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; + } + } + + /** + * optional string course_name = 2; + */ + 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; + } + } + + /** + * optional string course_name = 2; + */ + public Builder setCourseName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + courseName_ = value; + onChanged(); + return this; + } + + /** + * optional string course_name = 2; + */ + public Builder clearCourseName() { + + courseName_ = getDefaultInstance().getCourseName(); + onChanged(); + return this; + } + + /** + * optional string course_name = 2; + */ + public Builder setCourseNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + courseName_ = value; + onChanged(); + return this; + } + + private java.util.List student_ = java.util.Collections.emptyList(); + + private void ensureStudentIsMutable() { + if (!((bitField0_ & 0x00000004) == 0x00000004)) { + student_ = new java.util.ArrayList(student_); + bitField0_ |= 0x00000004; + } + } + + private com.google.protobuf.RepeatedFieldBuilder studentBuilder_; + + /** + * repeated .baeldung.Student student = 3; + */ + public java.util.List getStudentList() { + if (studentBuilder_ == null) { + return java.util.Collections.unmodifiableList(student_); + } else { + return studentBuilder_.getMessageList(); + } + } + + /** + * repeated .baeldung.Student student = 3; + */ + public int getStudentCount() { + if (studentBuilder_ == null) { + return student_.size(); + } else { + return studentBuilder_.getCount(); + } + } + + /** + * repeated .baeldung.Student student = 3; + */ + public com.baeldung.protobuf.BaeldungTraining.Student getStudent(int index) { + if (studentBuilder_ == null) { + return student_.get(index); + } else { + return studentBuilder_.getMessage(index); + } + } + + /** + * repeated .baeldung.Student student = 3; + */ + public Builder setStudent(int index, com.baeldung.protobuf.BaeldungTraining.Student value) { + if (studentBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureStudentIsMutable(); + student_.set(index, value); + onChanged(); + } else { + studentBuilder_.setMessage(index, value); + } + return this; + } + + /** + * repeated .baeldung.Student student = 3; + */ + public Builder setStudent(int index, com.baeldung.protobuf.BaeldungTraining.Student.Builder builderForValue) { + if (studentBuilder_ == null) { + ensureStudentIsMutable(); + student_.set(index, builderForValue.build()); + onChanged(); + } else { + studentBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * repeated .baeldung.Student student = 3; + */ + public Builder addStudent(com.baeldung.protobuf.BaeldungTraining.Student value) { + if (studentBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureStudentIsMutable(); + student_.add(value); + onChanged(); + } else { + studentBuilder_.addMessage(value); + } + return this; + } + + /** + * repeated .baeldung.Student student = 3; + */ + public Builder addStudent(int index, com.baeldung.protobuf.BaeldungTraining.Student value) { + if (studentBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureStudentIsMutable(); + student_.add(index, value); + onChanged(); + } else { + studentBuilder_.addMessage(index, value); + } + return this; + } + + /** + * repeated .baeldung.Student student = 3; + */ + public Builder addStudent(com.baeldung.protobuf.BaeldungTraining.Student.Builder builderForValue) { + if (studentBuilder_ == null) { + ensureStudentIsMutable(); + student_.add(builderForValue.build()); + onChanged(); + } else { + studentBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * repeated .baeldung.Student student = 3; + */ + public Builder addStudent(int index, com.baeldung.protobuf.BaeldungTraining.Student.Builder builderForValue) { + if (studentBuilder_ == null) { + ensureStudentIsMutable(); + student_.add(index, builderForValue.build()); + onChanged(); + } else { + studentBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * repeated .baeldung.Student student = 3; + */ + public Builder addAllStudent(java.lang.Iterable values) { + if (studentBuilder_ == null) { + ensureStudentIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, student_); + onChanged(); + } else { + studentBuilder_.addAllMessages(values); + } + return this; + } + + /** + * repeated .baeldung.Student student = 3; + */ + public Builder clearStudent() { + if (studentBuilder_ == null) { + student_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + } else { + studentBuilder_.clear(); + } + return this; + } + + /** + * repeated .baeldung.Student student = 3; + */ + public Builder removeStudent(int index) { + if (studentBuilder_ == null) { + ensureStudentIsMutable(); + student_.remove(index); + onChanged(); + } else { + studentBuilder_.remove(index); + } + return this; + } + + /** + * repeated .baeldung.Student student = 3; + */ + public com.baeldung.protobuf.BaeldungTraining.Student.Builder getStudentBuilder(int index) { + return getStudentFieldBuilder().getBuilder(index); + } + + /** + * repeated .baeldung.Student student = 3; + */ + public com.baeldung.protobuf.BaeldungTraining.StudentOrBuilder getStudentOrBuilder(int index) { + if (studentBuilder_ == null) { + return student_.get(index); + } else { + return studentBuilder_.getMessageOrBuilder(index); + } + } + + /** + * repeated .baeldung.Student student = 3; + */ + public java.util.List getStudentOrBuilderList() { + if (studentBuilder_ != null) { + return studentBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(student_); + } + } + + /** + * repeated .baeldung.Student student = 3; + */ + public com.baeldung.protobuf.BaeldungTraining.Student.Builder addStudentBuilder() { + return getStudentFieldBuilder().addBuilder(com.baeldung.protobuf.BaeldungTraining.Student.getDefaultInstance()); + } + + /** + * repeated .baeldung.Student student = 3; + */ + public com.baeldung.protobuf.BaeldungTraining.Student.Builder addStudentBuilder(int index) { + return getStudentFieldBuilder().addBuilder(index, com.baeldung.protobuf.BaeldungTraining.Student.getDefaultInstance()); + } + + /** + * repeated .baeldung.Student student = 3; + */ + public java.util.List getStudentBuilderList() { + return getStudentFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilder getStudentFieldBuilder() { + if (studentBuilder_ == null) { + studentBuilder_ = new com.google.protobuf.RepeatedFieldBuilder(student_, + ((bitField0_ & 0x00000004) == 0x00000004), getParentForChildren(), isClean()); + student_ = null; + } + return studentBuilder_; + } + + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + // @@protoc_insertion_point(builder_scope:baeldung.Course) } + + // @@protoc_insertion_point(class_scope:baeldung.Course) + private static final com.baeldung.protobuf.BaeldungTraining.Course DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.baeldung.protobuf.BaeldungTraining.Course(); + } + + public static com.baeldung.protobuf.BaeldungTraining.Course getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = new com.google.protobuf.AbstractParser() { + 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; + } + + public com.baeldung.protobuf.BaeldungTraining.Course getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + public interface StudentOrBuilder extends + // @@protoc_insertion_point(interface_extends:baeldung.Student) + com.google.protobuf.MessageOrBuilder { + /** - * optional string number = 1; + * optional int32 id = 1; */ - public com.google.protobuf.ByteString - getNumberBytes() { - java.lang.Object ref = number_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - number_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } + int getId(); + /** - * optional string number = 1; + * optional string first_name = 2; */ - public Builder setNumber( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - number_ = value; - onChanged(); - return this; - } + java.lang.String getFirstName(); + /** - * optional string number = 1; + * optional string first_name = 2; */ - public Builder clearNumber() { - - number_ = getDefaultInstance().getNumber(); - onChanged(); - return this; - } + com.google.protobuf.ByteString getFirstNameBytes(); + /** - * optional string number = 1; + * optional string last_name = 3; */ - public Builder setNumberBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - number_ = value; - onChanged(); - return this; - } + java.lang.String getLastName(); - private int type_ = 0; /** - * optional .baeldung.Student.PhoneType type = 2; + * optional string last_name = 3; */ - public int getTypeValue() { - return type_; - } + com.google.protobuf.ByteString getLastNameBytes(); + /** - * optional .baeldung.Student.PhoneType type = 2; + * optional string email = 4; */ - public Builder setTypeValue(int value) { - type_ = value; - onChanged(); - return this; - } + java.lang.String getEmail(); + /** - * optional .baeldung.Student.PhoneType type = 2; + * optional string email = 4; */ - public com.baeldung.protobuf.BaeldungTraining.Student.PhoneType getType() { - com.baeldung.protobuf.BaeldungTraining.Student.PhoneType result = com.baeldung.protobuf.BaeldungTraining.Student.PhoneType.forNumber(type_); - return result == null ? com.baeldung.protobuf.BaeldungTraining.Student.PhoneType.UNRECOGNIZED : result; - } + com.google.protobuf.ByteString getEmailBytes(); + /** - * optional .baeldung.Student.PhoneType type = 2; + * repeated .baeldung.Student.PhoneNumber phone = 5; */ - public Builder setType(com.baeldung.protobuf.BaeldungTraining.Student.PhoneType value) { - if (value == null) { - throw new NullPointerException(); - } - - type_ = value.getNumber(); - onChanged(); - return this; - } + java.util.List getPhoneList(); + /** - * optional .baeldung.Student.PhoneType type = 2; + * repeated .baeldung.Student.PhoneNumber phone = 5; */ - public Builder clearType() { - - type_ = 0; - onChanged(); - return this; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } + com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber getPhone(int index); - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } + /** + * repeated .baeldung.Student.PhoneNumber phone = 5; + */ + int getPhoneCount(); + /** + * repeated .baeldung.Student.PhoneNumber phone = 5; + */ + java.util.List getPhoneOrBuilderList(); - // @@protoc_insertion_point(builder_scope:baeldung.Student.PhoneNumber) - } - - // @@protoc_insertion_point(class_scope:baeldung.Student.PhoneNumber) - private static final com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber(); - } - - public static com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public PhoneNumber parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new PhoneNumber(input, extensionRegistry); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - public com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - + /** + * repeated .baeldung.Student.PhoneNumber phone = 5; + */ + com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumberOrBuilder getPhoneOrBuilder(int index); } - private int bitField0_; - public static final int ID_FIELD_NUMBER = 1; - private int id_; - /** - * optional int32 id = 1; - */ - public int getId() { - return id_; - } - - public static final int FIRST_NAME_FIELD_NUMBER = 2; - private volatile java.lang.Object firstName_; - /** - * optional string first_name = 2; - */ - public java.lang.String getFirstName() { - java.lang.Object ref = firstName_; - 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(); - firstName_ = s; - return s; - } - } - /** - * optional string first_name = 2; - */ - public com.google.protobuf.ByteString - getFirstNameBytes() { - java.lang.Object ref = firstName_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - firstName_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int LAST_NAME_FIELD_NUMBER = 3; - private volatile java.lang.Object lastName_; - /** - * optional string last_name = 3; - */ - public java.lang.String getLastName() { - java.lang.Object ref = lastName_; - 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(); - lastName_ = s; - return s; - } - } - /** - * optional string last_name = 3; - */ - public com.google.protobuf.ByteString - getLastNameBytes() { - java.lang.Object ref = lastName_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - lastName_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int EMAIL_FIELD_NUMBER = 4; - private volatile java.lang.Object email_; - /** - * optional string email = 4; - */ - public java.lang.String getEmail() { - java.lang.Object ref = email_; - 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(); - email_ = s; - return s; - } - } - /** - * optional string email = 4; - */ - public com.google.protobuf.ByteString - getEmailBytes() { - java.lang.Object ref = email_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - email_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int PHONE_FIELD_NUMBER = 5; - private java.util.List phone_; - /** - * repeated .baeldung.Student.PhoneNumber phone = 5; - */ - public java.util.List getPhoneList() { - return phone_; - } - /** - * repeated .baeldung.Student.PhoneNumber phone = 5; - */ - public java.util.List - getPhoneOrBuilderList() { - return phone_; - } - /** - * repeated .baeldung.Student.PhoneNumber phone = 5; - */ - public int getPhoneCount() { - return phone_.size(); - } - /** - * repeated .baeldung.Student.PhoneNumber phone = 5; - */ - public com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber getPhone(int index) { - return phone_.get(index); - } - /** - * repeated .baeldung.Student.PhoneNumber phone = 5; - */ - public com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumberOrBuilder getPhoneOrBuilder( - int index) { - return phone_.get(index); - } - - private byte memoizedIsInitialized = -1; - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (id_ != 0) { - output.writeInt32(1, id_); - } - if (!getFirstNameBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 2, firstName_); - } - if (!getLastNameBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 3, lastName_); - } - if (!getEmailBytes().isEmpty()) { - com.google.protobuf.GeneratedMessage.writeString(output, 4, email_); - } - for (int i = 0; i < phone_.size(); i++) { - output.writeMessage(5, phone_.get(i)); - } - } - - 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 (!getFirstNameBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(2, firstName_); - } - if (!getLastNameBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(3, lastName_); - } - if (!getEmailBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessage.computeStringSize(4, email_); - } - for (int i = 0; i < phone_.size(); i++) { - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(5, phone_.get(i)); - } - memoizedSize = size; - return size; - } - - private static final long serialVersionUID = 0L; - public static com.baeldung.protobuf.BaeldungTraining.Student parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.baeldung.protobuf.BaeldungTraining.Student parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.baeldung.protobuf.BaeldungTraining.Student parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.baeldung.protobuf.BaeldungTraining.Student parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.baeldung.protobuf.BaeldungTraining.Student parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessage - .parseWithIOException(PARSER, input); - } - public static com.baeldung.protobuf.BaeldungTraining.Student 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 com.baeldung.protobuf.BaeldungTraining.Student parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessage - .parseDelimitedWithIOException(PARSER, input); - } - public static com.baeldung.protobuf.BaeldungTraining.Student 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 com.baeldung.protobuf.BaeldungTraining.Student parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessage - .parseWithIOException(PARSER, input); - } - public static com.baeldung.protobuf.BaeldungTraining.Student parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessage - .parseWithIOException(PARSER, input, extensionRegistry); - } - - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.baeldung.protobuf.BaeldungTraining.Student prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - 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 baeldung.Student} */ - public static final class Builder extends - com.google.protobuf.GeneratedMessage.Builder implements - // @@protoc_insertion_point(builder_implements:baeldung.Student) - com.baeldung.protobuf.BaeldungTraining.StudentOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.baeldung.protobuf.BaeldungTraining.internal_static_baeldung_Student_descriptor; - } - - protected com.google.protobuf.GeneratedMessage.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.baeldung.protobuf.BaeldungTraining.internal_static_baeldung_Student_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.baeldung.protobuf.BaeldungTraining.Student.class, com.baeldung.protobuf.BaeldungTraining.Student.Builder.class); - } - - // Construct using com.baeldung.protobuf.BaeldungTraining.Student.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessage.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { - getPhoneFieldBuilder(); + public static final class Student extends com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:baeldung.Student) + StudentOrBuilder { + // Use Student.newBuilder() to construct. + private Student(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); } - } - public Builder clear() { - super.clear(); - id_ = 0; - firstName_ = ""; - - lastName_ = ""; - - email_ = ""; - - if (phoneBuilder_ == null) { - phone_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000010); - } else { - phoneBuilder_.clear(); + private Student() { + id_ = 0; + firstName_ = ""; + lastName_ = ""; + email_ = ""; + phone_ = java.util.Collections.emptyList(); } - return this; - } - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.baeldung.protobuf.BaeldungTraining.internal_static_baeldung_Student_descriptor; - } + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } - public com.baeldung.protobuf.BaeldungTraining.Student getDefaultInstanceForType() { - return com.baeldung.protobuf.BaeldungTraining.Student.getDefaultInstance(); - } + private Student(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 8: { - public com.baeldung.protobuf.BaeldungTraining.Student build() { - com.baeldung.protobuf.BaeldungTraining.Student result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } + id_ = input.readInt32(); + break; + } + case 18: { + java.lang.String s = input.readStringRequireUtf8(); - public com.baeldung.protobuf.BaeldungTraining.Student buildPartial() { - com.baeldung.protobuf.BaeldungTraining.Student result = new com.baeldung.protobuf.BaeldungTraining.Student(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - result.id_ = id_; - result.firstName_ = firstName_; - result.lastName_ = lastName_; - result.email_ = email_; - if (phoneBuilder_ == null) { - if (((bitField0_ & 0x00000010) == 0x00000010)) { - phone_ = java.util.Collections.unmodifiableList(phone_); - bitField0_ = (bitField0_ & ~0x00000010); - } - result.phone_ = phone_; - } else { - result.phone_ = phoneBuilder_.build(); - } - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } + firstName_ = s; + break; + } + case 26: { + java.lang.String s = input.readStringRequireUtf8(); - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.baeldung.protobuf.BaeldungTraining.Student) { - return mergeFrom((com.baeldung.protobuf.BaeldungTraining.Student)other); - } else { - super.mergeFrom(other); - return this; - } - } + lastName_ = s; + break; + } + case 34: { + java.lang.String s = input.readStringRequireUtf8(); - public Builder mergeFrom(com.baeldung.protobuf.BaeldungTraining.Student other) { - if (other == com.baeldung.protobuf.BaeldungTraining.Student.getDefaultInstance()) return this; - if (other.getId() != 0) { - setId(other.getId()); - } - if (!other.getFirstName().isEmpty()) { - firstName_ = other.firstName_; - onChanged(); - } - if (!other.getLastName().isEmpty()) { - lastName_ = other.lastName_; - onChanged(); - } - if (!other.getEmail().isEmpty()) { - email_ = other.email_; - onChanged(); - } - if (phoneBuilder_ == null) { - if (!other.phone_.isEmpty()) { - if (phone_.isEmpty()) { - phone_ = other.phone_; - bitField0_ = (bitField0_ & ~0x00000010); - } else { - ensurePhoneIsMutable(); - phone_.addAll(other.phone_); + email_ = s; + break; + } + case 42: { + if (!((mutable_bitField0_ & 0x00000010) == 0x00000010)) { + phone_ = new java.util.ArrayList(); + mutable_bitField0_ |= 0x00000010; + } + phone_.add(input.readMessage(com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber.parser(), extensionRegistry)); + 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 { + if (((mutable_bitField0_ & 0x00000010) == 0x00000010)) { + phone_ = java.util.Collections.unmodifiableList(phone_); + } + makeExtensionsImmutable(); } - onChanged(); - } - } else { - if (!other.phone_.isEmpty()) { - if (phoneBuilder_.isEmpty()) { - phoneBuilder_.dispose(); - phoneBuilder_ = null; - phone_ = other.phone_; - bitField0_ = (bitField0_ & ~0x00000010); - phoneBuilder_ = - com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? - getPhoneFieldBuilder() : null; - } else { - phoneBuilder_.addAllMessages(other.phone_); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.baeldung.protobuf.BaeldungTraining.internal_static_baeldung_Student_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { + return com.baeldung.protobuf.BaeldungTraining.internal_static_baeldung_Student_fieldAccessorTable.ensureFieldAccessorsInitialized(com.baeldung.protobuf.BaeldungTraining.Student.class, com.baeldung.protobuf.BaeldungTraining.Student.Builder.class); + } + + /** + * Protobuf enum {@code baeldung.Student.PhoneType} + */ + public enum PhoneType implements com.google.protobuf.ProtocolMessageEnum { + /** + * MOBILE = 0; + */ + MOBILE(0), + /** + * LANDLINE = 1; + */ + LANDLINE(1), UNRECOGNIZED(-1),; + + /** + * MOBILE = 0; + */ + public static final int MOBILE_VALUE = 0; + /** + * LANDLINE = 1; + */ + public static final int LANDLINE_VALUE = 1; + + public final int getNumber() { + if (this == UNRECOGNIZED) { + throw new java.lang.IllegalArgumentException("Can't get the number of an unknown enum value."); + } + return value; } - } - } - onChanged(); - return this; - } - public final boolean isInitialized() { - return true; - } + /** + * @deprecated Use {@link #forNumber(int)} instead. + */ + @java.lang.Deprecated + public static PhoneType valueOf(int value) { + return forNumber(value); + } - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.baeldung.protobuf.BaeldungTraining.Student parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.baeldung.protobuf.BaeldungTraining.Student) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; + public static PhoneType forNumber(int value) { + switch (value) { + case 0: + return MOBILE; + case 1: + return LANDLINE; + default: + return null; + } + } - private int id_ ; - /** - * optional int32 id = 1; - */ - public int getId() { - return id_; - } - /** - * optional int32 id = 1; - */ - public Builder setId(int value) { - - id_ = value; - onChanged(); - return this; - } - /** - * optional int32 id = 1; - */ - public Builder clearId() { - - id_ = 0; - onChanged(); - return this; - } + public static com.google.protobuf.Internal.EnumLiteMap internalGetValueMap() { + return internalValueMap; + } - private java.lang.Object firstName_ = ""; - /** - * optional string first_name = 2; - */ - public java.lang.String getFirstName() { - java.lang.Object ref = firstName_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - firstName_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string first_name = 2; - */ - public com.google.protobuf.ByteString - getFirstNameBytes() { - java.lang.Object ref = firstName_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - firstName_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string first_name = 2; - */ - public Builder setFirstName( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - firstName_ = value; - onChanged(); - return this; - } - /** - * optional string first_name = 2; - */ - public Builder clearFirstName() { - - firstName_ = getDefaultInstance().getFirstName(); - onChanged(); - return this; - } - /** - * optional string first_name = 2; - */ - public Builder setFirstNameBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - firstName_ = value; - onChanged(); - return this; - } + private static final com.google.protobuf.Internal.EnumLiteMap internalValueMap = new com.google.protobuf.Internal.EnumLiteMap() { + public PhoneType findValueByNumber(int number) { + return PhoneType.forNumber(number); + } + }; - private java.lang.Object lastName_ = ""; - /** - * optional string last_name = 3; - */ - public java.lang.String getLastName() { - java.lang.Object ref = lastName_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - lastName_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string last_name = 3; - */ - public com.google.protobuf.ByteString - getLastNameBytes() { - java.lang.Object ref = lastName_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - lastName_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string last_name = 3; - */ - public Builder setLastName( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - lastName_ = value; - onChanged(); - return this; - } - /** - * optional string last_name = 3; - */ - public Builder clearLastName() { - - lastName_ = getDefaultInstance().getLastName(); - onChanged(); - return this; - } - /** - * optional string last_name = 3; - */ - public Builder setLastNameBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - lastName_ = value; - onChanged(); - return this; - } + public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { + return getDescriptor().getValues().get(ordinal()); + } - private java.lang.Object email_ = ""; - /** - * optional string email = 4; - */ - public java.lang.String getEmail() { - java.lang.Object ref = email_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - email_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * optional string email = 4; - */ - public com.google.protobuf.ByteString - getEmailBytes() { - java.lang.Object ref = email_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - email_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * optional string email = 4; - */ - public Builder setEmail( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - email_ = value; - onChanged(); - return this; - } - /** - * optional string email = 4; - */ - public Builder clearEmail() { - - email_ = getDefaultInstance().getEmail(); - onChanged(); - return this; - } - /** - * optional string email = 4; - */ - public Builder setEmailBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - email_ = value; - onChanged(); - return this; - } + public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { + return getDescriptor(); + } - private java.util.List phone_ = - java.util.Collections.emptyList(); - private void ensurePhoneIsMutable() { - if (!((bitField0_ & 0x00000010) == 0x00000010)) { - phone_ = new java.util.ArrayList(phone_); - bitField0_ |= 0x00000010; - } - } + public static final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.baeldung.protobuf.BaeldungTraining.Student.getDescriptor().getEnumTypes().get(0); + } - private com.google.protobuf.RepeatedFieldBuilder< - com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber, com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber.Builder, com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumberOrBuilder> phoneBuilder_; + private static final PhoneType[] VALUES = values(); - /** - * repeated .baeldung.Student.PhoneNumber phone = 5; - */ - public java.util.List getPhoneList() { - if (phoneBuilder_ == null) { - return java.util.Collections.unmodifiableList(phone_); - } else { - return phoneBuilder_.getMessageList(); - } - } - /** - * repeated .baeldung.Student.PhoneNumber phone = 5; - */ - public int getPhoneCount() { - if (phoneBuilder_ == null) { - return phone_.size(); - } else { - return phoneBuilder_.getCount(); - } - } - /** - * repeated .baeldung.Student.PhoneNumber phone = 5; - */ - public com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber getPhone(int index) { - if (phoneBuilder_ == null) { - return phone_.get(index); - } else { - return phoneBuilder_.getMessage(index); - } - } - /** - * repeated .baeldung.Student.PhoneNumber phone = 5; - */ - public Builder setPhone( - int index, com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber value) { - if (phoneBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensurePhoneIsMutable(); - phone_.set(index, value); - onChanged(); - } else { - phoneBuilder_.setMessage(index, value); - } - return this; - } - /** - * repeated .baeldung.Student.PhoneNumber phone = 5; - */ - public Builder setPhone( - int index, com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber.Builder builderForValue) { - if (phoneBuilder_ == null) { - ensurePhoneIsMutable(); - phone_.set(index, builderForValue.build()); - onChanged(); - } else { - phoneBuilder_.setMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .baeldung.Student.PhoneNumber phone = 5; - */ - public Builder addPhone(com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber value) { - if (phoneBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensurePhoneIsMutable(); - phone_.add(value); - onChanged(); - } else { - phoneBuilder_.addMessage(value); - } - return this; - } - /** - * repeated .baeldung.Student.PhoneNumber phone = 5; - */ - public Builder addPhone( - int index, com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber value) { - if (phoneBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - ensurePhoneIsMutable(); - phone_.add(index, value); - onChanged(); - } else { - phoneBuilder_.addMessage(index, value); - } - return this; - } - /** - * repeated .baeldung.Student.PhoneNumber phone = 5; - */ - public Builder addPhone( - com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber.Builder builderForValue) { - if (phoneBuilder_ == null) { - ensurePhoneIsMutable(); - phone_.add(builderForValue.build()); - onChanged(); - } else { - phoneBuilder_.addMessage(builderForValue.build()); - } - return this; - } - /** - * repeated .baeldung.Student.PhoneNumber phone = 5; - */ - public Builder addPhone( - int index, com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber.Builder builderForValue) { - if (phoneBuilder_ == null) { - ensurePhoneIsMutable(); - phone_.add(index, builderForValue.build()); - onChanged(); - } else { - phoneBuilder_.addMessage(index, builderForValue.build()); - } - return this; - } - /** - * repeated .baeldung.Student.PhoneNumber phone = 5; - */ - public Builder addAllPhone( - java.lang.Iterable values) { - if (phoneBuilder_ == null) { - ensurePhoneIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( - values, phone_); - onChanged(); - } else { - phoneBuilder_.addAllMessages(values); - } - return this; - } - /** - * repeated .baeldung.Student.PhoneNumber phone = 5; - */ - public Builder clearPhone() { - if (phoneBuilder_ == null) { - phone_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000010); - onChanged(); - } else { - phoneBuilder_.clear(); - } - return this; - } - /** - * repeated .baeldung.Student.PhoneNumber phone = 5; - */ - public Builder removePhone(int index) { - if (phoneBuilder_ == null) { - ensurePhoneIsMutable(); - phone_.remove(index); - onChanged(); - } else { - phoneBuilder_.remove(index); - } - return this; - } - /** - * repeated .baeldung.Student.PhoneNumber phone = 5; - */ - public com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber.Builder getPhoneBuilder( - int index) { - return getPhoneFieldBuilder().getBuilder(index); - } - /** - * repeated .baeldung.Student.PhoneNumber phone = 5; - */ - public com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumberOrBuilder getPhoneOrBuilder( - int index) { - if (phoneBuilder_ == null) { - return phone_.get(index); } else { - return phoneBuilder_.getMessageOrBuilder(index); - } - } - /** - * repeated .baeldung.Student.PhoneNumber phone = 5; - */ - public java.util.List - getPhoneOrBuilderList() { - if (phoneBuilder_ != null) { - return phoneBuilder_.getMessageOrBuilderList(); - } else { - return java.util.Collections.unmodifiableList(phone_); - } - } - /** - * repeated .baeldung.Student.PhoneNumber phone = 5; - */ - public com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber.Builder addPhoneBuilder() { - return getPhoneFieldBuilder().addBuilder( - com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber.getDefaultInstance()); - } - /** - * repeated .baeldung.Student.PhoneNumber phone = 5; - */ - public com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber.Builder addPhoneBuilder( - int index) { - return getPhoneFieldBuilder().addBuilder( - index, com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber.getDefaultInstance()); - } - /** - * repeated .baeldung.Student.PhoneNumber phone = 5; - */ - public java.util.List - getPhoneBuilderList() { - return getPhoneFieldBuilder().getBuilderList(); - } - private com.google.protobuf.RepeatedFieldBuilder< - com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber, com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber.Builder, com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumberOrBuilder> - getPhoneFieldBuilder() { - if (phoneBuilder_ == null) { - phoneBuilder_ = new com.google.protobuf.RepeatedFieldBuilder< - com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber, com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber.Builder, com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumberOrBuilder>( - phone_, - ((bitField0_ & 0x00000010) == 0x00000010), - getParentForChildren(), - isClean()); - phone_ = null; - } - return phoneBuilder_; - } - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } + public static PhoneType valueOf(com.google.protobuf.Descriptors.EnumValueDescriptor desc) { + if (desc.getType() != getDescriptor()) { + throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); + } + if (desc.getIndex() == -1) { + return UNRECOGNIZED; + } + return VALUES[desc.getIndex()]; + } - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return this; - } + private final int value; + private PhoneType(int value) { + this.value = value; + } - // @@protoc_insertion_point(builder_scope:baeldung.Student) - } + // @@protoc_insertion_point(enum_scope:baeldung.Student.PhoneType) + } - // @@protoc_insertion_point(class_scope:baeldung.Student) - private static final com.baeldung.protobuf.BaeldungTraining.Student DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.baeldung.protobuf.BaeldungTraining.Student(); - } + public interface PhoneNumberOrBuilder extends + // @@protoc_insertion_point(interface_extends:baeldung.Student.PhoneNumber) + com.google.protobuf.MessageOrBuilder { - public static com.baeldung.protobuf.BaeldungTraining.Student getDefaultInstance() { - return DEFAULT_INSTANCE; - } + /** + * optional string number = 1; + */ + java.lang.String getNumber(); - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - public Student parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new Student(input, extensionRegistry); - } - }; + /** + * optional string number = 1; + */ + com.google.protobuf.ByteString getNumberBytes(); - public static com.google.protobuf.Parser parser() { - return PARSER; - } + /** + * optional .baeldung.Student.PhoneType type = 2; + */ + int getTypeValue(); - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } + /** + * optional .baeldung.Student.PhoneType type = 2; + */ + com.baeldung.protobuf.BaeldungTraining.Student.PhoneType getType(); + } - public com.baeldung.protobuf.BaeldungTraining.Student getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } + /** + * Protobuf type {@code baeldung.Student.PhoneNumber} + */ + public static final class PhoneNumber extends com.google.protobuf.GeneratedMessage implements + // @@protoc_insertion_point(message_implements:baeldung.Student.PhoneNumber) + PhoneNumberOrBuilder { + // Use PhoneNumber.newBuilder() to construct. + private PhoneNumber(com.google.protobuf.GeneratedMessage.Builder builder) { + super(builder); + } - } + private PhoneNumber() { + number_ = ""; + type_ = 0; + } - private static final com.google.protobuf.Descriptors.Descriptor - internal_static_baeldung_Course_descriptor; - private static final - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_baeldung_Course_fieldAccessorTable; - private static final com.google.protobuf.Descriptors.Descriptor - internal_static_baeldung_Student_descriptor; - private static final - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_baeldung_Student_fieldAccessorTable; - private static final com.google.protobuf.Descriptors.Descriptor - internal_static_baeldung_Student_PhoneNumber_descriptor; - private static final - com.google.protobuf.GeneratedMessage.FieldAccessorTable - internal_static_baeldung_Student_PhoneNumber_fieldAccessorTable; + @java.lang.Override + public final com.google.protobuf.UnknownFieldSet getUnknownFields() { + return com.google.protobuf.UnknownFieldSet.getDefaultInstance(); + } - public static com.google.protobuf.Descriptors.FileDescriptor - getDescriptor() { - return descriptor; - } - private static com.google.protobuf.Descriptors.FileDescriptor - descriptor; - static { - java.lang.String[] descriptorData = { - "\n\030resources/baeldung.proto\022\010baeldung\"M\n\006" + - "Course\022\n\n\002id\030\001 \001(\005\022\023\n\013course_name\030\002 \001(\t\022" + - "\"\n\007student\030\003 \003(\0132\021.baeldung.Student\"\352\001\n\007" + - "Student\022\n\n\002id\030\001 \001(\005\022\022\n\nfirst_name\030\002 \001(\t\022" + - "\021\n\tlast_name\030\003 \001(\t\022\r\n\005email\030\004 \001(\t\022,\n\005pho" + - "ne\030\005 \003(\0132\035.baeldung.Student.PhoneNumber\032" + - "H\n\013PhoneNumber\022\016\n\006number\030\001 \001(\t\022)\n\004type\030\002" + - " \001(\0162\033.baeldung.Student.PhoneType\"%\n\tPho" + - "neType\022\n\n\006MOBILE\020\000\022\014\n\010LANDLINE\020\001B)\n\025com." + - "baeldung.protobufB\020BaeldungTrainingb\006pro", - "to3" - }; - com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = - new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { - public com.google.protobuf.ExtensionRegistry assignDescriptors( - com.google.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - return null; - } + private PhoneNumber(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + this(); + int mutable_bitField0_ = 0; + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + default: { + if (!input.skipField(tag)) { + done = true; + } + break; + } + case 10: { + java.lang.String s = input.readStringRequireUtf8(); + + number_ = s; + break; + } + case 16: { + int rawValue = input.readEnum(); + + type_ = rawValue; + 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 { + makeExtensionsImmutable(); + } + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.baeldung.protobuf.BaeldungTraining.internal_static_baeldung_Student_PhoneNumber_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { + return com.baeldung.protobuf.BaeldungTraining.internal_static_baeldung_Student_PhoneNumber_fieldAccessorTable.ensureFieldAccessorsInitialized(com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber.class, + com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber.Builder.class); + } + + public static final int NUMBER_FIELD_NUMBER = 1; + private volatile java.lang.Object number_; + + /** + * optional string number = 1; + */ + public java.lang.String getNumber() { + java.lang.Object ref = number_; + 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(); + number_ = s; + return s; + } + } + + /** + * optional string number = 1; + */ + public com.google.protobuf.ByteString getNumberBytes() { + java.lang.Object ref = number_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + number_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int TYPE_FIELD_NUMBER = 2; + private int type_; + + /** + * optional .baeldung.Student.PhoneType type = 2; + */ + public int getTypeValue() { + return type_; + } + + /** + * optional .baeldung.Student.PhoneType type = 2; + */ + public com.baeldung.protobuf.BaeldungTraining.Student.PhoneType getType() { + com.baeldung.protobuf.BaeldungTraining.Student.PhoneType result = com.baeldung.protobuf.BaeldungTraining.Student.PhoneType.forNumber(type_); + return result == null ? com.baeldung.protobuf.BaeldungTraining.Student.PhoneType.UNRECOGNIZED : result; + } + + private byte memoizedIsInitialized = -1; + + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) + return true; + if (isInitialized == 0) + return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!getNumberBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 1, number_); + } + if (type_ != com.baeldung.protobuf.BaeldungTraining.Student.PhoneType.MOBILE.getNumber()) { + output.writeEnum(2, type_); + } + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) + return size; + + size = 0; + if (!getNumberBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(1, number_); + } + if (type_ != com.baeldung.protobuf.BaeldungTraining.Student.PhoneType.MOBILE.getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(2, type_); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + + public static com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber parseFrom(com.google.protobuf.ByteString data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber parseFrom(com.google.protobuf.ByteString data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber parseFrom(byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber parseFrom(java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber 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 com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber 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 com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber parseFrom(com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber parseFrom(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + 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 baeldung.Student.PhoneNumber} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:baeldung.Student.PhoneNumber) + com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumberOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.baeldung.protobuf.BaeldungTraining.internal_static_baeldung_Student_PhoneNumber_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { + return com.baeldung.protobuf.BaeldungTraining.internal_static_baeldung_Student_PhoneNumber_fieldAccessorTable.ensureFieldAccessorsInitialized(com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber.class, + com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber.Builder.class); + } + + // Construct using com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + } + } + + public Builder clear() { + super.clear(); + number_ = ""; + + type_ = 0; + + return this; + } + + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.baeldung.protobuf.BaeldungTraining.internal_static_baeldung_Student_PhoneNumber_descriptor; + } + + public com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber getDefaultInstanceForType() { + return com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber.getDefaultInstance(); + } + + public com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber build() { + com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber buildPartial() { + com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber result = new com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber(this); + result.number_ = number_; + result.type_ = type_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber) { + return mergeFrom((com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber other) { + if (other == com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber.getDefaultInstance()) + return this; + if (!other.getNumber().isEmpty()) { + number_ = other.number_; + onChanged(); + } + if (other.type_ != 0) { + setTypeValue(other.getTypeValue()); + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { + com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private java.lang.Object number_ = ""; + + /** + * optional string number = 1; + */ + public java.lang.String getNumber() { + java.lang.Object ref = number_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + number_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * optional string number = 1; + */ + public com.google.protobuf.ByteString getNumberBytes() { + java.lang.Object ref = number_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + number_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * optional string number = 1; + */ + public Builder setNumber(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + number_ = value; + onChanged(); + return this; + } + + /** + * optional string number = 1; + */ + public Builder clearNumber() { + + number_ = getDefaultInstance().getNumber(); + onChanged(); + return this; + } + + /** + * optional string number = 1; + */ + public Builder setNumberBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + number_ = value; + onChanged(); + return this; + } + + private int type_ = 0; + + /** + * optional .baeldung.Student.PhoneType type = 2; + */ + public int getTypeValue() { + return type_; + } + + /** + * optional .baeldung.Student.PhoneType type = 2; + */ + public Builder setTypeValue(int value) { + type_ = value; + onChanged(); + return this; + } + + /** + * optional .baeldung.Student.PhoneType type = 2; + */ + public com.baeldung.protobuf.BaeldungTraining.Student.PhoneType getType() { + com.baeldung.protobuf.BaeldungTraining.Student.PhoneType result = com.baeldung.protobuf.BaeldungTraining.Student.PhoneType.forNumber(type_); + return result == null ? com.baeldung.protobuf.BaeldungTraining.Student.PhoneType.UNRECOGNIZED : result; + } + + /** + * optional .baeldung.Student.PhoneType type = 2; + */ + public Builder setType(com.baeldung.protobuf.BaeldungTraining.Student.PhoneType value) { + if (value == null) { + throw new NullPointerException(); + } + + type_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * optional .baeldung.Student.PhoneType type = 2; + */ + public Builder clearType() { + + type_ = 0; + onChanged(); + return this; + } + + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + // @@protoc_insertion_point(builder_scope:baeldung.Student.PhoneNumber) + } + + // @@protoc_insertion_point(class_scope:baeldung.Student.PhoneNumber) + private static final com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber(); + } + + public static com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = new com.google.protobuf.AbstractParser() { + public PhoneNumber parsePartialFrom(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + return new PhoneNumber(input, extensionRegistry); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private int bitField0_; + public static final int ID_FIELD_NUMBER = 1; + private int id_; + + /** + * optional int32 id = 1; + */ + public int getId() { + return id_; + } + + public static final int FIRST_NAME_FIELD_NUMBER = 2; + private volatile java.lang.Object firstName_; + + /** + * optional string first_name = 2; + */ + public java.lang.String getFirstName() { + java.lang.Object ref = firstName_; + 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(); + firstName_ = s; + return s; + } + } + + /** + * optional string first_name = 2; + */ + public com.google.protobuf.ByteString getFirstNameBytes() { + java.lang.Object ref = firstName_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + firstName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int LAST_NAME_FIELD_NUMBER = 3; + private volatile java.lang.Object lastName_; + + /** + * optional string last_name = 3; + */ + public java.lang.String getLastName() { + java.lang.Object ref = lastName_; + 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(); + lastName_ = s; + return s; + } + } + + /** + * optional string last_name = 3; + */ + public com.google.protobuf.ByteString getLastNameBytes() { + java.lang.Object ref = lastName_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + lastName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int EMAIL_FIELD_NUMBER = 4; + private volatile java.lang.Object email_; + + /** + * optional string email = 4; + */ + public java.lang.String getEmail() { + java.lang.Object ref = email_; + 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(); + email_ = s; + return s; + } + } + + /** + * optional string email = 4; + */ + public com.google.protobuf.ByteString getEmailBytes() { + java.lang.Object ref = email_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + email_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PHONE_FIELD_NUMBER = 5; + private java.util.List phone_; + + /** + * repeated .baeldung.Student.PhoneNumber phone = 5; + */ + public java.util.List getPhoneList() { + return phone_; + } + + /** + * repeated .baeldung.Student.PhoneNumber phone = 5; + */ + public java.util.List getPhoneOrBuilderList() { + return phone_; + } + + /** + * repeated .baeldung.Student.PhoneNumber phone = 5; + */ + public int getPhoneCount() { + return phone_.size(); + } + + /** + * repeated .baeldung.Student.PhoneNumber phone = 5; + */ + public com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber getPhone(int index) { + return phone_.get(index); + } + + /** + * repeated .baeldung.Student.PhoneNumber phone = 5; + */ + public com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumberOrBuilder getPhoneOrBuilder(int index) { + return phone_.get(index); + } + + private byte memoizedIsInitialized = -1; + + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) + return true; + if (isInitialized == 0) + return false; + + memoizedIsInitialized = 1; + return true; + } + + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (id_ != 0) { + output.writeInt32(1, id_); + } + if (!getFirstNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 2, firstName_); + } + if (!getLastNameBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 3, lastName_); + } + if (!getEmailBytes().isEmpty()) { + com.google.protobuf.GeneratedMessage.writeString(output, 4, email_); + } + for (int i = 0; i < phone_.size(); i++) { + output.writeMessage(5, phone_.get(i)); + } + } + + 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 (!getFirstNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(2, firstName_); + } + if (!getLastNameBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(3, lastName_); + } + if (!getEmailBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessage.computeStringSize(4, email_); + } + for (int i = 0; i < phone_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(5, phone_.get(i)); + } + memoizedSize = size; + return size; + } + + private static final long serialVersionUID = 0L; + + public static com.baeldung.protobuf.BaeldungTraining.Student parseFrom(com.google.protobuf.ByteString data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.baeldung.protobuf.BaeldungTraining.Student parseFrom(com.google.protobuf.ByteString data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.baeldung.protobuf.BaeldungTraining.Student parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.baeldung.protobuf.BaeldungTraining.Student parseFrom(byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.baeldung.protobuf.BaeldungTraining.Student parseFrom(java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.baeldung.protobuf.BaeldungTraining.Student 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 com.baeldung.protobuf.BaeldungTraining.Student parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseDelimitedWithIOException(PARSER, input); + } + + public static com.baeldung.protobuf.BaeldungTraining.Student 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 com.baeldung.protobuf.BaeldungTraining.Student parseFrom(com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input); + } + + public static com.baeldung.protobuf.BaeldungTraining.Student parseFrom(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { + return com.google.protobuf.GeneratedMessage.parseWithIOException(PARSER, input, extensionRegistry); + } + + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(com.baeldung.protobuf.BaeldungTraining.Student prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + 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 baeldung.Student} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessage.Builder implements + // @@protoc_insertion_point(builder_implements:baeldung.Student) + com.baeldung.protobuf.BaeldungTraining.StudentOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.baeldung.protobuf.BaeldungTraining.internal_static_baeldung_Student_descriptor; + } + + protected com.google.protobuf.GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable() { + return com.baeldung.protobuf.BaeldungTraining.internal_static_baeldung_Student_fieldAccessorTable.ensureFieldAccessorsInitialized(com.baeldung.protobuf.BaeldungTraining.Student.class, + com.baeldung.protobuf.BaeldungTraining.Student.Builder.class); + } + + // Construct using com.baeldung.protobuf.BaeldungTraining.Student.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessage.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) { + getPhoneFieldBuilder(); + } + } + + public Builder clear() { + super.clear(); + id_ = 0; + + firstName_ = ""; + + lastName_ = ""; + + email_ = ""; + + if (phoneBuilder_ == null) { + phone_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000010); + } else { + phoneBuilder_.clear(); + } + return this; + } + + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.baeldung.protobuf.BaeldungTraining.internal_static_baeldung_Student_descriptor; + } + + public com.baeldung.protobuf.BaeldungTraining.Student getDefaultInstanceForType() { + return com.baeldung.protobuf.BaeldungTraining.Student.getDefaultInstance(); + } + + public com.baeldung.protobuf.BaeldungTraining.Student build() { + com.baeldung.protobuf.BaeldungTraining.Student result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + public com.baeldung.protobuf.BaeldungTraining.Student buildPartial() { + com.baeldung.protobuf.BaeldungTraining.Student result = new com.baeldung.protobuf.BaeldungTraining.Student(this); + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + result.id_ = id_; + result.firstName_ = firstName_; + result.lastName_ = lastName_; + result.email_ = email_; + if (phoneBuilder_ == null) { + if (((bitField0_ & 0x00000010) == 0x00000010)) { + phone_ = java.util.Collections.unmodifiableList(phone_); + bitField0_ = (bitField0_ & ~0x00000010); + } + result.phone_ = phone_; + } else { + result.phone_ = phoneBuilder_.build(); + } + result.bitField0_ = to_bitField0_; + onBuilt(); + return result; + } + + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.baeldung.protobuf.BaeldungTraining.Student) { + return mergeFrom((com.baeldung.protobuf.BaeldungTraining.Student) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.baeldung.protobuf.BaeldungTraining.Student other) { + if (other == com.baeldung.protobuf.BaeldungTraining.Student.getDefaultInstance()) + return this; + if (other.getId() != 0) { + setId(other.getId()); + } + if (!other.getFirstName().isEmpty()) { + firstName_ = other.firstName_; + onChanged(); + } + if (!other.getLastName().isEmpty()) { + lastName_ = other.lastName_; + onChanged(); + } + if (!other.getEmail().isEmpty()) { + email_ = other.email_; + onChanged(); + } + if (phoneBuilder_ == null) { + if (!other.phone_.isEmpty()) { + if (phone_.isEmpty()) { + phone_ = other.phone_; + bitField0_ = (bitField0_ & ~0x00000010); + } else { + ensurePhoneIsMutable(); + phone_.addAll(other.phone_); + } + onChanged(); + } + } else { + if (!other.phone_.isEmpty()) { + if (phoneBuilder_.isEmpty()) { + phoneBuilder_.dispose(); + phoneBuilder_ = null; + phone_ = other.phone_; + bitField0_ = (bitField0_ & ~0x00000010); + phoneBuilder_ = com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? getPhoneFieldBuilder() : null; + } else { + phoneBuilder_.addAllMessages(other.phone_); + } + } + } + onChanged(); + return this; + } + + public final boolean isInitialized() { + return true; + } + + public Builder mergeFrom(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { + com.baeldung.protobuf.BaeldungTraining.Student parsedMessage = null; + try { + parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + parsedMessage = (com.baeldung.protobuf.BaeldungTraining.Student) e.getUnfinishedMessage(); + throw e.unwrapIOException(); + } finally { + if (parsedMessage != null) { + mergeFrom(parsedMessage); + } + } + return this; + } + + private int bitField0_; + + private int id_; + + /** + * optional int32 id = 1; + */ + public int getId() { + return id_; + } + + /** + * optional int32 id = 1; + */ + public Builder setId(int value) { + + id_ = value; + onChanged(); + return this; + } + + /** + * optional int32 id = 1; + */ + public Builder clearId() { + + id_ = 0; + onChanged(); + return this; + } + + private java.lang.Object firstName_ = ""; + + /** + * optional string first_name = 2; + */ + public java.lang.String getFirstName() { + java.lang.Object ref = firstName_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + firstName_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * optional string first_name = 2; + */ + public com.google.protobuf.ByteString getFirstNameBytes() { + java.lang.Object ref = firstName_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + firstName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * optional string first_name = 2; + */ + public Builder setFirstName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + firstName_ = value; + onChanged(); + return this; + } + + /** + * optional string first_name = 2; + */ + public Builder clearFirstName() { + + firstName_ = getDefaultInstance().getFirstName(); + onChanged(); + return this; + } + + /** + * optional string first_name = 2; + */ + public Builder setFirstNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + firstName_ = value; + onChanged(); + return this; + } + + private java.lang.Object lastName_ = ""; + + /** + * optional string last_name = 3; + */ + public java.lang.String getLastName() { + java.lang.Object ref = lastName_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + lastName_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * optional string last_name = 3; + */ + public com.google.protobuf.ByteString getLastNameBytes() { + java.lang.Object ref = lastName_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + lastName_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * optional string last_name = 3; + */ + public Builder setLastName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + lastName_ = value; + onChanged(); + return this; + } + + /** + * optional string last_name = 3; + */ + public Builder clearLastName() { + + lastName_ = getDefaultInstance().getLastName(); + onChanged(); + return this; + } + + /** + * optional string last_name = 3; + */ + public Builder setLastNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + lastName_ = value; + onChanged(); + return this; + } + + private java.lang.Object email_ = ""; + + /** + * optional string email = 4; + */ + public java.lang.String getEmail() { + java.lang.Object ref = email_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + email_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * optional string email = 4; + */ + public com.google.protobuf.ByteString getEmailBytes() { + java.lang.Object ref = email_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + email_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * optional string email = 4; + */ + public Builder setEmail(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + + email_ = value; + onChanged(); + return this; + } + + /** + * optional string email = 4; + */ + public Builder clearEmail() { + + email_ = getDefaultInstance().getEmail(); + onChanged(); + return this; + } + + /** + * optional string email = 4; + */ + public Builder setEmailBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + email_ = value; + onChanged(); + return this; + } + + private java.util.List phone_ = java.util.Collections.emptyList(); + + private void ensurePhoneIsMutable() { + if (!((bitField0_ & 0x00000010) == 0x00000010)) { + phone_ = new java.util.ArrayList(phone_); + bitField0_ |= 0x00000010; + } + } + + private com.google.protobuf.RepeatedFieldBuilder phoneBuilder_; + + /** + * repeated .baeldung.Student.PhoneNumber phone = 5; + */ + public java.util.List getPhoneList() { + if (phoneBuilder_ == null) { + return java.util.Collections.unmodifiableList(phone_); + } else { + return phoneBuilder_.getMessageList(); + } + } + + /** + * repeated .baeldung.Student.PhoneNumber phone = 5; + */ + public int getPhoneCount() { + if (phoneBuilder_ == null) { + return phone_.size(); + } else { + return phoneBuilder_.getCount(); + } + } + + /** + * repeated .baeldung.Student.PhoneNumber phone = 5; + */ + public com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber getPhone(int index) { + if (phoneBuilder_ == null) { + return phone_.get(index); + } else { + return phoneBuilder_.getMessage(index); + } + } + + /** + * repeated .baeldung.Student.PhoneNumber phone = 5; + */ + public Builder setPhone(int index, com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber value) { + if (phoneBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePhoneIsMutable(); + phone_.set(index, value); + onChanged(); + } else { + phoneBuilder_.setMessage(index, value); + } + return this; + } + + /** + * repeated .baeldung.Student.PhoneNumber phone = 5; + */ + public Builder setPhone(int index, com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber.Builder builderForValue) { + if (phoneBuilder_ == null) { + ensurePhoneIsMutable(); + phone_.set(index, builderForValue.build()); + onChanged(); + } else { + phoneBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * repeated .baeldung.Student.PhoneNumber phone = 5; + */ + public Builder addPhone(com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber value) { + if (phoneBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePhoneIsMutable(); + phone_.add(value); + onChanged(); + } else { + phoneBuilder_.addMessage(value); + } + return this; + } + + /** + * repeated .baeldung.Student.PhoneNumber phone = 5; + */ + public Builder addPhone(int index, com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber value) { + if (phoneBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePhoneIsMutable(); + phone_.add(index, value); + onChanged(); + } else { + phoneBuilder_.addMessage(index, value); + } + return this; + } + + /** + * repeated .baeldung.Student.PhoneNumber phone = 5; + */ + public Builder addPhone(com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber.Builder builderForValue) { + if (phoneBuilder_ == null) { + ensurePhoneIsMutable(); + phone_.add(builderForValue.build()); + onChanged(); + } else { + phoneBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * repeated .baeldung.Student.PhoneNumber phone = 5; + */ + public Builder addPhone(int index, com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber.Builder builderForValue) { + if (phoneBuilder_ == null) { + ensurePhoneIsMutable(); + phone_.add(index, builderForValue.build()); + onChanged(); + } else { + phoneBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * repeated .baeldung.Student.PhoneNumber phone = 5; + */ + public Builder addAllPhone(java.lang.Iterable values) { + if (phoneBuilder_ == null) { + ensurePhoneIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, phone_); + onChanged(); + } else { + phoneBuilder_.addAllMessages(values); + } + return this; + } + + /** + * repeated .baeldung.Student.PhoneNumber phone = 5; + */ + public Builder clearPhone() { + if (phoneBuilder_ == null) { + phone_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000010); + onChanged(); + } else { + phoneBuilder_.clear(); + } + return this; + } + + /** + * repeated .baeldung.Student.PhoneNumber phone = 5; + */ + public Builder removePhone(int index) { + if (phoneBuilder_ == null) { + ensurePhoneIsMutable(); + phone_.remove(index); + onChanged(); + } else { + phoneBuilder_.remove(index); + } + return this; + } + + /** + * repeated .baeldung.Student.PhoneNumber phone = 5; + */ + public com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber.Builder getPhoneBuilder(int index) { + return getPhoneFieldBuilder().getBuilder(index); + } + + /** + * repeated .baeldung.Student.PhoneNumber phone = 5; + */ + public com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumberOrBuilder getPhoneOrBuilder(int index) { + if (phoneBuilder_ == null) { + return phone_.get(index); + } else { + return phoneBuilder_.getMessageOrBuilder(index); + } + } + + /** + * repeated .baeldung.Student.PhoneNumber phone = 5; + */ + public java.util.List getPhoneOrBuilderList() { + if (phoneBuilder_ != null) { + return phoneBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(phone_); + } + } + + /** + * repeated .baeldung.Student.PhoneNumber phone = 5; + */ + public com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber.Builder addPhoneBuilder() { + return getPhoneFieldBuilder().addBuilder(com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber.getDefaultInstance()); + } + + /** + * repeated .baeldung.Student.PhoneNumber phone = 5; + */ + public com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber.Builder addPhoneBuilder(int index) { + return getPhoneFieldBuilder().addBuilder(index, com.baeldung.protobuf.BaeldungTraining.Student.PhoneNumber.getDefaultInstance()); + } + + /** + * repeated .baeldung.Student.PhoneNumber phone = 5; + */ + public java.util.List getPhoneBuilderList() { + return getPhoneFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilder getPhoneFieldBuilder() { + if (phoneBuilder_ == null) { + phoneBuilder_ = new com.google.protobuf.RepeatedFieldBuilder( + phone_, ((bitField0_ & 0x00000010) == 0x00000010), getParentForChildren(), isClean()); + phone_ = null; + } + return phoneBuilder_; + } + + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + public final Builder mergeUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return this; + } + + // @@protoc_insertion_point(builder_scope:baeldung.Student) + } + + // @@protoc_insertion_point(class_scope:baeldung.Student) + private static final com.baeldung.protobuf.BaeldungTraining.Student DEFAULT_INSTANCE; + static { + DEFAULT_INSTANCE = new com.baeldung.protobuf.BaeldungTraining.Student(); + } + + public static com.baeldung.protobuf.BaeldungTraining.Student getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = new com.google.protobuf.AbstractParser() { + public Student parsePartialFrom(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + return new Student(input, extensionRegistry); + } }; - com.google.protobuf.Descriptors.FileDescriptor - .internalBuildGeneratedFileFrom(descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] { - }, assigner); - internal_static_baeldung_Course_descriptor = - getDescriptor().getMessageTypes().get(0); - internal_static_baeldung_Course_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_baeldung_Course_descriptor, - new java.lang.String[] { "Id", "CourseName", "Student", }); - internal_static_baeldung_Student_descriptor = - getDescriptor().getMessageTypes().get(1); - internal_static_baeldung_Student_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_baeldung_Student_descriptor, - new java.lang.String[] { "Id", "FirstName", "LastName", "Email", "Phone", }); - internal_static_baeldung_Student_PhoneNumber_descriptor = - internal_static_baeldung_Student_descriptor.getNestedTypes().get(0); - internal_static_baeldung_Student_PhoneNumber_fieldAccessorTable = new - com.google.protobuf.GeneratedMessage.FieldAccessorTable( - internal_static_baeldung_Student_PhoneNumber_descriptor, - new java.lang.String[] { "Number", "Type", }); - } - // @@protoc_insertion_point(outer_class_scope) + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + public com.baeldung.protobuf.BaeldungTraining.Student getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + + } + + private static final com.google.protobuf.Descriptors.Descriptor internal_static_baeldung_Course_descriptor; + private static final com.google.protobuf.GeneratedMessage.FieldAccessorTable internal_static_baeldung_Course_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor internal_static_baeldung_Student_descriptor; + private static final com.google.protobuf.GeneratedMessage.FieldAccessorTable internal_static_baeldung_Student_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor internal_static_baeldung_Student_PhoneNumber_descriptor; + private static final com.google.protobuf.GeneratedMessage.FieldAccessorTable internal_static_baeldung_Student_PhoneNumber_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\030resources/baeldung.proto\022\010baeldung\"M\n\006" + "Course\022\n\n\002id\030\001 \001(\005\022\023\n\013course_name\030\002 \001(\t\022" + + "\"\n\007student\030\003 \003(\0132\021.baeldung.Student\"\352\001\n\007" + "Student\022\n\n\002id\030\001 \001(\005\022\022\n\nfirst_name\030\002 \001(\t\022" + + "\021\n\tlast_name\030\003 \001(\t\022\r\n\005email\030\004 \001(\t\022,\n\005pho" + "ne\030\005 \003(\0132\035.baeldung.Student.PhoneNumber\032" + "H\n\013PhoneNumber\022\016\n\006number\030\001 \001(\t\022)\n\004type\030\002" + + " \001(\0162\033.baeldung.Student.PhoneType\"%\n\tPho" + "neType\022\n\n\006MOBILE\020\000\022\014\n\010LANDLINE\020\001B)\n\025com." + "baeldung.protobufB\020BaeldungTrainingb\006pro", "to3" }; + com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() { + public com.google.protobuf.ExtensionRegistry assignDescriptors(com.google.protobuf.Descriptors.FileDescriptor root) { + descriptor = root; + return null; + } + }; + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom(descriptorData, new com.google.protobuf.Descriptors.FileDescriptor[] {}, assigner); + internal_static_baeldung_Course_descriptor = getDescriptor().getMessageTypes().get(0); + internal_static_baeldung_Course_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable(internal_static_baeldung_Course_descriptor, new java.lang.String[] { "Id", "CourseName", "Student", }); + internal_static_baeldung_Student_descriptor = getDescriptor().getMessageTypes().get(1); + internal_static_baeldung_Student_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable(internal_static_baeldung_Student_descriptor, new java.lang.String[] { "Id", "FirstName", "LastName", "Email", "Phone", }); + internal_static_baeldung_Student_PhoneNumber_descriptor = internal_static_baeldung_Student_descriptor.getNestedTypes().get(0); + internal_static_baeldung_Student_PhoneNumber_fieldAccessorTable = new com.google.protobuf.GeneratedMessage.FieldAccessorTable(internal_static_baeldung_Student_PhoneNumber_descriptor, new java.lang.String[] { "Number", "Type", }); + } + + // @@protoc_insertion_point(outer_class_scope) } diff --git a/spring-protobuf/src/main/java/com/baeldung/protobuf/CourseRepository.java b/spring-protobuf/src/main/java/com/baeldung/protobuf/CourseRepository.java index 60f24abf93..cbafd7d224 100644 --- a/spring-protobuf/src/main/java/com/baeldung/protobuf/CourseRepository.java +++ b/spring-protobuf/src/main/java/com/baeldung/protobuf/CourseRepository.java @@ -7,11 +7,11 @@ import java.util.Map; public class CourseRepository { private final Map courses; - - public CourseRepository (Map courses) { + + public CourseRepository(Map courses) { this.courses = courses; } - + public Course getCourse(int id) { return courses.get(id); }