Interface Property<V>
- All Known Subinterfaces:
VertexProperty<V>
public interface Property<V>
A
Property denotes a key/value pair associated with an Edge. A property is much like a Java8
Optional in that a property can be not present (i.e. empty). The key of a property is always a
String and the value of a property is an arbitrary Java object. Each underlying graph engine will typically have
constraints on what Java objects are allowed to be used as values.- Author:
- Marko A. Rodriguez (http://markorodriguez.com), Stephen Mallette (http://stephen.genoprime.com)
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classCommon exceptions to use with a property. -
Method Summary
Modifier and TypeMethodDescriptionelement()Get the element that this property is associated with.static <V> Property<V>empty()Create an empty property that is not present.default voidIf the property is present, the consume the value as specified by theConsumer.booleanWhether the property is empty or not.key()The key of the property.default VIf the value is present, return the value, else return the provided value.default VIf the value is present, return the value, else generate a value given theSupplier.orElseThrow(Supplier<? extends E> exceptionSupplier) If the value is present, return the value, else throw the exception generated by theSupplier.voidremove()Remove the property from the associated element.value()The value of the property.
-
Method Details
-
key
String key()The key of the property.- Returns:
- The property key
-
value
The value of the property.- Returns:
- The property value
- Throws:
NoSuchElementException- thrown if the property is empty
-
isPresent
boolean isPresent()Whether the property is empty or not.- Returns:
- True if the property exists, else false
-
ifPresent
If the property is present, the consume the value as specified by theConsumer.- Parameters:
consumer- The consumer to process the existing value.
-
orElse
If the value is present, return the value, else return the provided value.- Parameters:
otherValue- The value to return if the property is not present- Returns:
- A value
-
orElseGet
If the value is present, return the value, else generate a value given theSupplier.- Parameters:
valueSupplier- The supplier to use to generate a value if the property is not present- Returns:
- A value
-
orElseThrow
If the value is present, return the value, else throw the exception generated by theSupplier.- Type Parameters:
E- The exception type- Parameters:
exceptionSupplier- The supplier to generate an exception if the property is not present- Returns:
- A value
- Throws:
E- if the property is not present, the exception is thrown
-
element
Element element()Get the element that this property is associated with.- Returns:
- The element associated with this property (i.e.
Vertex,Edge, orVertexProperty).
-
remove
void remove()Remove the property from the associated element. -
empty
Create an empty property that is not present.- Type Parameters:
V- The value class of the empty property- Returns:
- A property that is not present
-