/** * Return this value as a regular java boxed primitive, String or primitive array. This method does not clone * primitive arrays. * * @return the object version of the current value */ public Object asObject() { return asObjectCopy(); }
@Override public Object previouslyCommitedValue() { return oldValue.asObjectCopy(); }
public static Object[] asObjects( Value[] propertyValues ) { Object[] legacy = new Object[propertyValues.length]; for ( int i = 0; i < propertyValues.length; i++ ) { legacy[i] = propertyValues[i].asObjectCopy(); } return legacy; }
@Override public Object previouslyCommitedValue() { return oldValue.asObjectCopy(); }
@Override public Object value() { if ( newValue == null || newValue == Values.NO_VALUE ) { throw new IllegalStateException( "This property has been removed, it has no value anymore: " + this ); } return newValue.asObjectCopy(); }
@Override public Object value() { if ( newValue == null || newValue == Values.NO_VALUE ) { throw new IllegalStateException( "This property has been removed, it has no value anymore: " + this ); } return newValue.asObjectCopy(); }
void assertGeneratesPublic() { assertThat( value.asObjectCopy(), equalTo( expected ) ); } }
private static Value duplicateValue( Value propertyValue ) { return Values.of( propertyValue.asObjectCopy() ); }
@Test void shouldProvideDirectDoubleArrayAsPublic() { double[] inStore = {1}; Value value = Values.doubleArray( inStore ); Object asObject = value.asObjectCopy(); assertNotNull( asObject, "should return double[]" ); double[] arr = (double[]) asObject; assertTrue( Arrays.equals( inStore, arr ), "should have same values" ); arr[0] = -1; assertFalse( Arrays.equals( inStore, arr ), "should not modify inStore array" ); assertTrue( Arrays.equals( inStore, (double[])value.asObjectCopy() ), "should still generate inStore array" ); }
@Test void shouldProvideDirectStringArrayAsPublic() { String[] inStore = {"a"}; Value value = Values.stringArray( inStore ); Object asObject = value.asObjectCopy(); assertNotNull( asObject, "should return String[]" ); String[] arr = (String[]) asObject; assertTrue( Arrays.equals( inStore, arr ), "should have same values" ); arr[0] = "b"; assertFalse( Arrays.equals( inStore, arr ), "should not modify inStore array" ); assertTrue( Arrays.equals( inStore, (String[])value.asObjectCopy() ), "should still generate inStore array" ); }
@Test void shouldProvideDirectByteArrayAsPublic() { byte[] inStore = {1}; Value value = Values.byteArray( inStore ); Object asObject = value.asObjectCopy(); assertNotNull( asObject, "should return byte[]" ); byte[] arr = (byte[]) asObject; assertTrue( Arrays.equals( inStore, arr ), "should have same values" ); arr[0] = -1; assertFalse( Arrays.equals( inStore, arr ), "should not modify inStore array" ); assertTrue( Arrays.equals( inStore, (byte[]) value.asObjectCopy() ), "should still generate inStore array" ); }
@Test void shouldProvideDirectIntArrayAsPublic() { int[] inStore = {1}; Value value = Values.intArray( inStore ); Object asObject = value.asObjectCopy(); assertNotNull( asObject, "should return int[]" ); int[] arr = (int[]) asObject; assertTrue( Arrays.equals( inStore, arr ), "should have same values" ); arr[0] = -1; assertFalse( Arrays.equals( inStore, arr ), "should not modify inStore array" ); assertTrue( Arrays.equals( inStore, (int[])value.asObjectCopy() ), "should still generate inStore array" ); }
@Test void shouldProvideDirectBooleanArrayAsPublic() { boolean[] inStore = {true}; Value value = Values.booleanArray( inStore ); Object asObject = value.asObjectCopy(); assertNotNull( asObject, "should return boolean[]" ); boolean[] arr = (boolean[]) asObject; assertTrue( Arrays.equals( inStore, arr ), "should have same values" ); arr[0] = false; assertFalse( Arrays.equals( inStore, arr ), "should not modify inStore array" ); assertTrue( Arrays.equals( inStore, (boolean[])value.asObjectCopy() ), "should still generate inStore array" ); }
@Test void shouldProvideDirectFloatArrayAsPublic() { float[] inStore = {1}; Value value = Values.floatArray( inStore ); Object asObject = value.asObjectCopy(); assertNotNull( asObject, "should return float[]" ); float[] arr = (float[]) asObject; assertTrue( Arrays.equals( inStore, arr ), "should have same values" ); arr[0] = -1; assertFalse( Arrays.equals( inStore, arr ), "should not modify inStore array" ); assertTrue( Arrays.equals( inStore, (float[])value.asObjectCopy() ), "should still generate inStore array" ); }
@Test void shouldProvideDirectLongArrayAsPublic() { long[] inStore = {1}; Value value = Values.longArray( inStore ); Object asObject = value.asObjectCopy(); assertNotNull( asObject, "should return long[]" ); long[] arr = (long[]) asObject; assertTrue( Arrays.equals( inStore, arr ), "should have same values" ); arr[0] = -1; assertFalse( Arrays.equals( inStore, arr ), "should not modify inStore array" ); assertTrue( Arrays.equals( inStore, (long[])value.asObjectCopy() ), "should still generate inStore array" ); }
@Override public void process( IndexEntryUpdate<?> update ) { switch ( update.updateMode() ) { case ADDED: case CHANGED: added.add( Pair.of( update.getEntityId(), update.values()[0].asObjectCopy() ) ); break; default: throw new IllegalArgumentException( update.updateMode().name() ); } }
void add( IndexEntryUpdate<?> update ) { if ( update.getEntityId() == 2 ) { job.update( IndexEntryUpdate.remove( nodeToDelete, index, valueToDelete ) ); } added.put( update.getEntityId(), update.values()[0].asObjectCopy() ); }
void add( IndexEntryUpdate<?> update ) { if ( update.getEntityId() == 2 ) { job.update( IndexEntryUpdate.change( nodeToChange, index, previousValue, newValue ) ); } added.add( Pair.of( update.getEntityId(), update.values()[0].asObjectCopy() ) ); }
private void testDateTypeWithPrecedingInLinedLong( Value value ) { node1.setProperty( "l1", 255 ); // Setting these low bits was triggering a bug in some date types decision on formatting String key = "dt"; node1.setProperty( key, value ); newTransaction(); Object property = node1.getProperty( key ); assertEquals( value.asObjectCopy(), property ); }
private void testDateTypeWithPrecedingNotInLinedLong( Value value ) { node1.setProperty( "l1", Long.MAX_VALUE ); String key = "dt"; node1.setProperty( key, value ); newTransaction(); Object property = node1.getProperty( key ); assertEquals( value.asObjectCopy(), property ); } }