Skip to content

Commit 37bc83e

Browse files
authored
feat(vector): add Value#asVector() (#1701)
1 parent 4dc7edf commit 37bc83e

File tree

4 files changed

+26
-0
lines changed

4 files changed

+26
-0
lines changed

driver/clirr-ignored-differences.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -947,4 +947,10 @@
947947
<method>org.neo4j.driver.types.UnsupportedType asUnsupportedType()</method>
948948
</difference>
949949

950+
<difference>
951+
<className>org/neo4j/driver/Value</className>
952+
<differenceType>7012</differenceType>
953+
<method>org.neo4j.driver.types.Vector asVector()</method>
954+
</difference>
955+
950956
</differences>

driver/src/main/java/org/neo4j/driver/Value.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,16 @@ public interface Value extends MapAccessor, MapAccessorWithDefaultValue {
496496
*/
497497
Point asPoint();
498498

499+
/**
500+
* Returns the value as an {@link Vector}, if possible.
501+
*
502+
* @return the value as a {@link Vector}, if possible
503+
* @throws Uncoercible if value types are incompatible
504+
* @since 6.0.0
505+
*/
506+
@Preview(name = "Neo4j Vector")
507+
Vector asVector();
508+
499509
/**
500510
* Returns the value as an {@link UnsupportedType}, if possible.
501511
*

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,11 @@ public Point asPoint() {
306306
throw new Uncoercible(type().name(), "Point");
307307
}
308308

309+
@Override
310+
public org.neo4j.driver.types.Vector asVector() {
311+
throw new Uncoercible(type().name(), "Vector");
312+
}
313+
309314
@Override
310315
public UnsupportedType asUnsupportedType() {
311316
throw new Uncoercible(type().name(), "UnsupportedType");

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ public org.neo4j.bolt.connection.values.Type boltValueType() {
4242
return org.neo4j.bolt.connection.values.Type.VECTOR;
4343
}
4444

45+
@Override
46+
public Vector asVector() {
47+
return asObject();
48+
}
49+
4550
@Override
4651
public <T> T as(Class<T> targetClass) {
4752
if (targetClass.isAssignableFrom(Int8Vector.class)

0 commit comments

Comments
 (0)