Skip to content

Commit 07f7e3c

Browse files
committed
To record
1 parent 6d2dfa2 commit 07f7e3c

36 files changed

+83
-556
lines changed

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

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -34,31 +34,7 @@
3434
* {@link Path} implementation that directly contains all nodes and relationships.
3535
*/
3636
public class InternalPath implements Path, AsValue {
37-
public static class SelfContainedSegment implements Segment {
38-
private final Node start;
39-
private final Relationship relationship;
40-
private final Node end;
41-
42-
public SelfContainedSegment(Node start, Relationship relationship, Node end) {
43-
this.start = start;
44-
this.relationship = relationship;
45-
this.end = end;
46-
}
47-
48-
@Override
49-
public Node start() {
50-
return start;
51-
}
52-
53-
@Override
54-
public Relationship relationship() {
55-
return relationship;
56-
}
57-
58-
@Override
59-
public Node end() {
60-
return end;
61-
}
37+
public record SelfContainedSegment(Node start, Relationship relationship, Node end) implements Segment {
6238

6339
@Override
6440
public boolean equals(Object other) {
@@ -73,14 +49,6 @@ public boolean equals(Object other) {
7349
return start.equals(that.start) && end.equals(that.end) && relationship.equals(that.relationship);
7450
}
7551

76-
@Override
77-
public int hashCode() {
78-
var result = start.hashCode();
79-
result = 31 * result + relationship.hashCode();
80-
result = 31 * result + end.hashCode();
81-
return result;
82-
}
83-
8452
@Override
8553
@SuppressWarnings("deprecation")
8654
public String toString() {

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

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,34 +18,9 @@
1818
*/
1919
package org.neo4j.driver.internal;
2020

21-
import java.util.Objects;
2221
import org.neo4j.driver.types.Point;
2322

24-
public class InternalPoint2D implements Point {
25-
private final int srid;
26-
private final double x;
27-
private final double y;
28-
29-
public InternalPoint2D(int srid, double x, double y) {
30-
this.srid = srid;
31-
this.x = x;
32-
this.y = y;
33-
}
34-
35-
@Override
36-
public int srid() {
37-
return srid;
38-
}
39-
40-
@Override
41-
public double x() {
42-
return x;
43-
}
44-
45-
@Override
46-
public double y() {
47-
return y;
48-
}
23+
public record InternalPoint2D(int srid, double x, double y) implements Point {
4924

5025
@Override
5126
public double z() {
@@ -64,11 +39,6 @@ public boolean equals(Object o) {
6439
return srid == that.srid && Double.compare(that.x, x) == 0 && Double.compare(that.y, y) == 0;
6540
}
6641

67-
@Override
68-
public int hashCode() {
69-
return Objects.hash(srid, x, y);
70-
}
71-
7242
@Override
7343
public String toString() {
7444
return "Point{" + "srid=" + srid + ", x=" + x + ", y=" + y + '}';

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

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -18,41 +18,9 @@
1818
*/
1919
package org.neo4j.driver.internal;
2020

21-
import java.util.Objects;
2221
import org.neo4j.driver.types.Point;
2322

24-
public class InternalPoint3D implements Point {
25-
private final int srid;
26-
private final double x;
27-
private final double y;
28-
private final double z;
29-
30-
public InternalPoint3D(int srid, double x, double y, double z) {
31-
this.srid = srid;
32-
this.x = x;
33-
this.y = y;
34-
this.z = z;
35-
}
36-
37-
@Override
38-
public int srid() {
39-
return srid;
40-
}
41-
42-
@Override
43-
public double x() {
44-
return x;
45-
}
46-
47-
@Override
48-
public double y() {
49-
return y;
50-
}
51-
52-
@Override
53-
public double z() {
54-
return z;
55-
}
23+
public record InternalPoint3D(int srid, double x, double y, double z) implements Point {
5624

5725
@Override
5826
public boolean equals(Object o) {
@@ -69,11 +37,6 @@ public boolean equals(Object o) {
6937
&& Double.compare(that.z, z) == 0;
7038
}
7139

72-
@Override
73-
public int hashCode() {
74-
return Objects.hash(srid, x, y, z);
75-
}
76-
7740
@Override
7841
public String toString() {
7942
return "Point{" + "srid=" + srid + ", x=" + x + ", y=" + y + ", z=" + z + '}';

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

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,18 @@
2121
import java.io.Serializable;
2222
import org.neo4j.driver.Config;
2323

24-
public class SecuritySettings implements Serializable {
24+
public record SecuritySettings(boolean encrypted, Config.TrustStrategy trustStrategy) implements Serializable {
2525
private static final long serialVersionUID = 4494615367164106576L;
2626

2727
private static final boolean DEFAULT_ENCRYPTED = false;
2828
private static final Config.TrustStrategy DEFAULT_TRUST_STRATEGY = Config.TrustStrategy.trustSystemCertificates();
2929
public static final SecuritySettings DEFAULT = new SecuritySettings(DEFAULT_ENCRYPTED, DEFAULT_TRUST_STRATEGY);
30-
private final boolean encrypted;
31-
private final Config.TrustStrategy trustStrategy;
3230

3331
public SecuritySettings(boolean encrypted, Config.TrustStrategy trustStrategy) {
3432
this.encrypted = encrypted;
3533
this.trustStrategy = trustStrategy == null ? DEFAULT_TRUST_STRATEGY : trustStrategy;
3634
}
3735

38-
public boolean encrypted() {
39-
return encrypted;
40-
}
41-
42-
public Config.TrustStrategy trustStrategy() {
43-
return trustStrategy;
44-
}
45-
4636
public static class SecuritySettingsBuilder {
4737
private boolean isCustomized = false;
4838
private boolean encrypted;

driver/src/main/java/org/neo4j/driver/internal/async/pool/PoolSettings.java

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -20,51 +20,23 @@
2020

2121
import java.util.concurrent.TimeUnit;
2222

23-
public class PoolSettings {
23+
public record PoolSettings(
24+
int maxConnectionPoolSize,
25+
long connectionAcquisitionTimeout,
26+
long maxConnectionLifetime,
27+
long idleTimeBeforeConnectionTest) {
2428
public static final int NOT_CONFIGURED = -1;
2529

2630
public static final int DEFAULT_MAX_CONNECTION_POOL_SIZE = 100;
2731
public static final long DEFAULT_IDLE_TIME_BEFORE_CONNECTION_TEST = NOT_CONFIGURED;
2832
public static final long DEFAULT_MAX_CONNECTION_LIFETIME = TimeUnit.HOURS.toMillis(1);
2933
public static final long DEFAULT_CONNECTION_ACQUISITION_TIMEOUT = TimeUnit.SECONDS.toMillis(60);
3034

31-
private final int maxConnectionPoolSize;
32-
private final long connectionAcquisitionTimeout;
33-
private final long maxConnectionLifetime;
34-
private final long idleTimeBeforeConnectionTest;
35-
36-
public PoolSettings(
37-
int maxConnectionPoolSize,
38-
long connectionAcquisitionTimeout,
39-
long maxConnectionLifetime,
40-
long idleTimeBeforeConnectionTest) {
41-
this.maxConnectionPoolSize = maxConnectionPoolSize;
42-
this.connectionAcquisitionTimeout = connectionAcquisitionTimeout;
43-
this.maxConnectionLifetime = maxConnectionLifetime;
44-
this.idleTimeBeforeConnectionTest = idleTimeBeforeConnectionTest;
45-
}
46-
47-
public long idleTimeBeforeConnectionTest() {
48-
return idleTimeBeforeConnectionTest;
49-
}
50-
5135
public boolean idleTimeBeforeConnectionTestEnabled() {
5236
return idleTimeBeforeConnectionTest >= 0;
5337
}
5438

55-
public long maxConnectionLifetime() {
56-
return maxConnectionLifetime;
57-
}
58-
5939
public boolean maxConnectionLifetimeEnabled() {
6040
return maxConnectionLifetime > 0;
6141
}
62-
63-
public int maxConnectionPoolSize() {
64-
return maxConnectionPoolSize;
65-
}
66-
67-
public long connectionAcquisitionTimeout() {
68-
return connectionAcquisitionTimeout;
69-
}
7042
}

driver/src/main/java/org/neo4j/driver/internal/cluster/RoutingTableRegistryImpl.java

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ public RoutingTableRegistryImpl(
8686
@Override
8787
public CompletionStage<RoutingTableHandler> ensureRoutingTable(ConnectionContext context) {
8888
return ensureDatabaseNameIsCompleted(context).thenCompose(ctxAndHandler -> {
89-
var completedContext = ctxAndHandler.getContext();
90-
var handler = ctxAndHandler.getHandler() != null
91-
? ctxAndHandler.getHandler()
89+
var completedContext = ctxAndHandler.context();
90+
var handler = ctxAndHandler.handler() != null
91+
? ctxAndHandler.handler()
9292
: getOrCreate(Futures.joinNowOrElseThrow(
9393
completedContext.databaseNameFuture(), PENDING_DATABASE_NAME_EXCEPTION_SUPPLIER));
9494
return handler.ensureRoutingTable(completedContext).thenApply(ignored -> handler);
@@ -235,12 +235,7 @@ RoutingTableHandler newInstance(DatabaseName databaseName, RoutingTableRegistry
235235
}
236236
}
237237

238-
private static class Principal {
239-
private final String id;
240-
241-
private Principal(String id) {
242-
this.id = id;
243-
}
238+
private record Principal(String id) {
244239

245240
@Override
246241
public boolean equals(Object o) {
@@ -253,28 +248,7 @@ public boolean equals(Object o) {
253248
var principal = (Principal) o;
254249
return Objects.equals(id, principal.id);
255250
}
256-
257-
@Override
258-
public int hashCode() {
259-
return Objects.hash(id);
260-
}
261251
}
262252

263-
private static class ConnectionContextAndHandler {
264-
private final ConnectionContext context;
265-
private final RoutingTableHandler handler;
266-
267-
private ConnectionContextAndHandler(ConnectionContext context, RoutingTableHandler handler) {
268-
this.context = context;
269-
this.handler = handler;
270-
}
271-
272-
public ConnectionContext getContext() {
273-
return context;
274-
}
275-
276-
public RoutingTableHandler getHandler() {
277-
return handler;
278-
}
279-
}
253+
private record ConnectionContextAndHandler(ConnectionContext context, RoutingTableHandler handler) {}
280254
}

driver/src/main/java/org/neo4j/driver/internal/messaging/encode/RouteMessageEncoder.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ public void encode(Message message, ValuePacker packer) throws IOException {
3737
checkArgument(message, RouteMessage.class);
3838
var routeMessage = (RouteMessage) message;
3939
packer.packStructHeader(3, message.signature());
40-
packer.pack(routeMessage.getRoutingContext());
41-
packer.pack(value(routeMessage.getBookmarks().stream().map(Bookmark::value)));
42-
packer.pack(routeMessage.getDatabaseName());
40+
packer.pack(routeMessage.routingContext());
41+
packer.pack(value(routeMessage.bookmarks().stream().map(Bookmark::value)));
42+
packer.pack(routeMessage.databaseName());
4343
}
4444
}

driver/src/main/java/org/neo4j/driver/internal/messaging/encode/RouteV44MessageEncoder.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ public void encode(Message message, ValuePacker packer) throws IOException {
4040
checkArgument(message, RouteMessage.class);
4141
var routeMessage = (RouteMessage) message;
4242
packer.packStructHeader(3, message.signature());
43-
packer.pack(routeMessage.getRoutingContext());
44-
packer.pack(value(routeMessage.getBookmarks().stream().map(Bookmark::value)));
43+
packer.pack(routeMessage.routingContext());
44+
packer.pack(value(routeMessage.bookmarks().stream().map(Bookmark::value)));
4545

4646
Map<String, Value> params;
47-
if (routeMessage.getImpersonatedUser() != null && routeMessage.getDatabaseName() == null) {
48-
params = Collections.singletonMap("imp_user", value(routeMessage.getImpersonatedUser()));
49-
} else if (routeMessage.getDatabaseName() != null) {
50-
params = Collections.singletonMap("db", value(routeMessage.getDatabaseName()));
47+
if (routeMessage.impersonatedUser() != null && routeMessage.databaseName() == null) {
48+
params = Collections.singletonMap("imp_user", value(routeMessage.impersonatedUser()));
49+
} else if (routeMessage.databaseName() != null) {
50+
params = Collections.singletonMap("db", value(routeMessage.databaseName()));
5151
} else {
5252
params = Collections.emptyMap();
5353
}

driver/src/main/java/org/neo4j/driver/internal/messaging/request/RouteMessage.java

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,10 @@
3333
* <p>
3434
* This message is used to fetch this routing information.
3535
*/
36-
public class RouteMessage implements Message {
36+
public record RouteMessage(
37+
Map<String, Value> routingContext, Set<Bookmark> bookmarks, String databaseName, String impersonatedUser)
38+
implements Message {
3739
public static final byte SIGNATURE = 0x66;
38-
private final Map<String, Value> routingContext;
39-
private final Set<Bookmark> bookmarks;
40-
private final String databaseName;
41-
private final String impersonatedUser;
4240

4341
/**
4442
* Constructor
@@ -56,22 +54,6 @@ public RouteMessage(
5654
this.impersonatedUser = impersonatedUser;
5755
}
5856

59-
public Map<String, Value> getRoutingContext() {
60-
return routingContext;
61-
}
62-
63-
public Set<Bookmark> getBookmarks() {
64-
return bookmarks;
65-
}
66-
67-
public String getDatabaseName() {
68-
return databaseName;
69-
}
70-
71-
public String getImpersonatedUser() {
72-
return impersonatedUser;
73-
}
74-
7557
@Override
7658
public byte signature() {
7759
return SIGNATURE;

0 commit comments

Comments
 (0)