Java Code Examples for com.tinkerpop.blueprints.Element#getPropertyKeys()
The following examples show how to use
com.tinkerpop.blueprints.Element#getPropertyKeys() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ArrayPropertyTransformer.java From SciGraph with Apache License 2.0 | 6 votes |
static void transform(Iterable<? extends Element> elements) { for (Element element: elements) { for (String key: element.getPropertyKeys()) { if (PROTECTED_PROPERTY_KEYS.contains(key)) { continue; } else { Object value = element.getProperty(key); if (value instanceof Iterable) { // Leave it } else if (value.getClass().isArray()) { element.setProperty(key, Arrays.asList(value)); } else { element.setProperty(key, newArrayList(value)); } } } } }
Example 2
Source File: TinkerGraphUtil.java From SciGraph with Apache License 2.0 | 5 votes |
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); } }
Example 3
Source File: ElementUtils.java From antiquity with GNU General Public License v3.0 | 5 votes |
/** * Returns {@link Element}'s properties as an immutable map. * * @return An immutable map of the specified {@link Element} properties * exlcuding the specified keys */ public static Map<String, Object> getPropertiesAsMap(Element element, Set<String> excludedKeys) { Builder<String, Object> props = ImmutableMap.builder(); for (String key : element.getPropertyKeys()) { if ((excludedKeys != null) && excludedKeys.contains(key)) { continue; } props.put(key, element.getProperty(key)); } return props.build(); }
Example 4
Source File: ElementUtils.java From antiquity with GNU General Public License v3.0 | 5 votes |
/** * 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)); } }
Example 5
Source File: ElementUtils.java From antiquity with GNU General Public License v3.0 | 5 votes |
/** * Get the specified {@link Element} properties as a string. * * @param withHeader if true the element's id will be printed in the first * line. * @param e The element to get the properties string for * @return A formatted string containing the specified element's properties */ public static String getElementPropsAsString(Element e, boolean withHeader) { StringBuilder elementPropsStr = new StringBuilder(); if (withHeader) { elementPropsStr.append(e); } for (String key : e.getPropertyKeys()) { elementPropsStr.append("\t").append(key).append("->").append(e.getProperty(key)); } return elementPropsStr.toString(); }
Example 6
Source File: ElementHelper.java From org.openntf.domino with Apache License 2.0 | 5 votes |
/** * Determines whether two elements have the same properties. * To be true, both must have the same property keys and respective values must be equals(). * * @param a an element * @param b an element * @return whether the two elements have equal properties */ public static boolean haveEqualProperties(final Element a, final Element b) { final Set<String> aKeys = a.getPropertyKeys(); final Set<String> bKeys = b.getPropertyKeys(); if (aKeys.containsAll(bKeys) && bKeys.containsAll(aKeys)) { for (String key : aKeys) { if (!a.getProperty(key).equals(b.getProperty(key))) return false; } return true; } else { return false; } }
Example 7
Source File: ElementHelper.java From org.openntf.domino with Apache License 2.0 | 5 votes |
/** * Get a clone of the properties of the provided element. * In other words, a HashMap is created and filled with the key/values of the element's properties. * * @param element the element to get the properties of * @return a clone of the properties of the element */ public static Map<String, Object> getProperties(final Element element) { final Map<String, Object> properties = new HashMap<String, Object>(); for (final String key : element.getPropertyKeys()) { properties.put(key, element.getProperty(key)); } return properties; }
Example 8
Source File: GraphDump.java From SciGraph with Apache License 2.0 | 4 votes |
public static void dumpProperties(Element container) { for (String key: container.getPropertyKeys()) { System.out.println(key + ": " + container.getProperty(key)); } }
Example 9
Source File: ElementHelper.java From org.openntf.domino with Apache License 2.0 | 2 votes |
/** * 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)); } }