org.apache.tinkerpop.gremlin.structure.Element.property()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(9.0k)|赞(0)|评价(0)|浏览(108)

本文整理了Java中org.apache.tinkerpop.gremlin.structure.Element.property()方法的一些代码示例,展示了Element.property()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.property()方法的具体详情如下:
包路径:org.apache.tinkerpop.gremlin.structure.Element
类名称:Element
方法名:property

Element.property介绍

[英]Get a Property for the Element given its key. The default implementation calls the raw Element#properties.
[中]获取给定元素键的元素的属性。默认实现调用原始元素#属性。

代码示例

代码示例来源:origin: apache/tinkerpop

@Override
public <V> Property<V> property(final String key) {
  return this.baseElement.property(key);
}

代码示例来源:origin: apache/tinkerpop

@Override
public <V> Property<V> property(final String key) {
  return new ComputerProperty<>(this.element.property(key));
}

代码示例来源:origin: apache/tinkerpop

/**
 * Assign key/value pairs as properties to an {@link org.apache.tinkerpop.gremlin.structure.Element}.  If the value of {@link T#id} or
 * {@link T#label} is in the set of pairs, then they are ignored.
 *
 * @param element           the graph element to assign the {@code propertyKeyValues}
 * @param propertyKeyValues the key/value pairs to assign to the {@code element}
 * @throws ClassCastException       if the value of the key is not a {@link String}
 * @throws IllegalArgumentException if the value of {@code element} is null
 */
public static void attachProperties(final Element element, final Object... propertyKeyValues) {
  if (null == element)
    throw Graph.Exceptions.argumentCanNotBeNull("element");
  for (int i = 0; i < propertyKeyValues.length; i = i + 2) {
    if (!propertyKeyValues[i].equals(T.id) && !propertyKeyValues[i].equals(T.label))
      element.property((String) propertyKeyValues[i], propertyKeyValues[i + 1]);
  }
}

代码示例来源:origin: apache/tinkerpop

public void createKeyIndex(final String key) {
  if (null == key)
    throw Graph.Exceptions.argumentCanNotBeNull("key");
  if (key.isEmpty())
    throw new IllegalArgumentException("The key for the index cannot be an empty string");
  if (this.indexedKeys.contains(key))
    return;
  this.indexedKeys.add(key);
  (Vertex.class.isAssignableFrom(this.indexClass) ?
      this.graph.vertices.values().<T>parallelStream() :
      this.graph.edges.values().<T>parallelStream())
      .map(e -> new Object[]{((T) e).property(key), e})
      .filter(a -> ((Property) a[0]).isPresent())
      .forEach(a -> this.put(key, ((Property) a[0]).value(), (T) a[1]));
}

代码示例来源:origin: apache/tinkerpop

/**
 * Get the value of a {@link Property} given it's key.
 * The default implementation calls {@link Element#property} and then returns the associated value.
 *
 * @throws NoSuchElementException if the property does not exist on the {@code Element}.
 */
public default <V> V value(final String key) throws NoSuchElementException {
  return this.<V>property(key).orElseThrow(() -> Property.Exceptions.propertyDoesNotExist(this,key));
}

代码示例来源:origin: apache/tinkerpop

@Override
public <V> Property<V> property(final String key, final V value) {
  if (state.equals(State.MAP_REDUCE))
    throw GraphComputer.Exceptions.vertexPropertiesCanNotBeUpdatedInMapReduce();
  return new ComputerProperty<>(this.element.property(key, value));
}

代码示例来源:origin: apache/tinkerpop

public final boolean test(final Element element) {
  // it is OK to evaluate equality of ids via toString(), given that the test suite enforces the value of
  // id().toString() to be a first class representation of the identifier. a string test is only executed
  // if the predicate value is a String.  this allows stuff like: g.V().has(id,lt(10)) to work properly
  if (this.key.equals(T.id.getAccessor()))
    return testingIdString ? testIdAsString(element) : testId(element);
  else if (this.key.equals(T.label.getAccessor()))
    return testLabel(element);
  else if (element instanceof VertexProperty && this.key.equals(T.value.getAccessor()))
    return testValue((VertexProperty) element);
  else if (element instanceof VertexProperty && this.key.equals(T.key.getAccessor()))
    return testKey((VertexProperty) element);
  else {
    if (element instanceof Vertex) {
      final Iterator<? extends Property> itty = element.properties(this.key);
      while (itty.hasNext()) {
        if (testValue(itty.next()))
          return true;
      }
      return false;
    } else {
      final Property property = element.property(this.key);
      return property.isPresent() && testValue(property);
    }
  }
}

代码示例来源:origin: apache/tinkerpop

private void assertPropertyValue(final Element element) {
  if (value instanceof Map)
    tryCommit(graph, graph -> {
      final Map map = element.<Map>property("aKey").value();
      assertEquals(((Map) value).size(), map.size());
      ((Map) value).keySet().forEach(k -> assertEquals(((Map) value).get(k), map.get(k)));
  else if (value instanceof List)
    tryCommit(graph, graph -> {
      final List l = element.<List>property("aKey").value();
      assertEquals(((List) value).size(), l.size());
      for (int ix = 0; ix < ((List) value).size(); ix++) {
  else if (value instanceof MockSerializable)
    tryCommit(graph, graph -> {
      final MockSerializable mock = element.<MockSerializable>property("aKey").value();
      assertEquals(((MockSerializable) value).getTestField(), mock.getTestField());
    });
  else if (value instanceof boolean[])
    tryCommit(graph, graph -> {
      final boolean[] l = element.<boolean[]>property("aKey").value();
      assertEquals(((boolean[]) value).length, l.length);
      for (int ix = 0; ix < ((boolean[]) value).length; ix++) {
  else if (value instanceof double[])
    tryCommit(graph, graph -> {
      final double[] l = element.<double[]>property("aKey").value();
      assertEquals(((double[]) value).length, l.length);
      for (int ix = 0; ix < ((double[]) value).length; ix++) {

代码示例来源:origin: apache/tinkerpop

final Property currentProperty = traverser.get().property(key);
  final boolean newProperty = element instanceof Vertex ? currentProperty == VertexProperty.empty() : currentProperty == Property.empty();
  final Event.ElementPropertyChangedEvent evt;
  ((Vertex) element).property(key, value, vertexPropertyKeyValues);
else
  element.property(key, value);

代码示例来源:origin: org.jboss.windup.graph/windup-graph-api

private void addTokenProperty(Element el, String propertyName, String propertyValue)
{
  Property<String> val = el.property(propertyName);
  if (!val.isPresent())
    el.property(propertyName, propertyValue);
  else
    el.property(propertyName, val.value() + "|" + propertyValue);
}

代码示例来源:origin: uk.gov.dstl.baleen/baleen-graph

private Map<String, Object> aggregateProperties(Element element) {
 Map<String, Object> mention = new HashMap<>();
 mention.put(ID_PROPERTY, element.id());
 options
   .getAggregateProperties()
   .forEach(p -> element.property(p).ifPresent(value -> mention.put(p, value)));
 return mention;
}

代码示例来源:origin: com.syncleus.ferma/ferma

@Override
public <T> T getProperty(final String name, final Class<T> type) {
  final Property<T> nameProperty = getElement().property(name);
  if( !nameProperty.isPresent() )
    return null;
  final T nameValue = nameProperty.value();
  if (type.isEnum()) {
    return (T) Enum.valueOf((Class<Enum>) type, nameValue.toString());
  }
  return nameValue;
}

代码示例来源:origin: Syncleus/Ferma

@Override
public <T> T getProperty(final String name, final Class<T> type) {
  final Property<T> nameProperty = getElement().property(name);
  if( !nameProperty.isPresent() )
    return null;
  final T nameValue = nameProperty.value();
  if (type.isEnum()) {
    return (T) Enum.valueOf((Class<Enum>) type, nameValue.toString());
  }
  return nameValue;
}

代码示例来源:origin: apache/atlas

@Override
public void setProperty(String propertyName, Object value) {
  try {
    getWrappedElement().property(propertyName, value);
  } catch(SchemaViolationException e) {
    throw new AtlasSchemaViolationException(e);
  }
}

代码示例来源:origin: Syncleus/Ferma

@Override
  public boolean test(final Traverser<T> toCheck) {
    final Property<String> property = toCheck.get().property(typeResolutionKey);
    if( !property.isPresent() )
      return true;
    final String resolvedType = property.value();
    if( allAllowedValues.contains(resolvedType) )
      return false;
    else
      return true;
  }
});

代码示例来源:origin: org.apache.tinkerpop/gremlin-core

@Override
public <V> Property<V> property(final String key, final V value) {
  if (state.equals(State.MAP_REDUCE))
    throw GraphComputer.Exceptions.vertexPropertiesCanNotBeUpdatedInMapReduce();
  return new ComputerProperty<>(this.element.property(key, value));
}

代码示例来源:origin: com.syncleus.ferma/ferma

@Override
public <T> T getProperty(final String name) {
  final Property<T> property = getElement().<T>property(name);
  if( property.isPresent())
    return property.value();
  else
    return null;
}

代码示例来源:origin: com.syncleus.ferma/ferma

@Override
public Class<?> resolve(final Element element) {
  final Property<String> typeResolutionName = element.<String>property(this.typeResolutionKey);
  if( typeResolutionName.isPresent() )
    return this.reflectionCache.forName(typeResolutionName.value());
  else
    return null;
}

代码示例来源:origin: org.hawkular.inventory/hawkular-inventory-impl-tinkerpop

@Override
public Element visitMetricType(MetricType.Blueprint type, Void parameter) {
  Element entity = common(path, type.getName(), type.getProperties(), MetricType.class);
  entity.property(Constants.Property.__metric_data_type.name(), type.getMetricDataType()
      .getDisplayName());
  entity.property(Constants.Property.__metric_interval.name(), type.getCollectionInterval());
  return entity;
}

代码示例来源:origin: org.hawkular.inventory/hawkular-inventory-impl-tinkerpop

@Override
public Element visitMetric(Metric.Blueprint metric, Void parameter) {
  Element entity = common(path, metric.getName(), metric.getProperties(), Metric.class);
  if (metric.getCollectionInterval() != null) {
    entity.property(Constants.Property.__metric_interval.name(), metric.getCollectionInterval());
  }
  return entity;
}

相关文章