@Override public <V> VertexProperty<V> property(final String key) { if (null != this.properties && this.properties.containsKey(key)) { final List<VertexProperty> list = (List) this.properties.get(key); if (list.size() > 1) throw Vertex.Exceptions.multiplePropertiesExistForProvidedKey(key); else return list.get(0); } else return VertexProperty.<V>empty(); }
/** * Get the {@link VertexProperty} for the provided key. If the property does not exist, return * {@link VertexProperty#empty}. If there are more than one vertex properties for the provided * key, then throw {@link Vertex.Exceptions#multiplePropertiesExistForProvidedKey}. * * @param key the key of the vertex property to get * @param <V> the expected type of the vertex property value * @return the retrieved vertex property */ @Override public default <V> VertexProperty<V> property(final String key) { final Iterator<VertexProperty<V>> iterator = this.properties(key); if (iterator.hasNext()) { final VertexProperty<V> property = iterator.next(); if (iterator.hasNext()) throw Vertex.Exceptions.multiplePropertiesExistForProvidedKey(key); else return property; } else { return VertexProperty.<V>empty(); } }
@Override public <V> VertexProperty<V> property(final String key) { if (this.removed) return VertexProperty.empty(); if (TinkerHelper.inComputerMode(this.graph)) { final List<VertexProperty> list = (List) this.graph.graphComputerView.getProperty(this, key); if (list.size() == 0) return VertexProperty.<V>empty(); else if (list.size() == 1) return list.get(0); else throw Vertex.Exceptions.multiplePropertiesExistForProvidedKey(key); } else { if (this.properties != null && this.properties.containsKey(key)) { final List<VertexProperty> list = (List) this.properties.get(key); if (list.size() > 1) throw Vertex.Exceptions.multiplePropertiesExistForProvidedKey(key); else return list.get(0); } else return VertexProperty.<V>empty(); } }
fail("This should throw a: " + Vertex.Exceptions.multiplePropertiesExistForProvidedKey("name")); } catch (final Exception e) { validateException(Vertex.Exceptions.multiplePropertiesExistForProvidedKey("name"), e);
@Override public <V> VertexProperty<V> property(final String key) { if (this.removed) return VertexProperty.empty(); if (TinkerHelper.inComputerMode(this.graph)) { final List<VertexProperty> list = (List) this.graph.graphComputerView.getProperty(this, key); if (list.size() == 0) return VertexProperty.<V>empty(); else if (list.size() == 1) return list.get(0); else throw Vertex.Exceptions.multiplePropertiesExistForProvidedKey(key); } else { if (this.properties != null && this.properties.containsKey(key)) { final List<VertexProperty> list = (List) this.properties.get(key); if (list.size() > 1) throw Vertex.Exceptions.multiplePropertiesExistForProvidedKey(key); else return list.get(0); } else return VertexProperty.<V>empty(); } }
@Override public <V> VertexProperty<V> property(final String key) { if (this.removed) return VertexProperty.empty(); if (TinkerHelper.inComputerMode(this.graph)) { final List<VertexProperty> list = (List) this.graph.graphComputerView.getProperty(this, key); if (list.size() == 0) return VertexProperty.<V>empty(); else if (list.size() == 1) return list.get(0); else throw Vertex.Exceptions.multiplePropertiesExistForProvidedKey(key); } else { if (this.properties != null && this.properties.containsKey(key)) { final List<VertexProperty> list = (List) this.properties.get(key); if (list.size() > 1) throw Vertex.Exceptions.multiplePropertiesExistForProvidedKey(key); else return list.get(0); } else return VertexProperty.<V>empty(); } }
/** * Get the {@link VertexProperty} for the provided key. If the property does not exist, return * {@link VertexProperty#empty}. If there are more than one vertex properties for the provided * key, then throw {@link Vertex.Exceptions#multiplePropertiesExistForProvidedKey}. * * @param key the key of the vertex property to get * @param <V> the expected type of the vertex property value * @return the retrieved vertex property */ @Override public default <V> VertexProperty<V> property(final String key) { final Iterator<VertexProperty<V>> iterator = this.properties(key); if (iterator.hasNext()) { final VertexProperty<V> property = iterator.next(); if (iterator.hasNext()) throw Vertex.Exceptions.multiplePropertiesExistForProvidedKey(key); else return property; } else { return VertexProperty.<V>empty(); } }
@Override public <V> VertexProperty<V> getVertexProperty(final Neo4jVertex vertex, final String key) { final Neo4jNode node = vertex.getBaseVertex(); if (node.hasProperty(key)) { if (node.getProperty(key).equals(VERTEX_PROPERTY_TOKEN)) { if (node.degree(Neo4jDirection.OUTGOING, Graph.Hidden.hide(key)) > 1) throw Vertex.Exceptions.multiplePropertiesExistForProvidedKey(key); else { return (VertexProperty<V>) new Neo4jVertexProperty<>(vertex, node.relationships(Neo4jDirection.OUTGOING, Graph.Hidden.hide(key)).iterator().next().end()); } } else { return new Neo4jVertexProperty<>(vertex, key, (V) node.getProperty(key)); } } else return VertexProperty.<V>empty(); }
@Override public <V> VertexProperty<V> property(final String key) { if (null != this.properties && this.properties.containsKey(key)) { final List<VertexProperty> list = (List) this.properties.get(key); if (list.size() > 1) throw Vertex.Exceptions.multiplePropertiesExistForProvidedKey(key); else return list.get(0); } else return VertexProperty.<V>empty(); }
fail("This should throw a: " + Vertex.Exceptions.multiplePropertiesExistForProvidedKey("name")); } catch (final Exception e) { validateException(Vertex.Exceptions.multiplePropertiesExistForProvidedKey("name"), e);
@Override public <V> VertexProperty<V> getVertexProperty(final Neo4jVertex vertex, final String key) { final Neo4jNode node = vertex.getBaseVertex(); if (node.hasProperty(key)) { if (node.getProperty(key).equals(VERTEX_PROPERTY_TOKEN)) { if (node.degree(Neo4jDirection.OUTGOING, Graph.Hidden.hide(key)) > 1) throw Vertex.Exceptions.multiplePropertiesExistForProvidedKey(key); else { return (VertexProperty<V>) new Neo4jVertexProperty<>(vertex, node.relationships(Neo4jDirection.OUTGOING, Graph.Hidden.hide(key)).iterator().next().end()); } } else { return new Neo4jVertexProperty<>(vertex, key, (V) node.getProperty(key)); } } else return VertexProperty.<V>empty(); }