diff --git a/driver/clirr-ignored-differences.xml b/driver/clirr-ignored-differences.xml index 9b77f32b46..eb8afa58f3 100644 --- a/driver/clirr-ignored-differences.xml +++ b/driver/clirr-ignored-differences.xml @@ -43,4 +43,16 @@ org.reactivestreams.Publisher close() + + org/neo4j/driver/Record + 7012 + java.lang.Iterable keys() + + + + org/neo4j/driver/Record + 7012 + java.lang.Iterable values() + + diff --git a/driver/src/main/java/org/neo4j/driver/Record.java b/driver/src/main/java/org/neo4j/driver/Record.java index 63251be2ba..204c766a8c 100644 --- a/driver/src/main/java/org/neo4j/driver/Record.java +++ b/driver/src/main/java/org/neo4j/driver/Record.java @@ -19,13 +19,10 @@ package org.neo4j.driver; import java.util.List; -import java.util.Map; -import org.neo4j.driver.internal.value.NullValue; import org.neo4j.driver.exceptions.ClientException; import org.neo4j.driver.exceptions.NoSuchRecordException; import org.neo4j.driver.types.MapAccessorWithDefaultValue; -import java.util.function.Function; import org.neo4j.driver.util.Immutable; import org.neo4j.driver.util.Pair; @@ -49,6 +46,7 @@ public interface Record extends MapAccessorWithDefaultValue * * @return all field keys in order */ + @Override List keys(); /** @@ -56,16 +54,9 @@ public interface Record extends MapAccessorWithDefaultValue * * @return all field keys in order */ + @Override List values(); - /** - * Check if the list of keys contains the given key - * - * @param key the key - * @return {@code true} if this map keys contains the given key otherwise {@code false} - */ - boolean containsKey( String key ); - /** * Retrieve the index of the field with the given key * @@ -75,15 +66,6 @@ public interface Record extends MapAccessorWithDefaultValue */ int index( String key ); - /** - * Retrieve the value of the property with the given key - * - * @param key the key of the property - * @return the property's value or a {@link NullValue} if no such key exists - * @throws NoSuchRecordException if the associated underlying record is not available - */ - Value get( String key ); - /** * Retrieve the value at the given field index * @@ -93,34 +75,6 @@ public interface Record extends MapAccessorWithDefaultValue */ Value get( int index ); - /** - * Retrieve the number of fields in this record - * - * @return the number of fields in this record - */ - int size(); - - /** - * Return this record as a map, where each value has been converted to a default - * java object using {@link Value#asObject()}. - * - * This is equivalent to calling {@link #asMap(Function)} with {@link Values#ofObject()}. - * - * @return this record as a map - */ - Map asMap(); - - /** - * Return this record as a map, where each value has been converted using the provided - * mapping function. You can find a library of common mapping functions in {@link Values}. - * - * @see Values for a long list of built-in conversion functions - * @param mapper the mapping function - * @param the type to convert to - * @return this record as a map - */ - Map asMap( Function mapper ); - /** * Retrieve all record fields * @@ -128,5 +82,4 @@ public interface Record extends MapAccessorWithDefaultValue * @throws NoSuchRecordException if the associated underlying record is not available */ List> fields(); - } diff --git a/driver/src/main/java/org/neo4j/driver/internal/InternalRecord.java b/driver/src/main/java/org/neo4j/driver/internal/InternalRecord.java index e189de4ee8..f5d8dce69c 100644 --- a/driver/src/main/java/org/neo4j/driver/internal/InternalRecord.java +++ b/driver/src/main/java/org/neo4j/driver/internal/InternalRecord.java @@ -23,6 +23,7 @@ import java.util.Map; import java.util.NoSuchElementException; import java.util.function.Function; +import java.util.stream.Collectors; import org.neo4j.driver.Record; import org.neo4j.driver.Value; @@ -68,7 +69,13 @@ public List values() } @Override - public List> fields() + public Iterable values( Function mapFunction ) + { + return values().stream().map( mapFunction ).collect( Collectors.toList() ); + } + + @Override + public List> fields() { return Extract.fields( this, ofValue() ); } diff --git a/driver/src/main/java/org/neo4j/driver/types/MapAccessorWithDefaultValue.java b/driver/src/main/java/org/neo4j/driver/types/MapAccessorWithDefaultValue.java index 4469e09727..84df2eebec 100644 --- a/driver/src/main/java/org/neo4j/driver/types/MapAccessorWithDefaultValue.java +++ b/driver/src/main/java/org/neo4j/driver/types/MapAccessorWithDefaultValue.java @@ -20,19 +20,17 @@ import java.util.List; import java.util.Map; +import java.util.function.Function; import org.neo4j.driver.Value; -import java.util.function.Function; /** - * Provides methods to access the value of an underlying unordered map by key. - * When calling the methods, a user need to provides a default value, which will be given back if no match found by - * the key provided. - * The default value also servers the purpose of specifying the return type of the value found in map by key. - * If the type of the value found A differs from the type of the default value B, a cast from A to B would happen - * automatically. Note: Error might arise if the cast from A to B is not possible. + * Provides methods to access the value of an underlying unordered map by key. When calling the methods, a user need to provides a default value, which will be + * given back if no match found by the key provided. The default value also servers the purpose of specifying the return type of the value found in map by key. + * If the type of the value found A differs from the type of the default value B, a cast from A to B would happen automatically. Note: Error might arise if the + * cast from A to B is not possible. */ -public interface MapAccessorWithDefaultValue +public interface MapAccessorWithDefaultValue extends MapAccessor { /** * Retrieve the value with the given key.