Java Code Examples for com.google.protobuf.Descriptors.OneofDescriptor#getIndex()

The following examples show how to use com.google.protobuf.Descriptors.OneofDescriptor#getIndex() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DynamicMessage.java    From play-store-api with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Builder setField(FieldDescriptor field, Object value) {
  verifyContainingType(field);
  ensureIsMutable();
  // TODO(xiaofeng): This check should really be put in FieldSet.setField()
  // where all other such checks are done. However, currently
  // FieldSet.setField() permits Integer value for enum fields probably
  // 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) {
    ensureEnumValueDescriptor(field, value);
  }
  OneofDescriptor oneofDescriptor = field.getContainingOneof();
  if (oneofDescriptor != null) {
    int index = oneofDescriptor.getIndex();
    FieldDescriptor oldField = oneofCases[index];
    if ((oldField != null) && (oldField != field)) {
      fields.clearField(oldField);
    }
    oneofCases[index] = field;
  }
  fields.setField(field, value);
  return this;
}
 
Example 2
Source File: DynamicMessage.java    From 365browser with Apache License 2.0 6 votes vote down vote up
public Builder setField(FieldDescriptor field, Object value) {
  verifyContainingType(field);
  ensureIsMutable();
  // TODO(xiaofeng): This check should really be put in FieldSet.setField()
  // where all other such checks are done. However, currently
  // FieldSet.setField() permits Integer value for enum fields probably
  // 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) {
    ensureEnumValueDescriptor(field, value);
  }
  OneofDescriptor oneofDescriptor = field.getContainingOneof();
  if (oneofDescriptor != null) {
    int index = oneofDescriptor.getIndex();
    FieldDescriptor oldField = oneofCases[index];
    if ((oldField != null) && (oldField != field)) {
      fields.clearField(oldField);
    }
    oneofCases[index] = field;
  }
  fields.setField(field, value);
  return this;
}
 
Example 3
Source File: DynamicMessage.java    From play-store-api with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean hasOneof(OneofDescriptor oneof) {
  verifyOneofContainingType(oneof);
  FieldDescriptor field = oneofCases[oneof.getIndex()];
  if (field == null) {
    return false;
  }
  return true;
}
 
Example 4
Source File: DynamicMessage.java    From play-store-api with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean hasOneof(OneofDescriptor oneof) {
  verifyOneofContainingType(oneof);
  FieldDescriptor field = oneofCases[oneof.getIndex()];
  if (field == null) {
    return false;
  }
  return true;
}
 
Example 5
Source File: DynamicMessage.java    From play-store-api with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Builder clearOneof(OneofDescriptor oneof) {
  verifyOneofContainingType(oneof);
  FieldDescriptor field = oneofCases[oneof.getIndex()];
  if (field != null) {
    clearField(field);
  }
  return this;
}
 
Example 6
Source File: DynamicMessage.java    From play-store-api with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Builder clearField(FieldDescriptor field) {
  verifyContainingType(field);
  ensureIsMutable();
  OneofDescriptor oneofDescriptor = field.getContainingOneof();
  if (oneofDescriptor != null) {
    int index = oneofDescriptor.getIndex();
    if (oneofCases[index] == field) {
      oneofCases[index] = null;
    }
  }
  fields.clearField(field);
  return this;
}
 
Example 7
Source File: GeneratedMessage.java    From play-store-api with GNU General Public License v3.0 5 votes vote down vote up
/** Get the OneofAccessor for a particular oneof. */
private OneofAccessor getOneof(final OneofDescriptor oneof) {
  if (oneof.getContainingType() != descriptor) {
    throw new IllegalArgumentException(
      "OneofDescriptor does not match message type.");
  }
  return oneofs[oneof.getIndex()];
}
 
Example 8
Source File: DynamicMessage.java    From 365browser with Apache License 2.0 5 votes vote down vote up
public boolean hasOneof(OneofDescriptor oneof) {
  verifyOneofContainingType(oneof);
  FieldDescriptor field = oneofCases[oneof.getIndex()];
  if (field == null) {
    return false;
  }
  return true;
}
 
Example 9
Source File: DynamicMessage.java    From 365browser with Apache License 2.0 5 votes vote down vote up
public boolean hasOneof(OneofDescriptor oneof) {
  verifyOneofContainingType(oneof);
  FieldDescriptor field = oneofCases[oneof.getIndex()];
  if (field == null) {
    return false;
  }
  return true;
}
 
Example 10
Source File: DynamicMessage.java    From 365browser with Apache License 2.0 5 votes vote down vote up
public Builder clearOneof(OneofDescriptor oneof) {
  verifyOneofContainingType(oneof);
  FieldDescriptor field = oneofCases[oneof.getIndex()];
  if (field != null) {
    clearField(field);
  }
  return this;
}
 
Example 11
Source File: DynamicMessage.java    From 365browser with Apache License 2.0 5 votes vote down vote up
public Builder clearField(FieldDescriptor field) {
  verifyContainingType(field);
  ensureIsMutable();
  OneofDescriptor oneofDescriptor = field.getContainingOneof();
  if (oneofDescriptor != null) {
    int index = oneofDescriptor.getIndex();
    if (oneofCases[index] == field) {
      oneofCases[index] = null;
    }
  }
  fields.clearField(field);
  return this;
}
 
Example 12
Source File: GeneratedMessage.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/** Get the OneofAccessor for a particular oneof. */
private OneofAccessor getOneof(final OneofDescriptor oneof) {
  if (oneof.getContainingType() != descriptor) {
    throw new IllegalArgumentException(
      "OneofDescriptor does not match message type.");
  }
  return oneofs[oneof.getIndex()];
}
 
Example 13
Source File: DynamicMessage.java    From play-store-api with GNU General Public License v3.0 4 votes vote down vote up
@Override
public FieldDescriptor getOneofFieldDescriptor(OneofDescriptor oneof) {
  verifyOneofContainingType(oneof);
  return oneofCases[oneof.getIndex()];
}
 
Example 14
Source File: DynamicMessage.java    From play-store-api with GNU General Public License v3.0 4 votes vote down vote up
@Override
public FieldDescriptor getOneofFieldDescriptor(OneofDescriptor oneof) {
  verifyOneofContainingType(oneof);
  return oneofCases[oneof.getIndex()];
}
 
Example 15
Source File: DynamicMessage.java    From 365browser with Apache License 2.0 4 votes vote down vote up
public FieldDescriptor getOneofFieldDescriptor(OneofDescriptor oneof) {
  verifyOneofContainingType(oneof);
  return oneofCases[oneof.getIndex()];
}
 
Example 16
Source File: DynamicMessage.java    From 365browser with Apache License 2.0 4 votes vote down vote up
public FieldDescriptor getOneofFieldDescriptor(OneofDescriptor oneof) {
  verifyOneofContainingType(oneof);
  return oneofCases[oneof.getIndex()];
}