com.tinkerpop.blueprints.Element类的使用及代码示例

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

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

Element介绍

[英]An Element is the base class for both vertices and edges. An element has an identifier that must be unique to its inheriting classes (vertex or edges). An element can maintain a collection of key/value properties. Keys are always Strings and values can be any Object. Particular implementations can reduce the space of objects that can be used as values. Typically, objects are Java primitives (e.g. String, long, int, boolean, etc.)
[中]元素是顶点和边的基类。元素的标识符必须对其继承类(顶点或边)唯一。元素可以维护键/值属性的集合。键始终是字符串,值可以是任何对象。特定的实现可以减少可用作值的对象的空间。通常,对象是Java原语(例如String、long、int、boolean等)

代码示例

代码示例来源:origin: gentics/mesh

public void debug(Element element) {
  System.out.println("---");
  for (String key : element.getPropertyKeys()) {
    System.out.println(key + " : " + element.getProperty(key));
  }
  System.out.println("---");
}

代码示例来源:origin: BrynCooke/totorom

/**
 * @return The id of this element.
 */
protected <N> N getId() {
  return (N) element.getId();
}

代码示例来源:origin: com.tinkerpop.blueprints/blueprints-core

/**
 * Copy the properties (key and value) from one element to another.
 * The properties are preserved on the from element.
 * ElementPropertiesRule that share the same key on the to element are overwritten.
 *
 * @param from the element to copy properties from
 * @param to   the element to copy properties to
 */
public static void copyProperties(final Element from, final Element to) {
  for (final String key : from.getPropertyKeys()) {
    to.setProperty(key, from.getProperty(key));
  }
}

代码示例来源:origin: com.tinkerpop.blueprints/blueprints-core

public Object getId() {
  return propertyBased
      ? baseElement.getProperty(IdGraph.ID)
      : baseElement.getId();
}

代码示例来源:origin: com.tinkerpop.blueprints/blueprints-core

/**
 * Renames a property by removing the old key and adding the stored value to the new key.
 * If property does not exist, nothing occurs.
 *
 * @param oldKey   the key to rename
 * @param newKey   the key to rename to
 * @param elements the elements to rename
 */
public static void renameProperty(final String oldKey, final String newKey, final Iterable<Element> elements) {
  for (final Element element : elements) {
    Object value = element.removeProperty(oldKey);
    if (null != value)
      element.setProperty(newKey, value);
  }
}

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

@Override
public Object processElement(Object frame, Method method,
    Object[] arguments, Property annotation,
    FramedGraph<?> framedGraph, Element element) {
  if (ClassUtilities.isGetMethod(method)) {
    Object value = element.getProperty(annotation.value());
    if (method.getReturnType().isEnum())
      return getValueAsEnum(method, value);
    else
      return value;
  } else if (ClassUtilities.isSetMethod(method)) {
    Object value = arguments[0];
    if (null == value) {
      element.removeProperty(annotation.value());
    } else {
      if (value.getClass().isEnum()) {
        element.setProperty(annotation.value(), ((Enum<?>) value).name());
      } else {
        element.setProperty(annotation.value(), value);
      }
    }
    if (method.getReturnType().isAssignableFrom(frame.getClass()))
    return frame;
  } else if (ClassUtilities.isRemoveMethod(method)) {
    element.removeProperty(annotation.value());
    return null;
  }
  return null;
}

代码示例来源:origin: BrynCooke/totorom

/**
 * Return a property value.
 * 
 * @param name
 *            The name of the property.
 * @return the value of the property or null if none was present.
 */
protected <T> T getProperty(String name) {
  return element.getProperty(name);
}

代码示例来源:origin: com.tinkerpop/pipes

protected Map<String, Object> processNextStart() {
    final S element = this.starts.next();
    final Map<String, Object> map = new HashMap<String, Object>();
    if (this.keys.length == 0) {
      // TODO: add ID and LABEL as properties?
      for (final String key : element.getPropertyKeys()) {
        map.put(key, element.getProperty(key));
      }
    } else {
      for (final String key : this.keys) {
        if (key.equals(ID))
          map.put(ID, element.getId());
        else if (element instanceof Edge && key.equals(LABEL))
          map.put(LABEL, ((Edge) element).getLabel());
        else
          map.put(key, element.getProperty(key));
      }
    }
    return map;
  }
}

代码示例来源:origin: BrynCooke/totorom

@Override
  public <T extends FramedElement> void init(Element element, Class<T> kind) {
    String clazz = element.getProperty("java_class");
    if (clazz == null) {
      element.setProperty("java_class", kind.getName());
    }
  }
};

代码示例来源:origin: com.tinkerpop.blueprints/blueprints-core

public void setProperty(final String key, final Object value) {
  this.baseElement.setProperty(key, value);
}

代码示例来源:origin: BrynCooke/totorom

/**
 * @return The property keys of this element.
 */
protected Set<String> getPropertyKeys() {
  return element.getPropertyKeys();
}

代码示例来源:origin: com.tinkerpop.blueprints/blueprints-core

/**
 * Clear all the properties from an iterable of elements.
 *
 * @param elements the elements to remove properties from
 */
public static void removeProperties(final Iterable<Element> elements) {
  for (final Element element : elements) {
    final List<String> keys = new ArrayList<String>();
    keys.addAll(element.getPropertyKeys());
    for (final String key : keys) {
      element.removeProperty(key);
    }
  }
}

代码示例来源:origin: com.tinkerpop.blueprints/blueprints-core

/**
 * Remove a property from all elements in the provided iterable.
 *
 * @param key      the property to remove by key
 * @param elements the elements to remove the property from
 */
public static void removeProperty(final String key, final Iterable<Element> elements) {
  for (final Element element : elements) {
    element.removeProperty(key);
  }
}

代码示例来源:origin: atlanmod/NeoEMF

@Override
public Object getId() {
  return propertyBased ? base.getProperty(IdGraph.ID) : base.getId();
}

代码示例来源:origin: com.tinkerpop/frames

@Override
public Object processElement(final Property annotation, final Method method, final Object[] arguments, final FramedGraph framedGraph, final Element element, final Direction direction) {
  if (ClassUtilities.isGetMethod(method)) {
    Object value = element.getProperty(annotation.value());
    if (method.getReturnType().isEnum())
      return getValueAsEnum(method, value);
    else
      return value;
  } else if (ClassUtilities.isSetMethod(method)) {
    Object value = arguments[0];
    if (null == value) {
      element.removeProperty(annotation.value());
    } else {
      if (value.getClass().isEnum()) {
        element.setProperty(annotation.value(), ((Enum<?>) value).name());
      } else {
        element.setProperty(annotation.value(), value);
      }
    }
    return null;
  } else if (ClassUtilities.isRemoveMethod(method)) {
    element.removeProperty(annotation.value());
    return null;
  }
  return null;
}

代码示例来源:origin: com.tinkerpop.blueprints/blueprints-core

public <T> T getProperty(final String key) {
  if (propertyBased && key.equals(IdGraph.ID)) {
    return null;
  } else {
    return baseElement.getProperty(key);
  }
}

代码示例来源:origin: atlanmod/NeoEMF

/**
 * Copies all {@code propertyKeys} from the {@code source} to the {@code target}.
 *
 * @param source       the source element
 * @param target       the target element
 * @param propertyKeys the property keys to copy
 */
private void copyProperties(Element source, Element target, Set<String> propertyKeys) {
  propertyKeys.forEach(k -> target.setProperty(k, source.getProperty(k)));
}

代码示例来源:origin: BrynCooke/totorom

/**
 * Set a property value.
 * 
 * @param name
 *            The name of the property.
 * @param value
 *            The value of the property.
 */
protected void setProperty(String name, Object value) {
  if (value == null) {
    element.removeProperty(name);
  } else {
    if (value instanceof Enum) {
      element.setProperty(name, value.toString());
    } else {
      element.setProperty(name, value);
    }
  }
}

代码示例来源:origin: gentics/mesh

@Override
public void init(final Element element, final Class<?> kind) {
  element.setProperty(this.typeResolutionKey, kind.getSimpleName());
}

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

@Override
public Set<String> getPropertyKeys() {
  return wrappedElement.getPropertyKeys();
}

相关文章