use of com.google.protobuf.Descriptors.Descriptor in project core-java by SpineEventEngine.
the class ReferenceValidator method findSourceFieldByName.
/**
* Searches for the event/context field with the name retrieved from the
* enrichment field {@code by} option.
*
* @param name the name of the searched field
* @param enrichmentField the field of the enrichment targeted onto the searched field
* @param strict if {@code true} the field must be found, an exception is thrown
* otherwise.
* <p>If {@code false} {@code null} will be returned upon an
* unsuccessful search
* @return {@link FieldDescriptor} for the field with the given name or {@code null} if the
* field is absent and if not in the strict mode
*/
private FieldDescriptor findSourceFieldByName(String name, FieldDescriptor enrichmentField, boolean strict) {
checkSourceFieldName(name, enrichmentField);
final Descriptor srcMessage = getSrcMessage(name);
final FieldDescriptor field = findField(name, srcMessage);
if (field == null && strict) {
throw noFieldException(name, srcMessage, enrichmentField);
}
return field;
}
use of com.google.protobuf.Descriptors.Descriptor in project j2objc by google.
the class CompatibilityTest method testExtensionRegistryGetUnmodifiable.
public void testExtensionRegistryGetUnmodifiable() throws Exception {
ExtensionRegistry registry = ExtensionRegistry.newInstance();
ExtensionRegistry registry2 = registry.getUnmodifiable();
registry.add(Typical.myPrimitiveExtension);
// Extension added to registry should be visible in registry2.
Descriptor descriptor = TypicalData.getDescriptor();
ExtensionRegistry.ExtensionInfo extensionInfo = registry2.findExtensionByNumber(descriptor, 1001);
assertNotNull(extensionInfo);
ExtensionRegistryLite registryLite = ExtensionRegistryLite.newInstance();
ExtensionRegistryLite registryLite2 = registryLite.getUnmodifiable();
assertNotNull(registryLite2);
}
use of com.google.protobuf.Descriptors.Descriptor in project j2objc by google.
the class CompatibilityTest method testEnumDescriptor.
public void testEnumDescriptor() throws Exception {
Descriptor descriptor = TypicalData.Builder.getDescriptor();
FieldDescriptor fieldDescriptor = descriptor.findFieldByNumber(3);
assertEquals(Type.ENUM, fieldDescriptor.getType());
EnumDescriptor enumDescriptor = fieldDescriptor.getEnumType();
assertNotNull(enumDescriptor);
EnumValueDescriptor enumValueDescriptor = enumDescriptor.findValueByNumber(1);
assertEquals(1, enumValueDescriptor.getNumber());
assertEquals("VALUE1", enumValueDescriptor.getName());
}
use of com.google.protobuf.Descriptors.Descriptor in project j2objc by google.
the class CompatibilityTest method testClearFieldWithDescriptor.
public void testClearFieldWithDescriptor() throws Exception {
Descriptor descriptor = TypicalData.Builder.getDescriptor();
FieldDescriptor intField = descriptor.findFieldByNumber(1);
FieldDescriptor repeatedIntField = descriptor.findFieldByNumber(4);
TypicalData.Builder dataBuilder = TypicalData.newBuilder().setMyInt(42).addRepeatedInt32(43).addRepeatedInt32(44);
assertEquals(42, dataBuilder.getMyInt());
dataBuilder.clearField(intField);
assertFalse(dataBuilder.hasMyInt());
assertEquals(2, dataBuilder.getRepeatedInt32Count());
dataBuilder.clearField(repeatedIntField);
assertEquals(0, dataBuilder.getRepeatedInt32Count());
}
use of com.google.protobuf.Descriptors.Descriptor in project j2objc by google.
the class CompatibilityTest method testGetMessageType.
public void testGetMessageType() throws Exception {
Descriptor descriptor = TypicalData.Builder.getDescriptor();
FieldDescriptor fieldDescriptor = descriptor.findFieldByNumber(11);
Descriptor messageDescriptor = fieldDescriptor.getMessageType();
assertNotNull(messageDescriptor);
FieldDescriptor messageFieldDescriptor = messageDescriptor.findFieldByNumber(1);
assertEquals(1, messageFieldDescriptor.getNumber());
}
Aggregations