private boolean getMetadata( String[] propertyPath, BiFunction<IndexingMetadata, Integer, Boolean> metadataFun) { Descriptor md = messageDescriptor; int i = 0; for (String p : propertyPath) { i++; FieldDescriptor field = md.findFieldByName(p); if (field == null) { break; } IndexingMetadata indexingMetadata = md.getProcessedAnnotation(IndexingMetadata.INDEXED_ANNOTATION); boolean res = indexingMetadata == null || metadataFun.apply(indexingMetadata, field.getNumber()); if (!res) { break; } if (field.getJavaType() == JavaType.MESSAGE) { md = field.getMessageType(); } else { return i == propertyPath.length; } } return false; }
private FieldDescriptor getFieldDescriptor(Descriptor messageDescriptor, String attributePath) { FieldDescriptor fd = null; String[] split = attributePath.split("[.]"); for (int i = 0; i < split.length; i++) { String name = split[i]; fd = messageDescriptor.findFieldByName(name); if (fd == null) { throw log.unknownField(name, messageDescriptor.getFullName()); } IndexingMetadata indexingMetadata = messageDescriptor.getProcessedAnnotation(IndexingMetadata.INDEXED_ANNOTATION); if (indexingMetadata != null && !indexingMetadata.isFieldIndexed(fd.getNumber())) { throw log.fieldIsNotIndexed(name, messageDescriptor.getFullName()); } if (i < split.length - 1) { messageDescriptor = fd.getMessageType(); } } return fd; }
private FieldDescriptor getFieldDescriptor(Descriptor messageDescriptor, String attributePath) { FieldDescriptor fd = null; String[] split = attributePath.split("[.]"); for (int i = 0; i < split.length; i++) { String name = split[i]; fd = messageDescriptor.findFieldByName(name); if (fd == null) { throw new IllegalArgumentException( "Unknown field " + name + " in type " + messageDescriptor.getFullName()); } IndexingMetadata indexingMetadata = messageDescriptor.getProcessedAnnotation(IndexingMetadata.INDEXED_ANNOTATION); if (indexingMetadata != null && !indexingMetadata.isFieldIndexed(fd.getNumber())) { throw new IllegalArgumentException( "Field " + name + " from type " + messageDescriptor.getFullName() + " is not indexed"); } if (i < split.length - 1) { messageDescriptor = fd.getMessageType(); } } return fd; }