Skip to content

Commit 4b0052d

Browse files
committed
Rename #value -> #get, cut back on Values conversion method.
1 parent 678f51f commit 4b0052d

Some content is hidden

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

49 files changed

+159
-601
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 & 10 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
}
@@ -101,12 +101,6 @@ public int size()
101101
return values.length;
102102
}
103103

104-
@Override
105-
public boolean hasRecord()
106-
{
107-
return true;
108-
}
109-
110104
@Override
111105
public Record record()
112106
{
@@ -145,8 +139,8 @@ else if ( other instanceof Record )
145139
}
146140
for ( int i = 0; i < size; i++ )
147141
{
148-
Value value = value( i );
149-
Value otherValue = otherRecord.value( i );
142+
Value value = get( i );
143+
Value otherValue = otherRecord.get( i );
150144
if ( ! value.equals( otherValue ) )
151145
{
152146
return false;

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

Lines changed: 7 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import java.util.List;
2323

2424
import org.neo4j.driver.v1.Function;
25-
import org.neo4j.driver.v1.Pair;
2625
import org.neo4j.driver.v1.Record;
2726
import org.neo4j.driver.v1.RecordAccessor;
2827
import org.neo4j.driver.v1.ResultCursor;
@@ -33,7 +32,6 @@
3332

3433
import static java.lang.String.format;
3534
import static java.util.Collections.emptyList;
36-
3735
import static org.neo4j.driver.v1.Records.recordAsIs;
3836

3937
public class InternalResultCursor extends InternalRecordAccessor implements ResultCursor
@@ -60,14 +58,14 @@ public boolean isOpen()
6058
return open;
6159
}
6260

63-
public Value value( int index )
61+
public Value get( int index )
6462
{
65-
return record().value( index );
63+
return record().get( index );
6664
}
6765

68-
public Value value( String key )
66+
public Value get( String key )
6967
{
70-
return record().value( key );
68+
return record().get( key );
7169
}
7270

7371
@Override
@@ -93,17 +91,10 @@ public int size()
9391
return keys.size();
9492
}
9593

96-
@Override
97-
public boolean hasRecord()
98-
{
99-
assertOpen();
100-
return current != null && current.hasRecord();
101-
}
102-
10394
@Override
10495
public Record record()
10596
{
106-
if ( hasRecord() )
97+
if ( current != null )
10798
{
10899
return current;
109100
}
@@ -198,9 +189,9 @@ public boolean single()
198189
}
199190

200191
@Override
201-
public RecordAccessor peek()
192+
public Record peek()
202193
{
203-
return new PeekingRecordAccessor();
194+
return iter.peek();
204195
}
205196

206197
@Override
@@ -276,69 +267,4 @@ private void discard()
276267
{
277268
iter.discard();
278269
}
279-
280-
private class PeekingRecordAccessor implements RecordAccessor
281-
{
282-
@Override
283-
public List<String> keys()
284-
{
285-
return InternalResultCursor.this.keys();
286-
}
287-
288-
@Override
289-
public boolean containsKey( String key )
290-
{
291-
return InternalResultCursor.this.containsKey( key );
292-
}
293-
294-
@Override
295-
public int index( String key )
296-
{
297-
return InternalResultCursor.this.index( key );
298-
}
299-
300-
@Override
301-
public Value value( String key )
302-
{
303-
return record().value( key );
304-
}
305-
306-
@Override
307-
public int size()
308-
{
309-
return InternalResultCursor.this.size();
310-
}
311-
312-
@Override
313-
public List<Pair<String, Value>> fields()
314-
{
315-
return record().fields();
316-
}
317-
318-
@Override
319-
public boolean hasRecord()
320-
{
321-
return iter.hasNext();
322-
}
323-
324-
@Override
325-
public Record record()
326-
{
327-
Record record = iter.peek();
328-
if ( record == null )
329-
{
330-
throw new NoRecordException( "Cannot peek past last record" );
331-
}
332-
else
333-
{
334-
return record;
335-
}
336-
}
337-
338-
@Override
339-
public Value value( int index )
340-
{
341-
return record().value( index );
342-
}
343-
}
344270
}

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

@@ -373,7 +373,7 @@ private void packProperties( Entity entity ) throws IOException
373373
for ( String propKey : keys )
374374
{
375375
packer.pack( propKey );
376-
packValue( entity.value( propKey ) );
376+
packValue( entity.get( propKey ) );
377377
}
378378
}
379379
}

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/InternalValue.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
public interface InternalValue extends Value, AsValue
2727
{
2828
TypeConstructor typeConstructor();
29+
2930
String toString( Format valueFormat );
3031

3132
enum Format implements Function<Value, String>

0 commit comments

Comments
 (0)