carnival-data / carnival

JVM property graph data unification framework
https://carnival-data.github.io/carnival/
GNU General Public License v3.0
7 stars 2 forks source link

PropertyDefTrait valueOf() return null if property not present #68

Closed augustearth closed 2 years ago

augustearth commented 2 years ago

Original functionality would throw an exception of valueOf was called for a property that was not present. Ex.

when:
def v1 = VX.THING_2.instance().create(graph)

then:
!PX.PROP_A.of(v1).isPresent()
PX.PROP_A.valueOf(v1) == null

The above would throw an exception. In practice, it turns out to be annoying to have to check for the presence of a property before calling valueOf. Almost always, the desired behavior is for valueOf to return null if the property is not present. Furthermore, to get the Property object, which has isPresent() and ifPresent() is easy via the PropertyDefTrait of() method.

valueOf() is a convenience method.