All Downloads are FREE. Search and download functionalities are using the official Maven repository.

datahub.protobuf.model.ProtobufElement Maven / Gradle / Ivy

There is a newer version: 0.14.1
Show newest version
package datahub.protobuf.model;

import com.google.protobuf.DescriptorProtos.DescriptorProto;
import com.google.protobuf.DescriptorProtos.FileDescriptorProto;
import com.google.protobuf.DescriptorProtos.SourceCodeInfo;
import datahub.protobuf.visitors.ProtobufModelVisitor;
import datahub.protobuf.visitors.VisitContext;

import java.util.List;
import java.util.stream.Stream;


public interface ProtobufElement {
    String name();
    String fullName();
    String nativeType();
    String comment();
    String fieldPathType();

    FileDescriptorProto fileProto();
    DescriptorProto messageProto();

    default Stream messageLocations() {
        List fileLocations = fileProto().getSourceCodeInfo().getLocationList();
        return fileLocations.stream()
                .filter(loc -> loc.getPathCount() > 1
                        && loc.getPath(0) == FileDescriptorProto.MESSAGE_TYPE_FIELD_NUMBER
                        && messageProto() == fileProto().getMessageType(loc.getPath(1)));
    }

     Stream accept(ProtobufModelVisitor v, VisitContext context);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy