/** * 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); } }
@Override public void removeProperty(String propertyName) { wrappedElement.removeProperty(propertyName); }
@Override public void deinit(final Element element) { element.removeProperty(this.typeResolutionKey); }
public <T> T removeProperty(final String key) { return this.baseElement.removeProperty(key); }
public <T> T removeProperty(final String key) { if (propertyBased) { if (key.equals(IdGraph.ID)) { throw new IllegalArgumentException("Unable to remove value for reserved property " + IdGraph.ID); } } return baseElement.removeProperty(key); }
public <T> T removeProperty(final String key) { if (key.equals(this.graph.getPartitionKey())) return null; return this.baseElement.removeProperty(key); }
@Override public <T> T removeProperty(String key) { checkArgument(!propertyBased || !key.equals(IdGraph.ID), "Unable to remove value for reserved property %s", IdGraph.ID); return base.removeProperty(key); }
/** * 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); } } }
/** * 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); } }
/** * Typecasts a property value. This only works for casting to a class that has a constructor of the for new X(String). * If no such constructor exists, a RuntimeException is thrown and the original element property is left unchanged. * * @param key the key for the property value to typecast * @param classCast the class to typecast to * @param elements the elements to have their property typecasted */ public static void typecastProperty(final String key, final Class classCast, final Iterable<Element> elements) { for (final Element element : elements) { final Object value = element.removeProperty(key); if (null != value) { try { element.setProperty(key, classCast.getConstructor(String.class).newInstance(value.toString())); } catch (Exception e) { element.setProperty(key, value); throw new RuntimeException(e.getMessage(), e); } } } }
/** * Raises a vertexPropertyRemoved or edgePropertyRemoved event. */ public <T> T removeProperty(final String key) { final Object propertyRemoved = baseElement.removeProperty(key); if (this instanceof Vertex) { this.onVertexPropertyRemoved((Vertex) this, key, propertyRemoved); } else if (this instanceof Edge) { this.onEdgePropertyRemoved((Edge) this, key, propertyRemoved); } return (T) propertyRemoved; }
/** * 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); } } }
/** * Sync the specified active element with the corresponding one. * * @param a active element * @param h historic, latest element. */ public void syncActiveAndLatestHistoric(ActiveVersionedElement<V, ?> a, HistoricVersionedElement<V, ?> h) { Set<String> removedKeys = new HashSet<String>(h.getPropertyKeys()); removedKeys.removeAll(VEProps.internalPreservedElementKeys); removedKeys.removeAll(a.getPropertyKeys()); for (String k : a.getPropertyKeys()) { if (!VEProps.nonCopiableKeys.contains(k)) { h.getRaw().setProperty(k, a.getProperty(k)); } } for (String k : removedKeys) { h.getRaw().removeProperty(k); } }
@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; }
@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; }
for (final Element element : elements) { for (final String key : keys) { final Object value = element.removeProperty(key); if (null != value) { counter++;
if (modelElement.getProperty(propName) != null) { LOGGER.log(Level.FINEST, "attribute {0} has a null value, clearing old value", propName); modelElement.removeProperty(propName); } else { LOGGER.log(Level.FINEST, "attribute {0} has a null value, not storing it!", propName);