public static Property createProperty(final Attachable<Property> attachableProperty, final Vertex hostVertex) {
            final Property baseProperty = attachableProperty.get();
            final Element baseElement = baseProperty.element();
            if (baseElement instanceof Vertex) {
                return Method.createVertexProperty((Attachable) attachableProperty, hostVertex);
            } else if (baseElement instanceof Edge) {
                final Iterator<Edge> edgeIterator = hostVertex.edges(Direction.OUT);
                if (edgeIterator.hasNext())
                    return edgeIterator.next().property(baseProperty.key(), baseProperty.value());
                throw new IllegalStateException("Could not find edge to create the property on");
            } else { // vertex property
                final Iterator<VertexProperty<Object>> vertexPropertyIterator = hostVertex.properties(((VertexProperty) baseElement).key());
                while (vertexPropertyIterator.hasNext()) {
                    final VertexProperty<Object> vp = vertexPropertyIterator.next();
                    if (ElementHelper.areEqual(vp, baseElement))
                        return vp.property(baseProperty.key(), baseProperty.value());
                }
                throw new IllegalStateException("Could not find vertex property to create the attachable property on");
            }
        }
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