private GremlinSource createGremlinSource()

in src/main/java/com/microsoft/spring/data/gremlin/repository/support/GremlinEntityInformation.java [40:65]


    private GremlinSource<T> createGremlinSource(@NonNull Class<T> domainClass, @NonNull Field idField) {
        final String label;
        final String domainClassName = domainClass.getSimpleName();
        final Vertex vertex = domainClass.getAnnotation(Vertex.class);
        final Edge edge = domainClass.getAnnotation(Edge.class);
        final Graph graph = domainClass.getAnnotation(Graph.class);
        final GremlinSource<T> source;

        if (vertex != null && edge == null && graph == null) {
            source = new GremlinSourceVertex<>(domainClass);
            label = vertex.label().isEmpty() ? domainClassName : vertex.label();
        } else if (edge != null && vertex == null && graph == null) {
            source = new GremlinSourceEdge<>(domainClass);
            label = edge.label().isEmpty() ? domainClassName : edge.label();
        } else if (graph != null && vertex == null && edge == null) {
            source = new GremlinSourceGraph<>(domainClass);
            label = "";
        } else {
            throw new GremlinUnexpectedEntityTypeException("Unexpected gremlin entity type");
        }

        source.setLabel(label);
        source.setIdField(idField);

        return source;
    }