Adding another enum and field usage just to see what it looks like

This commit is contained in:
Dan Buch
2012-05-07 22:31:40 -04:00
parent af3b05be3d
commit 438aa1db17
5 changed files with 374 additions and 56 deletions

View File

@@ -8,6 +8,81 @@ public final class Addressbook {
public static void registerAllExtensions(
com.google.protobuf.ExtensionRegistry registry) {
}
public enum Gender
implements com.google.protobuf.ProtocolMessageEnum {
NONE(0, 0),
MALE(1, 1),
FEMALE(2, 2),
OTHER(3, 3),
;
public static final int NONE_VALUE = 0;
public static final int MALE_VALUE = 1;
public static final int FEMALE_VALUE = 2;
public static final int OTHER_VALUE = 3;
public final int getNumber() { return value; }
public static Gender valueOf(int value) {
switch (value) {
case 0: return NONE;
case 1: return MALE;
case 2: return FEMALE;
case 3: return OTHER;
default: return null;
}
}
public static com.google.protobuf.Internal.EnumLiteMap<Gender>
internalGetValueMap() {
return internalValueMap;
}
private static com.google.protobuf.Internal.EnumLiteMap<Gender>
internalValueMap =
new com.google.protobuf.Internal.EnumLiteMap<Gender>() {
public Gender findValueByNumber(int number) {
return Gender.valueOf(number);
}
};
public final com.google.protobuf.Descriptors.EnumValueDescriptor
getValueDescriptor() {
return getDescriptor().getValues().get(index);
}
public final com.google.protobuf.Descriptors.EnumDescriptor
getDescriptorForType() {
return getDescriptor();
}
public static final com.google.protobuf.Descriptors.EnumDescriptor
getDescriptor() {
return tutorial.Addressbook.getDescriptor().getEnumTypes().get(0);
}
private static final Gender[] VALUES = {
NONE, MALE, FEMALE, OTHER,
};
public static Gender valueOf(
com.google.protobuf.Descriptors.EnumValueDescriptor desc) {
if (desc.getType() != getDescriptor()) {
throw new java.lang.IllegalArgumentException(
"EnumValueDescriptor is not for this type.");
}
return VALUES[desc.getIndex()];
}
private final int index;
private final int value;
private Gender(int index, int value) {
this.index = index;
this.value = value;
}
// @@protoc_insertion_point(enum_scope:tutorial.Gender)
}
public interface PersonOrBuilder
extends com.google.protobuf.MessageOrBuilder {
@@ -23,7 +98,11 @@ public final class Addressbook {
boolean hasEmail();
String getEmail();
// repeated .tutorial.Person.PhoneNumber phone = 4;
// optional .tutorial.Gender type = 4 [default = NONE];
boolean hasType();
tutorial.Addressbook.Gender getType();
// repeated .tutorial.Person.PhoneNumber phone = 5;
java.util.List<tutorial.Addressbook.Person.PhoneNumber>
getPhoneList();
tutorial.Addressbook.Person.PhoneNumber getPhone(int index);
@@ -657,8 +736,18 @@ public final class Addressbook {
}
}
// repeated .tutorial.Person.PhoneNumber phone = 4;
public static final int PHONE_FIELD_NUMBER = 4;
// optional .tutorial.Gender type = 4 [default = NONE];
public static final int TYPE_FIELD_NUMBER = 4;
private tutorial.Addressbook.Gender type_;
public boolean hasType() {
return ((bitField0_ & 0x00000008) == 0x00000008);
}
public tutorial.Addressbook.Gender getType() {
return type_;
}
// repeated .tutorial.Person.PhoneNumber phone = 5;
public static final int PHONE_FIELD_NUMBER = 5;
private java.util.List<tutorial.Addressbook.Person.PhoneNumber> phone_;
public java.util.List<tutorial.Addressbook.Person.PhoneNumber> getPhoneList() {
return phone_;
@@ -682,6 +771,7 @@ public final class Addressbook {
name_ = "";
id_ = 0;
email_ = "";
type_ = tutorial.Addressbook.Gender.NONE;
phone_ = java.util.Collections.emptyList();
}
private byte memoizedIsInitialized = -1;
@@ -719,8 +809,11 @@ public final class Addressbook {
if (((bitField0_ & 0x00000004) == 0x00000004)) {
output.writeBytes(3, getEmailBytes());
}
if (((bitField0_ & 0x00000008) == 0x00000008)) {
output.writeEnum(4, type_.getNumber());
}
for (int i = 0; i < phone_.size(); i++) {
output.writeMessage(4, phone_.get(i));
output.writeMessage(5, phone_.get(i));
}
getUnknownFields().writeTo(output);
}
@@ -743,9 +836,13 @@ public final class Addressbook {
size += com.google.protobuf.CodedOutputStream
.computeBytesSize(3, getEmailBytes());
}
if (((bitField0_ & 0x00000008) == 0x00000008)) {
size += com.google.protobuf.CodedOutputStream
.computeEnumSize(4, type_.getNumber());
}
for (int i = 0; i < phone_.size(); i++) {
size += com.google.protobuf.CodedOutputStream
.computeMessageSize(4, phone_.get(i));
.computeMessageSize(5, phone_.get(i));
}
size += getUnknownFields().getSerializedSize();
memoizedSerializedSize = size;
@@ -878,9 +975,11 @@ public final class Addressbook {
bitField0_ = (bitField0_ & ~0x00000002);
email_ = "";
bitField0_ = (bitField0_ & ~0x00000004);
type_ = tutorial.Addressbook.Gender.NONE;
bitField0_ = (bitField0_ & ~0x00000008);
if (phoneBuilder_ == null) {
phone_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00000008);
bitField0_ = (bitField0_ & ~0x00000010);
} else {
phoneBuilder_.clear();
}
@@ -934,10 +1033,14 @@ public final class Addressbook {
to_bitField0_ |= 0x00000004;
}
result.email_ = email_;
if (((from_bitField0_ & 0x00000008) == 0x00000008)) {
to_bitField0_ |= 0x00000008;
}
result.type_ = type_;
if (phoneBuilder_ == null) {
if (((bitField0_ & 0x00000008) == 0x00000008)) {
if (((bitField0_ & 0x00000010) == 0x00000010)) {
phone_ = java.util.Collections.unmodifiableList(phone_);
bitField0_ = (bitField0_ & ~0x00000008);
bitField0_ = (bitField0_ & ~0x00000010);
}
result.phone_ = phone_;
} else {
@@ -968,11 +1071,14 @@ public final class Addressbook {
if (other.hasEmail()) {
setEmail(other.getEmail());
}
if (other.hasType()) {
setType(other.getType());
}
if (phoneBuilder_ == null) {
if (!other.phone_.isEmpty()) {
if (phone_.isEmpty()) {
phone_ = other.phone_;
bitField0_ = (bitField0_ & ~0x00000008);
bitField0_ = (bitField0_ & ~0x00000010);
} else {
ensurePhoneIsMutable();
phone_.addAll(other.phone_);
@@ -985,7 +1091,7 @@ public final class Addressbook {
phoneBuilder_.dispose();
phoneBuilder_ = null;
phone_ = other.phone_;
bitField0_ = (bitField0_ & ~0x00000008);
bitField0_ = (bitField0_ & ~0x00000010);
phoneBuilder_ =
com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ?
getPhoneFieldBuilder() : null;
@@ -1054,7 +1160,18 @@ public final class Addressbook {
email_ = input.readBytes();
break;
}
case 34: {
case 32: {
int rawValue = input.readEnum();
tutorial.Addressbook.Gender value = tutorial.Addressbook.Gender.valueOf(rawValue);
if (value == null) {
unknownFields.mergeVarintField(4, rawValue);
} else {
bitField0_ |= 0x00000008;
type_ = value;
}
break;
}
case 42: {
tutorial.Addressbook.Person.PhoneNumber.Builder subBuilder = tutorial.Addressbook.Person.PhoneNumber.newBuilder();
input.readMessage(subBuilder, extensionRegistry);
addPhone(subBuilder.buildPartial());
@@ -1159,13 +1276,37 @@ public final class Addressbook {
onChanged();
}
// repeated .tutorial.Person.PhoneNumber phone = 4;
// optional .tutorial.Gender type = 4 [default = NONE];
private tutorial.Addressbook.Gender type_ = tutorial.Addressbook.Gender.NONE;
public boolean hasType() {
return ((bitField0_ & 0x00000008) == 0x00000008);
}
public tutorial.Addressbook.Gender getType() {
return type_;
}
public Builder setType(tutorial.Addressbook.Gender value) {
if (value == null) {
throw new NullPointerException();
}
bitField0_ |= 0x00000008;
type_ = value;
onChanged();
return this;
}
public Builder clearType() {
bitField0_ = (bitField0_ & ~0x00000008);
type_ = tutorial.Addressbook.Gender.NONE;
onChanged();
return this;
}
// repeated .tutorial.Person.PhoneNumber phone = 5;
private java.util.List<tutorial.Addressbook.Person.PhoneNumber> phone_ =
java.util.Collections.emptyList();
private void ensurePhoneIsMutable() {
if (!((bitField0_ & 0x00000008) == 0x00000008)) {
if (!((bitField0_ & 0x00000010) == 0x00000010)) {
phone_ = new java.util.ArrayList<tutorial.Addressbook.Person.PhoneNumber>(phone_);
bitField0_ |= 0x00000008;
bitField0_ |= 0x00000010;
}
}
@@ -1281,7 +1422,7 @@ public final class Addressbook {
public Builder clearPhone() {
if (phoneBuilder_ == null) {
phone_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00000008);
bitField0_ = (bitField0_ & ~0x00000010);
onChanged();
} else {
phoneBuilder_.clear();
@@ -1337,7 +1478,7 @@ public final class Addressbook {
phoneBuilder_ = new com.google.protobuf.RepeatedFieldBuilder<
tutorial.Addressbook.Person.PhoneNumber, tutorial.Addressbook.Person.PhoneNumber.Builder, tutorial.Addressbook.Person.PhoneNumberOrBuilder>(
phone_,
((bitField0_ & 0x00000008) == 0x00000008),
((bitField0_ & 0x00000010) == 0x00000010),
getParentForChildren(),
isClean());
phone_ = null;
@@ -1943,14 +2084,16 @@ public final class Addressbook {
descriptor;
static {
java.lang.String[] descriptorData = {
"\n\021addressbook.proto\022\010tutorial\"\332\001\n\006Person" +
"\n\021addressbook.proto\022\010tutorial\"\200\002\n\006Person" +
"\022\014\n\004name\030\001 \002(\t\022\n\n\002id\030\002 \002(\005\022\r\n\005email\030\003 \001(" +
"\t\022+\n\005phone\030\004 \003(\0132\034.tutorial.Person.Phone" +
"Number\032M\n\013PhoneNumber\022\016\n\006number\030\001 \002(\t\022.\n" +
"\004type\030\002 \001(\0162\032.tutorial.Person.PhoneType:" +
"\004HOME\"+\n\tPhoneType\022\n\n\006MOBILE\020\000\022\010\n\004HOME\020\001" +
"\022\010\n\004WORK\020\002\"/\n\013AddressBook\022 \n\006person\030\001 \003(" +
"\0132\020.tutorial.Person"
"\t\022$\n\004type\030\004 \001(\0162\020.tutorial.Gender:\004NONE\022" +
"+\n\005phone\030\005 \003(\0132\034.tutorial.Person.PhoneNu" +
"mber\032M\n\013PhoneNumber\022\016\n\006number\030\001 \002(\t\022.\n\004t" +
"ype\030\002 \001(\0162\032.tutorial.Person.PhoneType:\004H" +
"OME\"+\n\tPhoneType\022\n\n\006MOBILE\020\000\022\010\n\004HOME\020\001\022\010" +
"\n\004WORK\020\002\"/\n\013AddressBook\022 \n\006person\030\001 \003(\0132" +
"\020.tutorial.Person*3\n\006Gender\022\010\n\004NONE\020\000\022\010\n" +
"\004MALE\020\001\022\n\n\006FEMALE\020\002\022\t\n\005OTHER\020\003"
};
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
@@ -1962,7 +2105,7 @@ public final class Addressbook {
internal_static_tutorial_Person_fieldAccessorTable = new
com.google.protobuf.GeneratedMessage.FieldAccessorTable(
internal_static_tutorial_Person_descriptor,
new java.lang.String[] { "Name", "Id", "Email", "Phone", },
new java.lang.String[] { "Name", "Id", "Email", "Type", "Phone", },
tutorial.Addressbook.Person.class,
tutorial.Addressbook.Person.Builder.class);
internal_static_tutorial_Person_PhoneNumber_descriptor =