Skip to content

Commit c71f92e

Browse files
committed
More Results API refactoring, post discussion with SP
- rename value -> get - rename retain -> list - introduce "Experimental" marker annotation, highlighting that the type system API is still experimental.
1 parent 269f4d8 commit c71f92e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+183
-158
lines changed

driver/src/main/java/org/neo4j/driver/internal/InternalEntity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public Iterable<String> keys()
106106
}
107107

108108
@Override
109-
public Value value( String key )
109+
public Value get( String key )
110110
{
111111
Value value = properties.get( key );
112112
return value == null ? Values.NULL : value;

driver/src/main/java/org/neo4j/driver/internal/InternalRecord.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public boolean containsKey( String key )
7575
}
7676

7777
@Override
78-
public Value value( String key )
78+
public Value get( String key )
7979
{
8080
Integer fieldIndex = keyIndexLookup.get( key );
8181

@@ -90,7 +90,7 @@ public Value value( String key )
9090
}
9191

9292
@Override
93-
public Value value( int index )
93+
public Value get( int index )
9494
{
9595
return index >= 0 && index < values.length ? values[index] : Values.NULL;
9696
}
@@ -145,8 +145,8 @@ else if ( other instanceof Record )
145145
}
146146
for ( int i = 0; i < size; i++ )
147147
{
148-
Value value = value( i );
149-
Value otherValue = otherRecord.value( i );
148+
Value value = get( i );
149+
Value otherValue = otherRecord.get( i );
150150
if ( ! value.equals( otherValue ) )
151151
{
152152
return false;

driver/src/main/java/org/neo4j/driver/internal/InternalResultCursor.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,14 @@ public boolean isOpen()
6060
return open;
6161
}
6262

63-
public Value value( int index )
63+
public Value get( int index )
6464
{
65-
return record().value( index );
65+
return record().get( index );
6666
}
6767

68-
public Value value( String key )
68+
public Value get( String key )
6969
{
70-
return record().value( key );
70+
return record().get( key );
7171
}
7272

7373
@Override
@@ -203,14 +203,13 @@ public RecordAccessor peek()
203203
return new PeekingRecordAccessor();
204204
}
205205

206-
@Override
207-
public List<Record> retain()
206+
public List<Record> recordsAsList()
208207
{
209-
return retain( recordAsIs() );
208+
return list( recordAsIs() );
210209
}
211210

212211
@Override
213-
public <T> List<T> retain( Function<RecordAccessor, T> mapFunction )
212+
public <T> List<T> list( Function<RecordAccessor, T> mapFunction )
214213
{
215214
if ( isEmpty() )
216215
{
@@ -298,9 +297,9 @@ public int index( String key )
298297
}
299298

300299
@Override
301-
public Value value( String key )
300+
public Value get( String key )
302301
{
303-
return record().value( key );
302+
return record().get( key );
304303
}
305304

306305
@Override
@@ -336,9 +335,9 @@ public Record record()
336335
}
337336

338337
@Override
339-
public Value value( int index )
338+
public Value get( int index )
340339
{
341-
return record().value( index );
340+
return record().get( index );
342341
}
343342
}
344343
}

driver/src/main/java/org/neo4j/driver/internal/connector/socket/SocketResponseHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ private void collectStatistics( StreamCollector collector, Value stats )
177177

178178
private int statsValue( Value stats, String name )
179179
{
180-
Value value = stats.value( name );
180+
Value value = stats.get( name );
181181
return value.isNull() ? 0 : value.asInt();
182182
}
183183

driver/src/main/java/org/neo4j/driver/internal/messaging/PackStreamMessageFormatV1.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ private void packValue( Value value ) throws IOException
243243
for ( String s : value.keys() )
244244
{
245245
packer.pack( s );
246-
packValue( value.value( s ) );
246+
packValue( value.get( s ) );
247247
}
248248
break;
249249

@@ -371,7 +371,7 @@ private void packProperties( Entity entity ) throws IOException
371371
for ( String propKey : keys )
372372
{
373373
packer.pack( propKey );
374-
packValue( entity.value( propKey ) );
374+
packValue( entity.get( propKey ) );
375375
}
376376
}
377377
}

driver/src/main/java/org/neo4j/driver/internal/summary/InternalNotification.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@ public class InternalNotification implements Notification
3030
@Override
3131
public Notification apply( Value value )
3232
{
33-
String code = value.value( "code" ).asString();
34-
String title = value.value( "title" ).asString();
35-
String description = value.value( "description" ).asString();
33+
String code = value.get( "code" ).asString();
34+
String title = value.get( "title" ).asString();
35+
String description = value.get( "description" ).asString();
3636

37-
Value posValue = value.value( "position" );
37+
Value posValue = value.get( "position" );
3838
InputPosition position = null;
3939
if( posValue != null )
4040
{
41-
position = new InternalInputPosition( posValue.value( "offset" ).asInt(),
42-
posValue.value( "line" ).asInt(),
43-
posValue.value( "column" ).asInt() );
41+
position = new InternalInputPosition( posValue.get( "offset" ).asInt(),
42+
posValue.get( "line" ).asInt(),
43+
posValue.get( "column" ).asInt() );
4444
}
4545

4646
return new InternalNotification( code, title, description, position );

driver/src/main/java/org/neo4j/driver/internal/summary/InternalPlan.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,19 +161,19 @@ public Converter( PlanCreator<T> planCreator )
161161
@Override
162162
public T apply( Value plan )
163163
{
164-
final String operatorType = plan.value( "operatorType" ).asString();
164+
final String operatorType = plan.get( "operatorType" ).asString();
165165

166-
final Value argumentsValue = plan.value( "args" );
166+
final Value argumentsValue = plan.get( "args" );
167167
final Map<String, Value> arguments = argumentsValue.isNull()
168168
? Collections.<String, Value>emptyMap()
169169
: argumentsValue.asMap( valueAsIs() );
170170

171-
final Value identifiersValue = plan.value( "identifiers" );
171+
final Value identifiersValue = plan.get( "identifiers" );
172172
final List<String> identifiers = identifiersValue.isNull()
173173
? Collections.<String>emptyList()
174174
: identifiersValue.asList( valueAsString() );
175175

176-
final Value childrenValue = plan.value( "children" );
176+
final Value childrenValue = plan.get( "children" );
177177
final List<T> children = childrenValue.isNull()
178178
? Collections.<T>emptyList()
179179
: childrenValue.asList( this );

driver/src/main/java/org/neo4j/driver/internal/summary/InternalProfiledPlan.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ public long records()
5656
public ProfiledPlan create( String operatorType, Map<String,Value> arguments, List<String> identifiers, List<ProfiledPlan> children, Value originalPlanValue )
5757
{
5858
return new InternalProfiledPlan( operatorType, arguments, identifiers, children,
59-
originalPlanValue.value( "dbHits" ).asLong(),
60-
originalPlanValue.value( "rows" ).asLong() );
59+
originalPlanValue.get( "dbHits" ).asLong(),
60+
originalPlanValue.get( "rows" ).asLong() );
6161
}
6262
};
6363

driver/src/main/java/org/neo4j/driver/internal/util/Extract.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,14 @@ public static <T> Map<String, T> map( RecordAccessor record, Function<Value, T>
121121
return emptyMap();
122122

123123
case 1:
124-
return singletonMap( record.keys().get( 0 ), mapFunction.apply( record.value( 0 ) ) );
124+
return singletonMap( record.keys().get( 0 ), mapFunction.apply( record.get( 0 ) ) );
125125

126126
default:
127127
Map<String, T> map = new HashMap<>( size );
128128
List<String> keys = record.keys();
129129
for ( int i = 0; i < size; i++ )
130130
{
131-
map.put( keys.get( i ), mapFunction.apply( record.value( i ) ) );
131+
map.put( keys.get( i ), mapFunction.apply( record.get( i ) ) );
132132
}
133133
return unmodifiableMap( map );
134134
}
@@ -145,7 +145,7 @@ public static <V> Iterable<Pair<String, V>> properties( final MapAccessor map, f
145145
case 1:
146146
{
147147
String key = map.keys().iterator().next();
148-
Value value = map.value( key );
148+
Value value = map.get( key );
149149
return singletonList( InternalPair.of( key, mapFunction.apply( value ) ) );
150150
}
151151

@@ -154,7 +154,7 @@ public static <V> Iterable<Pair<String, V>> properties( final MapAccessor map, f
154154
List<Pair<String, V>> list = new ArrayList<>( size );
155155
for ( String key : map.keys() )
156156
{
157-
Value value = map.value( key );
157+
Value value = map.get( key );
158158
list.add( InternalPair.of( key, mapFunction.apply( value ) ) );
159159
}
160160
return unmodifiableList( list );
@@ -173,7 +173,7 @@ public static <V> List<Pair<String, V>> fields( final RecordAccessor map, final
173173
case 1:
174174
{
175175
String key = map.keys().iterator().next();
176-
Value value = map.value( key );
176+
Value value = map.get( key );
177177
return singletonList( InternalPair.of( key, mapFunction.apply( value ) ) );
178178
}
179179

@@ -184,7 +184,7 @@ public static <V> List<Pair<String, V>> fields( final RecordAccessor map, final
184184
for ( int i = 0; i < size; i++ )
185185
{
186186
String key = keys.get( i );
187-
Value value = map.value( i );
187+
Value value = map.get( i );
188188
list.add( InternalPair.of( key, mapFunction.apply( value ) ) );
189189
}
190190
return unmodifiableList( list );

driver/src/main/java/org/neo4j/driver/internal/value/EntityValueAdapter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ public Iterable<String> keys()
4646
}
4747

4848
@Override
49-
public Value value( String key )
49+
public Value get( String key )
5050
{
51-
return asEntity().value( key );
51+
return asEntity().get( key );
5252
}
5353
}

driver/src/main/java/org/neo4j/driver/internal/value/ListValue.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public int size()
166166
}
167167

168168
@Override
169-
public Value value( int index )
169+
public Value get( int index )
170170
{
171171
return index >= 0 && index < values.length ? values[index] : Values.NULL;
172172
}

driver/src/main/java/org/neo4j/driver/internal/value/MapValue.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public <T> Iterable<T> values( Function<Value, T> mapFunction )
9999
}
100100

101101
@Override
102-
public Value value( String key )
102+
public Value get( String key )
103103
{
104104
Value value = val.get( key );
105105
return value == null ? Values.NULL: value;

driver/src/main/java/org/neo4j/driver/internal/value/ValueAdapter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,13 +260,13 @@ public Relationship asRelationship()
260260
}
261261

262262
@Override
263-
public Value value( int index )
263+
public Value get( int index )
264264
{
265265
throw new NotMultiValued( type().name() + " is not an indexed collection" );
266266
}
267267

268268
@Override
269-
public Value value( String key )
269+
public Value get( String key )
270270
{
271271
throw new NotMultiValued( type().name() + " is not a keyed collection" );
272272
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package org.neo4j.driver.v1;
2+
3+
import java.lang.annotation.Documented;
4+
import java.lang.annotation.ElementType;
5+
import java.lang.annotation.Inherited;
6+
import java.lang.annotation.Retention;
7+
import java.lang.annotation.RetentionPolicy;
8+
import java.lang.annotation.Target;
9+
10+
/**
11+
* This is a marker interface highlighting an API component that is experimental. API parts annotated with this do not fall under the normal guarantees
12+
* for backwards compatibility - they may change or be removed in any future release. Components marked with this interface are included and documented in
13+
* order to receive your feedback, please do try these experimental features out and share your thoughts on them.
14+
*/
15+
@Inherited
16+
@Documented
17+
@Retention( RetentionPolicy.RUNTIME)
18+
@Target( { ElementType.TYPE, ElementType.METHOD } )
19+
public @interface Experimental
20+
{
21+
}

driver/src/main/java/org/neo4j/driver/v1/ListAccessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public interface ListAccessor
3737
* @return the value or a {@link org.neo4j.driver.internal.value.NullValue} if the index is out of bounds
3838
* @throws ClientException if record has not been initialized
3939
*/
40-
Value value( int index );
40+
Value get( int index );
4141

4242
/**
4343
* Retrieve the number of elements in this list

driver/src/main/java/org/neo4j/driver/v1/MapAccessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public interface MapAccessor
5151
* @return the property's value or a {@link NullValue} if no such key exists
5252
* @throws ClientException if record has not been initialized
5353
*/
54-
Value value( String key );
54+
Value get( String key );
5555

5656
/**
5757
* Retrieve the number of entries in this map

driver/src/main/java/org/neo4j/driver/v1/Record.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* A record is an immutable copy of an ordered map
2525
*
2626
* @see ResultCursor#record()
27-
* @see ResultCursor#retain()
27+
* @see ResultCursor#list()
2828
*/
2929
@Immutable
3030
public interface Record extends RecordAccessor

driver/src/main/java/org/neo4j/driver/v1/RecordAccessor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public interface RecordAccessor extends ListAccessor
5353
*
5454
* @throws java.util.NoSuchElementException if the given key is not from {@link #keys()}
5555
* @param key the give key
56-
* @return the index of the field as used by {@link #value(int)}
56+
* @return the index of the field as used by {@link #get(int)}
5757
*/
5858
int index( String key );
5959

@@ -64,7 +64,7 @@ public interface RecordAccessor extends ListAccessor
6464
* @return the property's value or a {@link NullValue} if no such key exists
6565
* @throws NoRecordException if the associated underlying record is not available
6666
*/
67-
Value value( String key );
67+
Value get( String key );
6868

6969
/**
7070
* Retrieve the number of fields in this record

driver/src/main/java/org/neo4j/driver/v1/Records.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
/**
2222
* Static utility methods for retaining records
2323
*
24-
* @see ResultCursor#retain()
24+
* @see ResultCursor#list()
2525
*/
2626
public abstract class Records
2727
{
@@ -52,7 +52,7 @@ public static <T> Function<RecordAccessor, T> column( final int index, final Fun
5252
@Override
5353
public T apply( RecordAccessor recordAccessor )
5454
{
55-
return mapFunction.apply( recordAccessor.value( index ) );
55+
return mapFunction.apply( recordAccessor.get( index ) );
5656
}
5757
};
5858
}
@@ -63,7 +63,7 @@ public static <T> Function<RecordAccessor, T> column( final String key, final Fu
6363
@Override
6464
public T apply( RecordAccessor recordAccessor )
6565
{
66-
return mapFunction.apply( recordAccessor.value( key ) );
66+
return mapFunction.apply( recordAccessor.get( key ) );
6767
}
6868
};
6969
}

0 commit comments

Comments
 (0)