Java Code Examples for org.apache.tinkerpop.gremlin.structure.Property#empty()

The following examples show how to use org.apache.tinkerpop.gremlin.structure.Property#empty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Neo4jEdge.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
@Override
public <V> Property<V> property(final String key, final V value) {
    ElementHelper.validateProperty(key, value);
    
    if (null == value) {
        properties(key).forEachRemaining(Property::remove);
        return Property.empty();
    }

    this.graph.tx().readWrite();
    try {
        this.baseElement.setProperty(key, value);
        return new Neo4jProperty<>(this, key, value);
    } catch (final IllegalArgumentException e) {
        throw Property.Exceptions.dataTypeOfPropertyValueNotSupported(value, e);
    }
}
 
Example 2
Source File: TinkerEdge.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
@Override
public <V> Property<V> property(final String key, final V value) {
    if (this.removed) throw elementAlreadyRemoved(Edge.class, id);
    ElementHelper.validateProperty(key, value);

    if (!allowNullPropertyValues && null == value) {
        properties(key).forEachRemaining(Property::remove);
        return Property.empty();
    }

    final Property oldProperty = super.property(key);
    final Property<V> newProperty = new TinkerProperty<>(this, key, value);
    if (null == this.properties) this.properties = new HashMap<>();
    this.properties.put(key, newProperty);
    TinkerHelper.autoUpdateIndex(this, key, value, oldProperty.isPresent() ? oldProperty.value() : null);
    return newProperty;

}
 
Example 3
Source File: FollowedBy.java    From tinkergraph-gremlin with Apache License 2.0 5 votes vote down vote up
@Override
protected <V> Property<V> specificProperty(String key) {
    // note: use the statically defined strings to take advantage of `==` (pointer comparison) over `.equals` (String content comparison) for performance 
    if (WEIGHT.equals(key) && weight != null) {
        return new TinkerProperty(this, key, weight);
    } else {
        return Property.empty();
    }
}
 
Example 4
Source File: Neo4jEdge.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Override
public <V> Property<V> property(final String key) {
    this.graph.tx().readWrite();
    if (this.baseElement.hasProperty(key))
        return new Neo4jProperty<>(this, key, (V) this.baseElement.getProperty(key));
    else
        return Property.empty();
}
 
Example 5
Source File: Neo4JEdge.java    From neo4j-gremlin-bolt with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
@SuppressWarnings("unchecked")
public <V> Property<V> property(String key) {
    Objects.requireNonNull(key, "key cannot be null");
    // property value
    Neo4JEdgeProperty propertyValue = properties.get(key);
    if (propertyValue != null)
        return (Property<V>)propertyValue;
    // empty property
    return Property.empty();
}
 
Example 6
Source File: BitsyElement.java    From bitsy with Apache License 2.0 5 votes vote down vote up
@Override
public <T> Property<T> property(String key) {
    T value = value(key);
    if (value == null) {
        return Property.<T>empty();
    } else {
        return new BitsyProperty<T>(this, key, value);
    }
}
 
Example 7
Source File: SerializerTestEdge.java    From tinkergraph-gremlin with Apache License 2.0 5 votes vote down vote up
@Override
protected <V> Property<V> specificProperty(String key) {
    // note: use the statically defined strings to take advantage of `==` (pointer comparison) over `.equals` (String content comparison) for performance
    if (LONG_PROPERTY.equals(key) && longProperty != null) {
        return new TinkerProperty(this, key, longProperty);
    } else {
        return Property.empty();
    }
}
 
Example 8
Source File: HBaseEdge.java    From hgraphdb with Apache License 2.0 4 votes vote down vote up
@Override
public <V> Property<V> property(final String key) {
    V value = getProperty(key);
    return value != null ? new HBaseProperty<>(graph, this, key, value) : Property.empty();
}
 
Example 9
Source File: KeyedVertexProperty.java    From tinkerpop with Apache License 2.0 4 votes vote down vote up
@Override
public <U> Property<U> property(String key) {
    return Property.<U>empty();
}
 
Example 10
Source File: KeyedVertexProperty.java    From tinkerpop with Apache License 2.0 4 votes vote down vote up
@Override
public <U> Property<U> property(String key, U value) {
    return Property.<U>empty();
}
 
Example 11
Source File: DetachedElement.java    From tinkerpop with Apache License 2.0 4 votes vote down vote up
@Override
public <V> Property<V> property(final String key) {
    return null != this.properties && this.properties.containsKey(key) ? this.properties.get(key).get(0) : Property.empty();
}
 
Example 12
Source File: EmptyVertexProperty.java    From tinkerpop with Apache License 2.0 4 votes vote down vote up
@Override
public <U> Property<U> property(String key) {
    return Property.<U>empty();
}
 
Example 13
Source File: EmptyVertexProperty.java    From tinkerpop with Apache License 2.0 4 votes vote down vote up
@Override
public <U> Property<U> property(String key, U value) {
    return Property.<U>empty();
}
 
Example 14
Source File: SungBy.java    From tinkergraph-gremlin with Apache License 2.0 4 votes vote down vote up
@Override
protected <V> Property<V> specificProperty(String key) {
    return Property.empty();
}
 
Example 15
Source File: TinkerEdge.java    From tinkerpop with Apache License 2.0 4 votes vote down vote up
@Override
public <V> Property<V> property(final String key) {
    return null == this.properties ? Property.<V>empty() : this.properties.getOrDefault(key, Property.<V>empty());
}
 
Example 16
Source File: TinkerVertexProperty.java    From tinkerpop with Apache License 2.0 4 votes vote down vote up
@Override
public <U> Property<U> property(final String key) {
    return null == this.properties ? Property.<U>empty() : this.properties.getOrDefault(key, Property.<U>empty());
}
 
Example 17
Source File: WrittenBy.java    From tinkergraph-gremlin with Apache License 2.0 4 votes vote down vote up
@Override
protected <V> Property<V> specificProperty(String key) {
    return Property.empty();
}
 
Example 18
Source File: TinkerVertexProperty.java    From tinkergraph-gremlin with Apache License 2.0 4 votes vote down vote up
@Override
public <U> Property<U> property(final String key) {
    return null == this.properties ? Property.<U>empty() : this.properties.getOrDefault(key, Property.<U>empty());
}