public static <V> Function<Attachable<V>, V> get(final Host hostVertexOrGraph) {
            return hostVertexOrGraph instanceof EmptyGraph ? Attachable::get : (Attachable<V> attachable) -> {
                final Object base = attachable.get();
                if (base instanceof Vertex) {
                    final Optional<Vertex> optional = hostVertexOrGraph instanceof Graph ?
                            Method.getVertex((Attachable<Vertex>) attachable, (Graph) hostVertexOrGraph) :
                            Method.getVertex((Attachable<Vertex>) attachable, (Vertex) hostVertexOrGraph);
                    return (V) optional.orElseThrow(() -> hostVertexOrGraph instanceof Graph ?
                            Attachable.Exceptions.canNotGetAttachableFromHostGraph(attachable, (Graph) hostVertexOrGraph) :
                            Attachable.Exceptions.canNotGetAttachableFromHostVertex(attachable, (Vertex) hostVertexOrGraph));
                } else if (base instanceof Edge) {
                    final Optional<Edge> optional = hostVertexOrGraph instanceof Graph ?
                            Method.getEdge((Attachable<Edge>) attachable, (Graph) hostVertexOrGraph) :
                            Method.getEdge((Attachable<Edge>) attachable, (Vertex) hostVertexOrGraph);
                    return (V) optional.orElseThrow(() -> hostVertexOrGraph instanceof Graph ?
                            Attachable.Exceptions.canNotGetAttachableFromHostGraph(attachable, (Graph) hostVertexOrGraph) :
                            Attachable.Exceptions.canNotGetAttachableFromHostVertex(attachable, (Vertex) hostVertexOrGraph));
                } else if (base instanceof VertexProperty) {
                    final Optional<VertexProperty> optional = hostVertexOrGraph instanceof Graph ?
                            Method.getVertexProperty((Attachable<VertexProperty>) attachable, (Graph) hostVertexOrGraph) :
                            Method.getVertexProperty((Attachable<VertexProperty>) attachable, (Vertex) hostVertexOrGraph);
                    return (V) optional.orElseThrow(() -> hostVertexOrGraph instanceof Graph ?
                            Attachable.Exceptions.canNotGetAttachableFromHostGraph(attachable, (Graph) hostVertexOrGraph) :
                            Attachable.Exceptions.canNotGetAttachableFromHostVertex(attachable, (Vertex) hostVertexOrGraph));
                } else if (base instanceof Property) {
                    final Optional<Property> optional = hostVertexOrGraph instanceof Graph ?
                            Method.getProperty((Attachable<Property>) attachable, (Graph) hostVertexOrGraph) :
                            Method.getProperty((Attachable<Property>) attachable, (Vertex) hostVertexOrGraph);
                    return (V) optional.orElseThrow(() -> hostVertexOrGraph instanceof Graph ?
                            Attachable.Exceptions.canNotGetAttachableFromHostGraph(attachable, (Graph) hostVertexOrGraph) :
                            Attachable.Exceptions.canNotGetAttachableFromHostVertex(attachable, (Vertex) hostVertexOrGraph));
                } else
                    throw Attachable.Exceptions.providedAttachableMustContainAGraphObject(attachable);
            };
        }
A collection of general methods of attachment. Note that more efficient methods of attachment might exist
if the user knows the source data being attached and the features of the graph that the data is being
attached to.
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/Attachable.java