public boolean hasProperty( final String key ) throws Exception { return execute( state -> state.properties.hasProperty( key ) ); }
@Override protected boolean matchesSafely( PropertyContainer propertyContainer, Description mismatchDescription ) { if ( !propertyContainer.hasProperty( propertyName ) ) { mismatchDescription.appendText( String.format( "found property container with property keys: %s", Iterables.asSet( propertyContainer.getPropertyKeys() ) ) ); return false; } return true; }
@Test public void shouldBeAbleToRemoveExistingGraphProperty() throws Exception { int prop; try ( Transaction tx = beginTransaction() ) { prop = tx.tokenWrite().propertyKeyGetOrCreateForName( "prop" ); assertThat( tx.dataWrite().graphSetProperty( prop, stringValue( "hello" ) ), equalTo( NO_VALUE ) ); tx.success(); } try ( Transaction tx = beginTransaction() ) { assertThat( tx.dataWrite().graphRemoveProperty( prop ), equalTo( stringValue("hello") ) ); tx.success(); } try ( org.neo4j.graphdb.Transaction ignore = graphDb.beginTx() ) { assertFalse( testSupport.graphProperties().hasProperty( "prop" ) ); } }
public static void combineProperties(Map.Entry<String, Object> prop, PropertyContainer target) { if (!target.hasProperty(prop.getKey())) target.setProperty(prop.getKey(), prop.getValue()); else { Set<Object> values = new LinkedHashSet<>(); if (target.getProperty(prop.getKey()).getClass().isArray()) values.addAll(new ArrayBackedList(target.getProperty(prop.getKey()))); else values.add(target.getProperty(prop.getKey())); if (prop.getValue().getClass().isArray()) values.addAll(new ArrayBackedList(prop.getValue())); else values.add(prop.getValue()); Object array = createPropertyValueFromSet(values); target.setProperty(prop.getKey(), array); } }
public static void mergeProperties(Map<String, Object> properties, PropertyContainer target, RefactorConfig propertyManagementMode) { for (Map.Entry<String, Object> prop : properties.entrySet()) { String key = prop.getKey(); String mergeMode = propertyManagementMode.getMergeMode(key); switch (mergeMode) { case RefactorConfig.OVERWRITE: target.setProperty(key, prop.getValue()); break; case RefactorConfig.DISCARD: if (!target.hasProperty(key)) { target.setProperty(key, prop.getValue()); } break; case RefactorConfig.COMBINE: combineProperties(prop, target); break; } } }
private void collectProps(Collection<String> fields, PropertyContainer pc, Reporter reporter, String[] row, int offset, String delimiter) { for (String field : fields) { if (pc.hasProperty(field)) { row[offset] = FormatUtils.toString(pc.getProperty(field)); reporter.update(0,0,1); } else { row[offset] = ""; } offset++; } }
public static String getStringProperty( final String prop, final PropertyContainer container ) { if ( container.hasProperty( prop ) ) { return (String) container.getProperty( prop ); } return null; }
/** * {@inheritDoc} */ @Override public boolean hasProperty(String key) { return getPropertyContainer().hasProperty(key); }
public static Boolean getBooleanProperty( final String prop, final PropertyContainer container ) { if ( container.hasProperty( prop ) ) { return (Boolean) container.getProperty( prop ); } return null; }
public static Boolean getBooleanProperty( final String prop, final PropertyContainer container, final Boolean defaultValue ) { if ( container.hasProperty( prop ) ) { return (Boolean) container.getProperty( prop ); } return defaultValue; }
public static Integer getIntegerProperty( final String prop, final PropertyContainer container ) { if ( container.hasProperty( prop ) ) { return (Integer) container.getProperty( prop ); } return null; }
public static Integer getIntegerProperty( final String prop, final PropertyContainer container, final int defaultValue ) { if ( container.hasProperty( prop ) ) { return (Integer) container.getProperty( prop ); } return defaultValue; }
public static Long getLongProperty( final String prop, final PropertyContainer container, final long defaultValue ) { if ( container.hasProperty( prop ) ) { return (Long) container.getProperty( prop ); } return defaultValue; }
public static void removeProperty( final String key, final PropertyContainer container ) { if ( container.hasProperty( key ) ) { container.removeProperty( key ); } }
public static String setConfigProperty( final String key, final String value, final PropertyContainer container ) { final String pkey = CONFIG_PROPERTY_PREFIX + key; final String old = container.hasProperty( pkey ) ? (String) container.getProperty( pkey ) : null; container.setProperty( pkey, value ); return old; }
private void collectProps(Collection<String> fields, PropertyContainer pc, Reporter reporter, Object[] row, int offset) { for (String field : fields) { if (pc.hasProperty(field)) { row[offset] = pc.getProperty(field); reporter.update(0,0,1); } else { row[offset] = ""; } offset++; } }
public static String removeConfigProperty( final String key, final PropertyContainer container ) { final String pkey = CONFIG_PROPERTY_PREFIX + key; String old = null; if ( container.hasProperty( pkey ) ) { old = (String) container.getProperty( pkey ); container.removeProperty( pkey ); } return old; }
public <T> T removeProperty(final String key) { if (!this.rawElement.hasProperty(key)) return null; else { this.graph.autoStartTransaction(true); return (T) this.rawElement.removeProperty(key); } }
/** * {@inheritDoc} */ @Override public boolean hasProperty(String key) { if (!getPropertyInclusionStrategy().include(key, self())) { return false; } return wrapped.hasProperty(key); }
public <T> T getProperty(final String key) { this.graph.autoStartTransaction(false); if (this.rawElement.hasProperty(key)) return (T) tryConvertCollectionToArrayList(this.rawElement.getProperty(key)); else return null; }