com.tinkerpop.blueprints.Element.setProperty()方法的使用及代码示例

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

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

Element.setProperty介绍

[英]Assign a key/value property to the element. If a value already exists for this key, then the previous key/value is overwritten.
[中]为元素指定键/值属性。如果此键的值已存在,则覆盖上一个键/值。

代码示例

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

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

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

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

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

/**
 * Set the properties of the provided element using the provided key value pairs.
 * The var args of Objects must be divisible by 2. All odd elements in the array must be a String key.
 *
 * @param element    the element to set the properties of
 * @param keysValues the key value pairs of the properties
 */
public static void setProperties(final Element element, final Object... keysValues) {
  if (keysValues.length % 2 != 0)
    throw new IllegalArgumentException("The object var args must be divisible by 2");
  for (int i = 0; i < keysValues.length; i = i + 2) {
    element.setProperty((String) keysValues[i], keysValues[i + 1]);
  }
}

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

public void setProperty(final String key, final Object value) {
  if (propertyBased && key.equals(IdGraph.ID)) {
    throw new IllegalArgumentException("Unable to set value for reserved property " + IdGraph.ID);
  }
  baseElement.setProperty(key, value);
}

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

/**
 * Set the properties of the provided element using the provided map.
 *
 * @param element    the element to set the properties of
 * @param properties the properties to set as a Map
 */
public static void setProperties(final Element element, final Map<String, Object> properties) {
  for (Map.Entry<String, Object> property : properties.entrySet()) {
    element.setProperty(property.getKey(), property.getValue());
  }
}

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

private void addProperties(final Element element, final Map<String, Object> map) {
  for (Map.Entry<String, Object> entry : map.entrySet()) {
    element.setProperty(entry.getKey(), entry.getValue());
  }
}

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

@Override
public <U> void setProperty(String propertyName, U value) {
  try {
    wrappedElement.setProperty(propertyName, value);
  } catch (SchemaViolationException e) {
    throw new AtlasSchemaViolationException(e);
  }
}

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

@Override
public void setProperty(String key, Object value) {
  checkArgument(!propertyBased || !key.equals(IdGraph.ID), "Unable to set value for reserved property %s", IdGraph.ID);
  base.setProperty(key, value);
}

代码示例来源: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) {
  if (!key.equals(this.graph.getPartitionKey()))
    this.baseElement.setProperty(key, value);
}

代码示例来源: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: com.tinkerpop.blueprints/blueprints-core

public void setPartition(final String partition) {
  this.baseElement.setProperty(this.graph.getPartitionKey(), partition);
}

代码示例来源: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: gentics/mesh

/**
 * Change type: com.gentics.mesh.core.data.impl.UserImpl to UserImpl
 * 
 * @param element
 */
private void migrateType(Element element) {
  String type = element.getProperty("ferma_type");
  if (!StringUtils.isEmpty(type)) {
    int idx = type.lastIndexOf(".");
    if (idx != -1) {
      type = type.substring(idx + 1);
      element.setProperty("ferma_type", type);
    }
  }
}

代码示例来源:origin: SciGraph/SciGraph

static void copyProperties(Element source, Element target) {
 for (String key : source.getPropertyKeys()) {
  Object property = source.getProperty(key);
  if (property.getClass().isArray()) {
   List<Object> propertyList = new ArrayList<>();
   for (int i = 0; i < Array.getLength(property); i++) {
    propertyList.add(Array.get(property, i));
   }
   property = propertyList;
  }
  target.setProperty(key, property);
 }
}

代码示例来源:origin: indexiatech/antiquity

/**
 * Copy properties from one element to another.
 * 
 * @param from element to copy properties from
 * @param to element to copy properties to
 * @param excludedKeys the keys that should be excluded from being copied.
 */
public static void copyProps(Element from, Element to, Set<String> excludedKeys) {
  for (String k : from.getPropertyKeys()) {
    if (excludedKeys != null && excludedKeys.contains(k)) {
      continue;
    }
    to.setProperty(k, from.getProperty(k));
  }
}

代码示例来源: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/frames

@Override
public void initElement(Class<?> kind, FramedGraph<?> framedGraph, Element element) {
  Class<?> typeHoldingTypeField = typeRegistry.getTypeHoldingTypeField(kind);
  if (typeHoldingTypeField != null) {
    TypeValue typeValue = kind.getAnnotation(TypeValue.class);
    if (typeValue != null) {
      element.setProperty(typeHoldingTypeField.getAnnotation(TypeField.class).value(), typeValue.value());
    }
  }
}

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

@Override
public void initElement(Class<?> kind, FramedGraph<?> framedGraph, Element element) {
  Class<?> typeHoldingTypeField = typeRegistry.getTypeHoldingTypeField(kind);
  if (typeHoldingTypeField != null) {
    TypeValue typeValue = kind.getAnnotation(TypeValue.class);
    if (typeValue != null) {
      element.setProperty(typeHoldingTypeField.getAnnotation(TypeField.class).value(), typeValue.value());
    }
  }
}

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

/**
 * Raises a vertexPropertyRemoved or edgePropertyChanged event.
 */
public void setProperty(final String key, final Object value) {
  final Object oldValue = this.baseElement.getProperty(key);
  this.baseElement.setProperty(key, value);
  if (this instanceof Vertex) {
    this.onVertexPropertyChanged((Vertex) this, key, oldValue, value);
  } else if (this instanceof Edge) {
    this.onEdgePropertyChanged((Edge) this, key, oldValue, value);
  }
}

相关文章