Search in sources :

Example 1 with GenericDescriptor

use of com.spotify.protoman.descriptor.GenericDescriptor in project protoman by spotify.

the class SchemaRegistryService method validationViolationToProto.

private static com.spotify.protoman.ValidationViolation validationViolationToProto(final ValidationViolation violation) {
    final com.spotify.protoman.ValidationViolation.Builder violationBuilder = com.spotify.protoman.ValidationViolation.newBuilder().setDescription(violation.description());
    @Nullable final GenericDescriptor currentDescriptor = violation.current();
    if (currentDescriptor != null) {
        currentDescriptor.sourceCodeInfo().ifPresent(sourceCodeInfo -> violationBuilder.setCurrent(sourceCodeInfoToFilePositionProto(sourceCodeInfo)));
    }
    @Nullable final GenericDescriptor candidateDescriptor = violation.candidate();
    if (candidateDescriptor != null) {
        candidateDescriptor.sourceCodeInfo().ifPresent(sourceCodeInfo -> violationBuilder.setCandidate(sourceCodeInfoToFilePositionProto(sourceCodeInfo)));
    }
    return violationBuilder.build();
}
Also used : ValidationViolation(com.spotify.protoman.validation.ValidationViolation) GenericDescriptor(com.spotify.protoman.descriptor.GenericDescriptor) Nullable(javax.annotation.Nullable)

Aggregations

GenericDescriptor (com.spotify.protoman.descriptor.GenericDescriptor)1 ValidationViolation (com.spotify.protoman.validation.ValidationViolation)1 Nullable (javax.annotation.Nullable)1