use of com.google.protobuf.Descriptors.FieldDescriptor in project j2objc by google.
the class PerformanceBenchmarks method testGetPrimitiveFieldsWithDescriptors.
private static void testGetPrimitiveFieldsWithDescriptors() {
TypicalData.Builder builder = TypicalData.newBuilder();
setAllPrimitiveFields(builder);
TypicalData data = builder.build();
List<FieldDescriptor> fields = getPrimitiveFieldDescriptors();
for (int i = 0; i < 10000; i++) {
for (FieldDescriptor field : fields) {
data.getField(field);
}
}
}
use of com.google.protobuf.Descriptors.FieldDescriptor in project j2objc by google.
the class PerformanceBenchmarks method getRepeatedFieldDescriptors.
private static List<FieldDescriptor> getRepeatedFieldDescriptors() {
Descriptor descriptor = TypicalData.Builder.getDescriptor();
List<FieldDescriptor> fields = new ArrayList<FieldDescriptor>();
fields.add(descriptor.findFieldByNumber(4));
fields.add(descriptor.findFieldByNumber(19));
fields.add(descriptor.findFieldByNumber(20));
fields.add(descriptor.findFieldByNumber(21));
fields.add(descriptor.findFieldByNumber(5));
fields.add(descriptor.findFieldByNumber(6));
fields.add(descriptor.findFieldByNumber(7));
fields.add(descriptor.findFieldByNumber(8));
fields.add(descriptor.findFieldByNumber(9));
fields.add(descriptor.findFieldByNumber(10));
return fields;
}
use of com.google.protobuf.Descriptors.FieldDescriptor in project j2objc by google.
the class PerformanceBenchmarks method getPrimitiveFieldDescriptors.
private static List<FieldDescriptor> getPrimitiveFieldDescriptors() {
Descriptor descriptor = TypicalData.Builder.getDescriptor();
List<FieldDescriptor> fields = new ArrayList<FieldDescriptor>();
fields.add(descriptor.findFieldByNumber(1));
fields.add(descriptor.findFieldByNumber(12));
fields.add(descriptor.findFieldByNumber(13));
fields.add(descriptor.findFieldByNumber(14));
fields.add(descriptor.findFieldByNumber(16));
fields.add(descriptor.findFieldByNumber(17));
fields.add(descriptor.findFieldByNumber(18));
return fields;
}
use of com.google.protobuf.Descriptors.FieldDescriptor in project core-java by SpineEventEngine.
the class ReferenceValidatorShould method store_valid_map_of_enrichment_fields_after_validation.
@Test
public void store_valid_map_of_enrichment_fields_after_validation() {
final ReferenceValidator validator = new ReferenceValidator(eventEnricher, UserDeletedEvent.class, EnrichmentBoundWithMultipleFieldsWithDifferentNames.class);
final ValidationResult result = validator.validate();
final Multimap<FieldDescriptor, FieldDescriptor> fieldMap = result.getFieldMap();
assertNotNull(fieldMap);
assertFalse(fieldMap.isEmpty());
assertSize(1, fieldMap);
final Iterator<? extends Map.Entry<?, ? extends Collection<?>>> fieldsIterator = fieldMap.asMap().entrySet().iterator();
assertTrue(fieldsIterator.hasNext());
final Map.Entry<?, ? extends Collection<?>> entry = fieldsIterator.next();
@SuppressWarnings("unchecked") final Map.Entry<FieldDescriptor, Collection<FieldDescriptor>> fieldEntry = (Map.Entry<FieldDescriptor, Collection<FieldDescriptor>>) entry;
final FieldDescriptor eventField = fieldEntry.getKey();
final String eventFieldName = eventField.getName();
assertEquals("deleted_uid", eventFieldName);
final Collection<FieldDescriptor> enrichmentFields = fieldEntry.getValue();
assertFalse(enrichmentFields.isEmpty());
assertSize(1, enrichmentFields);
final Iterator<FieldDescriptor> enrichmentFieldIterator = enrichmentFields.iterator();
assertTrue(enrichmentFieldIterator.hasNext());
final FieldDescriptor enrichmentField = enrichmentFieldIterator.next();
final String enrichmentFieldName = enrichmentField.getName();
assertEquals(USER_GOOGLE_UID_FIELD, enrichmentFieldName);
}
use of com.google.protobuf.Descriptors.FieldDescriptor in project core-java by SpineEventEngine.
the class ReferenceValidatorShould method handle_separator_spaces_in_by_argument.
@Test
public void handle_separator_spaces_in_by_argument() {
final ReferenceValidator validator = new ReferenceValidator(eventEnricher, TaskAdded.class, EnrichmentBoundWithFieldsSeparatedWithSpaces.class);
final ValidationResult result = validator.validate();
final Multimap<FieldDescriptor, FieldDescriptor> fieldMap = result.getFieldMap();
assertFalse(fieldMap.isEmpty());
assertSize(1, fieldMap);
final Iterator<Map.Entry<FieldDescriptor, Collection<FieldDescriptor>>> mapIterator = fieldMap.asMap().entrySet().iterator();
assertTrue(mapIterator.hasNext());
final Map.Entry<FieldDescriptor, Collection<FieldDescriptor>> singleEntry = mapIterator.next();
final FieldDescriptor boundField = singleEntry.getKey();
final String boundFieldName = boundField.getName();
assertEquals("project_id", boundFieldName);
final Collection<FieldDescriptor> targets = singleEntry.getValue();
assertSize(1, targets);
final FieldDescriptor targetField = targets.iterator().next();
final String targetFieldName = targetField.getName();
assertEquals(USER_GOOGLE_UID_FIELD, targetFieldName);
}
Aggregations