Skip to content

Commit

Permalink
Update verification methods' names.
Browse files Browse the repository at this point in the history
  • Loading branch information
xfxyjwf committed Oct 3, 2014
1 parent 345d49a commit 725326f
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions java/src/main/java/com/google/protobuf/DynamicMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ public Builder setField(FieldDescriptor field, Object value) {
// because of some internal features we support. Should figure it out
// and move this check to a more appropriate place.
if (field.getType() == FieldDescriptor.Type.ENUM) {
verifyEnumValue(field, value);
ensureEnumValueDescriptor(field, value);
}
OneofDescriptor oneofDescriptor = field.getContainingOneof();
if (oneofDescriptor != null) {
Expand Down Expand Up @@ -578,8 +578,9 @@ private void verifyOneofContainingType(OneofDescriptor oneof) {
}
}

/** Verifies that the value is EnumValueDescriptor and matchs Enum Type. */
private void verifySingleEnumValue(FieldDescriptor field, Object value) {
/** Verifies that the value is EnumValueDescriptor and matches Enum Type. */
private void ensureSingularEnumValueDescriptor(
FieldDescriptor field, Object value) {
if (value == null) {
throw new NullPointerException();
}
Expand All @@ -594,13 +595,14 @@ private void verifySingleEnumValue(FieldDescriptor field, Object value) {
}

/** Verifies the value for an enum field. */
private void verifyEnumValue(FieldDescriptor field, Object value) {
private void ensureEnumValueDescriptor(
FieldDescriptor field, Object value) {
if (field.isRepeated()) {
for (Object item : (List) value) {
verifySingleEnumValue(field, item);
ensureSingularEnumValueDescriptor(field, item);
}
} else {
verifySingleEnumValue(field, value);
ensureSingularEnumValueDescriptor(field, value);
}
}

Expand Down

0 comments on commit 725326f

Please sign in to comment.