From 11c68cba033e50057c99d40ea55b05cd2abe604c Mon Sep 17 00:00:00 2001 From: Dmitriy Tverdiakov <11927660+injectives@users.noreply.github.com> Date: Thu, 23 Feb 2023 13:46:04 +0000 Subject: [PATCH] Improve Javadoc (#1382) This update also enables failures on warnings for public Javadoc. --- driver/src/main/java/module-info.java | 3 + .../neo4j/driver/BookmarkManagerConfig.java | 4 + .../main/java/org/neo4j/driver/Config.java | 86 ++++++++ .../java/org/neo4j/driver/QueryConfig.java | 15 ++ .../main/java/org/neo4j/driver/Records.java | 24 +++ .../driver/RevocationCheckingStrategy.java | 5 + .../java/org/neo4j/driver/SessionConfig.java | 22 ++ .../org/neo4j/driver/TransactionConfig.java | 6 + .../main/java/org/neo4j/driver/Values.java | 196 +++++++++++++++++- .../exceptions/AuthenticationException.java | 5 + .../AuthorizationExpiredException.java | 8 + .../driver/exceptions/ClientException.java | 14 ++ .../ConnectionReadTimeoutException.java | 9 + .../driver/exceptions/DatabaseException.java | 5 + .../driver/exceptions/DiscoveryException.java | 5 + .../exceptions/FatalDiscoveryException.java | 9 + .../driver/exceptions/Neo4jException.java | 23 ++ .../exceptions/NoSuchRecordException.java | 4 + .../driver/exceptions/ProtocolException.java | 9 + .../exceptions/ResultConsumedException.java | 4 + .../driver/exceptions/SecurityException.java | 10 + .../ServiceUnavailableException.java | 9 + .../exceptions/SessionExpiredException.java | 9 + .../exceptions/TokenExpiredException.java | 5 + .../TransactionNestingException.java | 4 + .../driver/exceptions/TransientException.java | 5 + .../exceptions/UntrustedServerException.java | 4 + .../exceptions/value/LossyCoercion.java | 5 + .../exceptions/value/NotMultiValued.java | 4 + .../driver/exceptions/value/Uncoercible.java | 5 + .../driver/exceptions/value/Unsizable.java | 4 + .../exceptions/value/ValueException.java | 4 + .../internal/packstream/PackStream.java | 2 +- .../neo4j/driver/reactive/RxQueryRunner.java | 10 + .../org/neo4j/driver/summary/QueryType.java | 38 +++- .../org/neo4j/driver/types/TypeSystem.java | 80 +++++++ pom.xml | 4 + 37 files changed, 650 insertions(+), 8 deletions(-) diff --git a/driver/src/main/java/module-info.java b/driver/src/main/java/module-info.java index 51c7453da9..579f0f447d 100644 --- a/driver/src/main/java/module-info.java +++ b/driver/src/main/java/module-info.java @@ -16,6 +16,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +/** + * The Neo4j Java Driver module. + */ @SuppressWarnings({"requires-automatic", "requires-transitive-automatic"}) module org.neo4j.driver { exports org.neo4j.driver; diff --git a/driver/src/main/java/org/neo4j/driver/BookmarkManagerConfig.java b/driver/src/main/java/org/neo4j/driver/BookmarkManagerConfig.java index 3704115493..170692c180 100644 --- a/driver/src/main/java/org/neo4j/driver/BookmarkManagerConfig.java +++ b/driver/src/main/java/org/neo4j/driver/BookmarkManagerConfig.java @@ -126,6 +126,10 @@ public BookmarkManagerConfigBuilder withBookmarksSupplier(Supplier return this; } + /** + * Builds an instance of {@link BookmarkManagerConfig}. + * @return the config + */ public BookmarkManagerConfig build() { return new BookmarkManagerConfig(this); } diff --git a/driver/src/main/java/org/neo4j/driver/Config.java b/driver/src/main/java/org/neo4j/driver/Config.java index d3ff7c3c25..11255f7822 100644 --- a/driver/src/main/java/org/neo4j/driver/Config.java +++ b/driver/src/main/java/org/neo4j/driver/Config.java @@ -75,6 +75,9 @@ public final class Config implements Serializable { private static final Config EMPTY = builder().build(); + /** + * The {@link QueryTask} {@link BookmarkManager}. + */ private final BookmarkManager queryBookmarkManager; /** @@ -82,25 +85,67 @@ public final class Config implements Serializable { */ private final Logging logging; + /** + * The flag indicating if leaked sessions logging is enabled. + */ private final boolean logLeakedSessions; + /** + * The maximum connection pool size. + */ private final int maxConnectionPoolSize; + /** + * The idle time that defines if connection should be tested before being handed out by the connection pool. + */ private final long idleTimeBeforeConnectionTest; + /** + * The maximum connection lifetime in milliseconds. + */ private final long maxConnectionLifetimeMillis; + /** + * The maximum amount of time connection acquisition will attempt to acquire a connection from the connection pool. + */ private final long connectionAcquisitionTimeoutMillis; + /** + * The security settings. + */ private final SecuritySettings securitySettings; + /** + * The fetch size. + */ private final long fetchSize; + /** + * The stale routing table purge delay in milliseconds. + */ private final long routingTablePurgeDelayMillis; + /** + * The managed transactions maximum retry time. + */ private final long maxTransactionRetryTimeMillis; + /** + * The configured connection timeout value in milliseconds. + */ private final int connectionTimeoutMillis; + /** + * The server address resolver. + */ private final ServerAddressResolver resolver; + /** + * The event loop thread count. + */ private final int eventLoopThreads; + /** + * The user_agent configured for this driver. + */ private final String userAgent; + /** + * The {@link MetricsAdapter}. + */ private final MetricsAdapter metricsAdapter; private Config(ConfigBuilder builder) { @@ -185,10 +230,18 @@ public int connectionTimeoutMillis() { return connectionTimeoutMillis; } + /** + * Returns the maximum connection pool size. + * @return the maximum size + */ public int maxConnectionPoolSize() { return maxConnectionPoolSize; } + /** + * Returns the connection acquisition timeout in milliseconds. + * @return the acquisition timeout + */ public long connectionAcquisitionTimeoutMillis() { return connectionAcquisitionTimeoutMillis; } @@ -250,10 +303,18 @@ public long maxTransactionRetryTimeMillis() { return maxTransactionRetryTimeMillis; } + /** + * Returns the fetch size. + * @return the fetch size + */ public long fetchSize() { return fetchSize; } + /** + * Returns the number of {@link io.netty.channel.EventLoop} threads. + * @return the number of threads + */ public int eventLoopThreads() { return eventLoopThreads; } @@ -265,6 +326,10 @@ public boolean isMetricsEnabled() { return this.metricsAdapter != MetricsAdapter.DEV_NULL; } + /** + * Returns the {@link MetricsAdapter}. + * @return the metrics adapter + */ public MetricsAdapter metricsAdapter() { return this.metricsAdapter; } @@ -730,14 +795,35 @@ public static final class TrustStrategy implements Serializable { * The trust strategy that the driver supports */ public enum Strategy { + /** + * Trust all certificates. + */ TRUST_ALL_CERTIFICATES, + /** + * Trust custom CA-signed certificates. + */ TRUST_CUSTOM_CA_SIGNED_CERTIFICATES, + /** + * Trust system CA-signed certificates. + */ TRUST_SYSTEM_CA_SIGNED_CERTIFICATES } + /** + * The strategy type. + */ private final Strategy strategy; + /** + * The configured certificate files. + */ private final List certFiles; + /** + * The flag indicating if hostname verification is enabled for this trust strategy. + */ private boolean hostnameVerificationEnabled = true; + /** + * The revocation strategy used for verifying certificates. + */ private RevocationCheckingStrategy revocationCheckingStrategy = RevocationCheckingStrategy.NO_CHECKS; private TrustStrategy(Strategy strategy) { diff --git a/driver/src/main/java/org/neo4j/driver/QueryConfig.java b/driver/src/main/java/org/neo4j/driver/QueryConfig.java index 71ccb16f93..f02c6ec82c 100644 --- a/driver/src/main/java/org/neo4j/driver/QueryConfig.java +++ b/driver/src/main/java/org/neo4j/driver/QueryConfig.java @@ -37,10 +37,25 @@ public final class QueryConfig implements Serializable { private static final QueryConfig DEFAULT = builder().build(); + /** + * The routing mode. + */ private final RoutingControl routing; + /** + * The target database. + */ private final String database; + /** + * The impersonated user. + */ private final String impersonatedUser; + /** + * The bookmark manager. + */ private final BookmarkManager bookmarkManager; + /** + * The flag indicating if default bookmark manager should be used. + */ private final boolean useDefaultBookmarkManager; /** diff --git a/driver/src/main/java/org/neo4j/driver/Records.java b/driver/src/main/java/org/neo4j/driver/Records.java index a0ee926ac3..bbf7299711 100644 --- a/driver/src/main/java/org/neo4j/driver/Records.java +++ b/driver/src/main/java/org/neo4j/driver/Records.java @@ -29,18 +29,42 @@ public final class Records { private Records() {} + /** + * Returns a function mapping record to a value from a given index. + * @param index the index value + * @return the function + */ public static Function column(int index) { return column(index, Values.ofValue()); } + /** + * Returns a function mapping record to a value from a given key. + * @param key the key value + * @return the function + */ public static Function column(String key) { return column(key, Values.ofValue()); } + /** + * Returns a function mapping record to a value of a target type from a given index. + * @param index the index value + * @param mapFunction the function mapping value to a value of a target type + * @return the function + * @param the target type + */ public static Function column(final int index, final Function mapFunction) { return record -> mapFunction.apply(record.get(index)); } + /** + * Returns a function mapping record to a value of a target type from a given key. + * @param key the key value + * @param mapFunction the function mapping value to a value of a target type + * @return the function + * @param the target type + */ public static Function column(final String key, final Function mapFunction) { return recordAccessor -> mapFunction.apply(recordAccessor.get(key)); } diff --git a/driver/src/main/java/org/neo4j/driver/RevocationCheckingStrategy.java b/driver/src/main/java/org/neo4j/driver/RevocationCheckingStrategy.java index ffeb751b03..c561555d0f 100644 --- a/driver/src/main/java/org/neo4j/driver/RevocationCheckingStrategy.java +++ b/driver/src/main/java/org/neo4j/driver/RevocationCheckingStrategy.java @@ -29,6 +29,11 @@ public enum RevocationCheckingStrategy { /** Require stapled revocation status and verify OCSP revocation checks, fail if no revocation status is stapled to the certificate. */ STRICT; + /** + * Returns whether a given strategy requires revocation checking. + * @param revocationCheckingStrategy the strategy + * @return whether revocation checking is required + */ public static boolean requiresRevocationChecking(RevocationCheckingStrategy revocationCheckingStrategy) { return revocationCheckingStrategy.equals(STRICT) || revocationCheckingStrategy.equals(VERIFY_IF_PRESENT); } diff --git a/driver/src/main/java/org/neo4j/driver/SessionConfig.java b/driver/src/main/java/org/neo4j/driver/SessionConfig.java index e79407a5ff..abcca9f363 100644 --- a/driver/src/main/java/org/neo4j/driver/SessionConfig.java +++ b/driver/src/main/java/org/neo4j/driver/SessionConfig.java @@ -41,11 +41,29 @@ public final class SessionConfig implements Serializable { private static final SessionConfig EMPTY = builder().build(); + /** + * The initial bookmarks. + */ private final Iterable bookmarks; + /** + * The default type of access. + */ private final AccessMode defaultAccessMode; + /** + * The target database name. + */ private final String database; + /** + * The fetch size. + */ private final Long fetchSize; + /** + * The impersonated user. + */ private final String impersonatedUser; + /** + * The bookmark manager. + */ private final BookmarkManager bookmarkManager; private SessionConfig(Builder builder) { @@ -348,6 +366,10 @@ public Builder withBookmarkManager(BookmarkManager bookmarkManager) { return this; } + /** + * Builds the {@link SessionConfig}. + * @return the config + */ public SessionConfig build() { return new SessionConfig(this); } diff --git a/driver/src/main/java/org/neo4j/driver/TransactionConfig.java b/driver/src/main/java/org/neo4j/driver/TransactionConfig.java index 6ee5a2b10a..6829dcc67b 100644 --- a/driver/src/main/java/org/neo4j/driver/TransactionConfig.java +++ b/driver/src/main/java/org/neo4j/driver/TransactionConfig.java @@ -69,7 +69,13 @@ public final class TransactionConfig implements Serializable { private static final TransactionConfig EMPTY = builder().build(); + /** + * the transaction timeout + */ private final Duration timeout; + /** + * The transaction metadata. + */ private final Map metadata; // Values are not serializable, hence, we keep a transient volatile map of them around diff --git a/driver/src/main/java/org/neo4j/driver/Values.java b/driver/src/main/java/org/neo4j/driver/Values.java index cbff5413e6..9bf1af6862 100644 --- a/driver/src/main/java/org/neo4j/driver/Values.java +++ b/driver/src/main/java/org/neo4j/driver/Values.java @@ -79,13 +79,24 @@ * @since 1.0 */ public final class Values { + /** + * The value instance of an empty map. + */ public static final Value EmptyMap = value(Collections.emptyMap()); + /** + * The value instance of {@code NULL}. + */ public static final Value NULL = NullValue.NULL; private Values() { throw new UnsupportedOperationException(); } + /** + * Returns a value from object. + * @param value the object value + * @return the array of values + */ @SuppressWarnings("unchecked") public static Value value(Object value) { if (value == null) { @@ -206,6 +217,11 @@ public static Value value(Object value) { throw new ClientException("Unable to convert " + value.getClass().getName() + " to Neo4j Value."); } + /** + * Returns an array of values from object vararg. + * @param input the object value(s) + * @return the array of values + */ public static Value[] values(final Object... input) { Value[] values = new Value[input.length]; for (int i = 0; i < input.length; i++) { @@ -214,6 +230,11 @@ public static Value[] values(final Object... input) { return values; } + /** + * Returns a value from value vararg. + * @param input the value(s) + * @return the value + */ public static Value value(Value... input) { int size = input.length; Value[] values = new Value[size]; @@ -221,10 +242,20 @@ public static Value value(Value... input) { return new ListValue(values); } + /** + * Returns a value from byte vararg. + * @param input the byte value(s) + * @return the value + */ public static Value value(byte... input) { return new BytesValue(input); } + /** + * Returns a value from string vararg. + * @param input the string value(s) + * @return the value + */ public static Value value(String... input) { StringValue[] values = new StringValue[input.length]; for (int i = 0; i < input.length; i++) { @@ -233,6 +264,11 @@ public static Value value(String... input) { return new ListValue(values); } + /** + * Returns a value from boolean vararg. + * @param input the boolean value(s) + * @return the value + */ public static Value value(boolean... input) { Value[] values = new Value[input.length]; for (int i = 0; i < input.length; i++) { @@ -241,6 +277,11 @@ public static Value value(boolean... input) { return new ListValue(values); } + /** + * Returns a value from char vararg. + * @param input the char value(s) + * @return the value + */ public static Value value(char... input) { Value[] values = new Value[input.length]; for (int i = 0; i < input.length; i++) { @@ -249,6 +290,11 @@ public static Value value(char... input) { return new ListValue(values); } + /** + * Returns a value from long vararg. + * @param input the long value(s) + * @return the value + */ public static Value value(long... input) { Value[] values = new Value[input.length]; for (int i = 0; i < input.length; i++) { @@ -257,6 +303,11 @@ public static Value value(long... input) { return new ListValue(values); } + /** + * Returns a value from short vararg. + * @param input the short value(s) + * @return the value + */ public static Value value(short... input) { Value[] values = new Value[input.length]; for (int i = 0; i < input.length; i++) { @@ -264,7 +315,11 @@ public static Value value(short... input) { } return new ListValue(values); } - + /** + * Returns a value from int vararg. + * @param input the int value(s) + * @return the value + */ public static Value value(int... input) { Value[] values = new Value[input.length]; for (int i = 0; i < input.length; i++) { @@ -272,7 +327,11 @@ public static Value value(int... input) { } return new ListValue(values); } - + /** + * Returns a value from double vararg. + * @param input the double value(s) + * @return the value + */ public static Value value(double... input) { Value[] values = new Value[input.length]; for (int i = 0; i < input.length; i++) { @@ -281,6 +340,11 @@ public static Value value(double... input) { return new ListValue(values); } + /** + * Returns a value from float vararg. + * @param input the float value(s) + * @return the value + */ public static Value value(float... input) { Value[] values = new Value[input.length]; for (int i = 0; i < input.length; i++) { @@ -289,6 +353,11 @@ public static Value value(float... input) { return new ListValue(values); } + /** + * Returns a value from list of objects. + * @param vals the list of objects + * @return the value + */ public static Value value(List vals) { Value[] values = new Value[vals.size()]; int i = 0; @@ -298,10 +367,20 @@ public static Value value(List vals) { return new ListValue(values); } + /** + * Returns a value from iterable of objects. + * @param val the iterable of objects + * @return the value + */ public static Value value(Iterable val) { return value(val.iterator()); } + /** + * Returns a value from iterator of objects. + * @param val the iterator of objects + * @return the value + */ public static Value value(Iterator val) { List values = new ArrayList<>(); while (val.hasNext()) { @@ -310,35 +389,75 @@ public static Value value(Iterator val) { return new ListValue(values.toArray(new Value[0])); } + /** + * Returns a value from stream of objects. + * @param stream the stream of objects + * @return the value + */ public static Value value(Stream stream) { Value[] values = stream.map(Values::value).toArray(Value[]::new); return new ListValue(values); } + /** + * Returns a value from char. + * @param val the char value + * @return the value + */ public static Value value(final char val) { return new StringValue(String.valueOf(val)); } + /** + * Returns a value from string. + * @param val the string value + * @return the value + */ public static Value value(final String val) { return new StringValue(val); } + /** + * Returns a value from long. + * @param val the long value + * @return the value + */ public static Value value(final long val) { return new IntegerValue(val); } + /** + * Returns a value from int. + * @param val the int value + * @return the value + */ public static Value value(final int val) { return new IntegerValue(val); } + /** + * Returns a value from double. + * @param val the double value + * @return the value + */ public static Value value(final double val) { return new FloatValue(val); } + /** + * Returns a value from boolean. + * @param val the boolean value + * @return the value + */ public static Value value(final boolean val) { return BooleanValue.fromBoolean(val); } + /** + * Returns a value from string to object map. + * @param val the string to object map + * @return the value + */ public static Value value(final Map val) { Map asValues = newHashMapWithSize(val.size()); for (Map.Entry entry : val.entrySet()) { @@ -347,54 +466,127 @@ public static Value value(final Map val) { return new MapValue(asValues); } + /** + * Returns a value from local date. + * @param localDate the local date value + * @return the value + */ public static Value value(LocalDate localDate) { return new DateValue(localDate); } + /** + * Returns a value from offset time. + * @param offsetTime the offset time value + * @return the value + */ public static Value value(OffsetTime offsetTime) { return new TimeValue(offsetTime); } + /** + * Returns a value from local time. + * @param localTime the local time value + * @return the value + */ public static Value value(LocalTime localTime) { return new LocalTimeValue(localTime); } + /** + * Returns a value from local date time. + * @param localDateTime the local date time value + * @return the value + */ public static Value value(LocalDateTime localDateTime) { return new LocalDateTimeValue(localDateTime); } + /** + * Returns a value from offset date time. + * @param offsetDateTime the offset date time value + * @return the value + */ public static Value value(OffsetDateTime offsetDateTime) { return new DateTimeValue(offsetDateTime.toZonedDateTime()); } + /** + * Returns a value from zoned date time. + * @param zonedDateTime the zoned date time value + * @return the value + */ public static Value value(ZonedDateTime zonedDateTime) { return new DateTimeValue(zonedDateTime); } + /** + * Returns a value from period. + * @param period the period value + * @return the value + */ public static Value value(Period period) { return value(new InternalIsoDuration(period)); } + /** + * Returns a value from duration. + * @param duration the duration value + * @return the value + */ public static Value value(Duration duration) { return value(new InternalIsoDuration(duration)); } + /** + * Returns a value from month, day, seconds and nanoseconds values. + * @param months the month value + * @param days the day value + * @param seconds the seconds value + * @param nanoseconds the nanoseconds value + * @return the value + */ public static Value isoDuration(long months, long days, long seconds, int nanoseconds) { return value(new InternalIsoDuration(months, days, seconds, nanoseconds)); } + /** + * Returns a value from ISO duration. + * @param duration the ISO duration value + * @return the value + */ private static Value value(IsoDuration duration) { return new DurationValue(duration); } + /** + * Returns a value from SRID, x and y values. + * @param srid the SRID value + * @param x the x value + * @param y the y value + * @return the value + */ public static Value point(int srid, double x, double y) { return value(new InternalPoint2D(srid, x, y)); } + /** + * Returns a value from point. + * @param point the point value + * @return the value + */ private static Value value(Point point) { return new PointValue(point); } + /** + * Returns a value from SRID, x ,y and z values. + * @param srid the SRID value + * @param x the x value + * @param y the y value + * @param z the z value + * @return the value + */ public static Value point(int srid, double x, double y, double z) { return value(new InternalPoint3D(srid, x, y, z)); } diff --git a/driver/src/main/java/org/neo4j/driver/exceptions/AuthenticationException.java b/driver/src/main/java/org/neo4j/driver/exceptions/AuthenticationException.java index b2195e8707..eb90bda6f9 100644 --- a/driver/src/main/java/org/neo4j/driver/exceptions/AuthenticationException.java +++ b/driver/src/main/java/org/neo4j/driver/exceptions/AuthenticationException.java @@ -31,6 +31,11 @@ public class AuthenticationException extends SecurityException { @Serial private static final long serialVersionUID = 1324352999966240271L; + /** + * Creates a new instance. + * @param code the code + * @param message the message + */ public AuthenticationException(String code, String message) { super(code, message); } diff --git a/driver/src/main/java/org/neo4j/driver/exceptions/AuthorizationExpiredException.java b/driver/src/main/java/org/neo4j/driver/exceptions/AuthorizationExpiredException.java index 80fbd9f393..d749b80ca6 100644 --- a/driver/src/main/java/org/neo4j/driver/exceptions/AuthorizationExpiredException.java +++ b/driver/src/main/java/org/neo4j/driver/exceptions/AuthorizationExpiredException.java @@ -29,9 +29,17 @@ public class AuthorizationExpiredException extends SecurityException implements @Serial private static final long serialVersionUID = 5688002170978405558L; + /** + * The description for {@link AuthorizationExpiredException}. + */ public static final String DESCRIPTION = "Authorization information kept on the server has expired, this connection is no longer valid."; + /** + * Creates a new instance. + * @param code the code + * @param message the message + */ public AuthorizationExpiredException(String code, String message) { super(code, message); } diff --git a/driver/src/main/java/org/neo4j/driver/exceptions/ClientException.java b/driver/src/main/java/org/neo4j/driver/exceptions/ClientException.java index c84e14d036..328eb67d72 100644 --- a/driver/src/main/java/org/neo4j/driver/exceptions/ClientException.java +++ b/driver/src/main/java/org/neo4j/driver/exceptions/ClientException.java @@ -29,14 +29,28 @@ public class ClientException extends Neo4jException { @Serial private static final long serialVersionUID = -6732913155228185887L; + /** + * Creates a new instance. + * @param message the message + */ public ClientException(String message) { super(message); } + /** + * Creates a new instance. + * @param message the message + * @param cause the cause + */ public ClientException(String message, Throwable cause) { super(message, cause); } + /** + * Creates a new instance. + * @param code the code + * @param message the message + */ public ClientException(String code, String message) { super(code, message); } diff --git a/driver/src/main/java/org/neo4j/driver/exceptions/ConnectionReadTimeoutException.java b/driver/src/main/java/org/neo4j/driver/exceptions/ConnectionReadTimeoutException.java index 730411167f..4ef10335dd 100644 --- a/driver/src/main/java/org/neo4j/driver/exceptions/ConnectionReadTimeoutException.java +++ b/driver/src/main/java/org/neo4j/driver/exceptions/ConnectionReadTimeoutException.java @@ -29,9 +29,18 @@ public class ConnectionReadTimeoutException extends ServiceUnavailableException @Serial private static final long serialVersionUID = -9222586212813330140L; + /** + * An instance of {@link ConnectionReadTimeoutException}. + */ public static final ConnectionReadTimeoutException INSTANCE = new ConnectionReadTimeoutException( "Connection read timed out due to it taking longer than the server-supplied timeout value via configuration hint."); + /** + * Creates a new instance. + * @param message the message + * @deprecated superseded by the {@link ConnectionReadTimeoutException#INSTANCE} value + */ + @Deprecated public ConnectionReadTimeoutException(String message) { super(message); } diff --git a/driver/src/main/java/org/neo4j/driver/exceptions/DatabaseException.java b/driver/src/main/java/org/neo4j/driver/exceptions/DatabaseException.java index f0ae7c0887..1518823219 100644 --- a/driver/src/main/java/org/neo4j/driver/exceptions/DatabaseException.java +++ b/driver/src/main/java/org/neo4j/driver/exceptions/DatabaseException.java @@ -29,6 +29,11 @@ public class DatabaseException extends Neo4jException { @Serial private static final long serialVersionUID = 4591061578560201032L; + /** + * Creates a new instance. + * @param code the code + * @param message the message + */ public DatabaseException(String code, String message) { super(code, message); } diff --git a/driver/src/main/java/org/neo4j/driver/exceptions/DiscoveryException.java b/driver/src/main/java/org/neo4j/driver/exceptions/DiscoveryException.java index 8b9da1293b..4cc8db5ed7 100644 --- a/driver/src/main/java/org/neo4j/driver/exceptions/DiscoveryException.java +++ b/driver/src/main/java/org/neo4j/driver/exceptions/DiscoveryException.java @@ -32,6 +32,11 @@ public class DiscoveryException extends Neo4jException { @Serial private static final long serialVersionUID = 6711564351333659090L; + /** + * Creates a new instance. + * @param message the message + * @param cause the cause + */ public DiscoveryException(String message, Throwable cause) { super(message, cause); } diff --git a/driver/src/main/java/org/neo4j/driver/exceptions/FatalDiscoveryException.java b/driver/src/main/java/org/neo4j/driver/exceptions/FatalDiscoveryException.java index b772c1dec8..9847254670 100644 --- a/driver/src/main/java/org/neo4j/driver/exceptions/FatalDiscoveryException.java +++ b/driver/src/main/java/org/neo4j/driver/exceptions/FatalDiscoveryException.java @@ -29,10 +29,19 @@ public class FatalDiscoveryException extends ClientException { @Serial private static final long serialVersionUID = -2831830142554054420L; + /** + * Creates a new instance. + * @param message the message + */ public FatalDiscoveryException(String message) { super(message); } + /** + * Creates a new instance. + * @param code the code + * @param message the message + */ public FatalDiscoveryException(String code, String message) { super(code, message); } diff --git a/driver/src/main/java/org/neo4j/driver/exceptions/Neo4jException.java b/driver/src/main/java/org/neo4j/driver/exceptions/Neo4jException.java index 57fe73933f..9663159a13 100644 --- a/driver/src/main/java/org/neo4j/driver/exceptions/Neo4jException.java +++ b/driver/src/main/java/org/neo4j/driver/exceptions/Neo4jException.java @@ -29,20 +29,43 @@ public class Neo4jException extends RuntimeException { @Serial private static final long serialVersionUID = -80579062276712566L; + /** + * The code value. + */ private final String code; + /** + * Creates a new instance. + * @param message the message + */ public Neo4jException(String message) { this("N/A", message); } + /** + * Creates a new instance. + * @param message the message + * @param cause the cause + */ public Neo4jException(String message, Throwable cause) { this("N/A", message, cause); } + /** + * Creates a new instance. + * @param code the code + * @param message the message + */ public Neo4jException(String code, String message) { this(code, message, null); } + /** + * Creates a new instance. + * @param code the code + * @param message the message + * @param cause the cause + */ public Neo4jException(String code, String message, Throwable cause) { super(message, cause); this.code = code; diff --git a/driver/src/main/java/org/neo4j/driver/exceptions/NoSuchRecordException.java b/driver/src/main/java/org/neo4j/driver/exceptions/NoSuchRecordException.java index c93368c659..0a9dd4465c 100644 --- a/driver/src/main/java/org/neo4j/driver/exceptions/NoSuchRecordException.java +++ b/driver/src/main/java/org/neo4j/driver/exceptions/NoSuchRecordException.java @@ -32,6 +32,10 @@ public class NoSuchRecordException extends NoSuchElementException { @Serial private static final long serialVersionUID = 9091962868264042491L; + /** + * Creates a new instance. + * @param message the message + */ public NoSuchRecordException(String message) { super(message); } diff --git a/driver/src/main/java/org/neo4j/driver/exceptions/ProtocolException.java b/driver/src/main/java/org/neo4j/driver/exceptions/ProtocolException.java index a11788c73a..3acd8b1ae5 100644 --- a/driver/src/main/java/org/neo4j/driver/exceptions/ProtocolException.java +++ b/driver/src/main/java/org/neo4j/driver/exceptions/ProtocolException.java @@ -30,10 +30,19 @@ public class ProtocolException extends Neo4jException { private static final String CODE = "Protocol violation: "; + /** + * Creates a new instance. + * @param message the message + */ public ProtocolException(String message) { super(CODE + message); } + /** + * Creates a new instance. + * @param message the message + * @param e the throwable + */ public ProtocolException(String message, Throwable e) { super(CODE + message, e); } diff --git a/driver/src/main/java/org/neo4j/driver/exceptions/ResultConsumedException.java b/driver/src/main/java/org/neo4j/driver/exceptions/ResultConsumedException.java index e1509bf35c..bcf9fddbe4 100644 --- a/driver/src/main/java/org/neo4j/driver/exceptions/ResultConsumedException.java +++ b/driver/src/main/java/org/neo4j/driver/exceptions/ResultConsumedException.java @@ -30,6 +30,10 @@ public class ResultConsumedException extends ClientException { @Serial private static final long serialVersionUID = 944999841543178703L; + /** + * Creates a new instance. + * @param message the message + */ public ResultConsumedException(String message) { super(message); } diff --git a/driver/src/main/java/org/neo4j/driver/exceptions/SecurityException.java b/driver/src/main/java/org/neo4j/driver/exceptions/SecurityException.java index 151b764c14..9734e05b71 100644 --- a/driver/src/main/java/org/neo4j/driver/exceptions/SecurityException.java +++ b/driver/src/main/java/org/neo4j/driver/exceptions/SecurityException.java @@ -30,10 +30,20 @@ public class SecurityException extends ClientException { @Serial private static final long serialVersionUID = -5964665406806523214L; + /** + * Creates a new instance. + * @param code the code + * @param message the message + */ public SecurityException(String code, String message) { super(code, message); } + /** + * Creates a new instance. + * @param message the message + * @param t the throwable + */ public SecurityException(String message, Throwable t) { super(message, t); } diff --git a/driver/src/main/java/org/neo4j/driver/exceptions/ServiceUnavailableException.java b/driver/src/main/java/org/neo4j/driver/exceptions/ServiceUnavailableException.java index bd5222d398..c07b8918ee 100644 --- a/driver/src/main/java/org/neo4j/driver/exceptions/ServiceUnavailableException.java +++ b/driver/src/main/java/org/neo4j/driver/exceptions/ServiceUnavailableException.java @@ -29,10 +29,19 @@ public class ServiceUnavailableException extends Neo4jException implements Retry @Serial private static final long serialVersionUID = 8316077882191697974L; + /** + * Creates a new instance. + * @param message the message + */ public ServiceUnavailableException(String message) { super(message); } + /** + * Creates a new instance. + * @param message the message + * @param throwable the throwable + */ public ServiceUnavailableException(String message, Throwable throwable) { super(message, throwable); } diff --git a/driver/src/main/java/org/neo4j/driver/exceptions/SessionExpiredException.java b/driver/src/main/java/org/neo4j/driver/exceptions/SessionExpiredException.java index da4da04685..d9ec46b60e 100644 --- a/driver/src/main/java/org/neo4j/driver/exceptions/SessionExpiredException.java +++ b/driver/src/main/java/org/neo4j/driver/exceptions/SessionExpiredException.java @@ -30,10 +30,19 @@ public class SessionExpiredException extends Neo4jException implements Retryable @Serial private static final long serialVersionUID = 843176371236755724L; + /** + * Creates a new instance. + * @param message the message + */ public SessionExpiredException(String message) { super(message); } + /** + * Creates a new instance. + * @param message the message + * @param throwable the throwable + */ public SessionExpiredException(String message, Throwable throwable) { super(message, throwable); } diff --git a/driver/src/main/java/org/neo4j/driver/exceptions/TokenExpiredException.java b/driver/src/main/java/org/neo4j/driver/exceptions/TokenExpiredException.java index 50140b1655..2d20f3fc2e 100644 --- a/driver/src/main/java/org/neo4j/driver/exceptions/TokenExpiredException.java +++ b/driver/src/main/java/org/neo4j/driver/exceptions/TokenExpiredException.java @@ -31,6 +31,11 @@ public class TokenExpiredException extends SecurityException { @Serial private static final long serialVersionUID = -5593851859769531234L; + /** + * Creates a new instance. + * @param code the code + * @param message the message + */ public TokenExpiredException(String code, String message) { super(code, message); } diff --git a/driver/src/main/java/org/neo4j/driver/exceptions/TransactionNestingException.java b/driver/src/main/java/org/neo4j/driver/exceptions/TransactionNestingException.java index fe398e555b..0d613cd61b 100644 --- a/driver/src/main/java/org/neo4j/driver/exceptions/TransactionNestingException.java +++ b/driver/src/main/java/org/neo4j/driver/exceptions/TransactionNestingException.java @@ -27,6 +27,10 @@ public class TransactionNestingException extends ClientException { @Serial private static final long serialVersionUID = -8264319542004457065L; + /** + * Creates a new instance. + * @param message the message + */ public TransactionNestingException(String message) { super(message); } diff --git a/driver/src/main/java/org/neo4j/driver/exceptions/TransientException.java b/driver/src/main/java/org/neo4j/driver/exceptions/TransientException.java index a2c3029d8e..bafd629612 100644 --- a/driver/src/main/java/org/neo4j/driver/exceptions/TransientException.java +++ b/driver/src/main/java/org/neo4j/driver/exceptions/TransientException.java @@ -30,6 +30,11 @@ public class TransientException extends Neo4jException implements RetryableExcep @Serial private static final long serialVersionUID = -2744576986358599923L; + /** + * Creates a new instance. + * @param code the code + * @param message the message + */ public TransientException(String code, String message) { super(code, message); } diff --git a/driver/src/main/java/org/neo4j/driver/exceptions/UntrustedServerException.java b/driver/src/main/java/org/neo4j/driver/exceptions/UntrustedServerException.java index 958ee2eafb..a195436ae3 100644 --- a/driver/src/main/java/org/neo4j/driver/exceptions/UntrustedServerException.java +++ b/driver/src/main/java/org/neo4j/driver/exceptions/UntrustedServerException.java @@ -27,6 +27,10 @@ public class UntrustedServerException extends RuntimeException { @Serial private static final long serialVersionUID = 3196604305660766197L; + /** + * Creates a new instance. + * @param message the message + */ public UntrustedServerException(String message) { super(message); } diff --git a/driver/src/main/java/org/neo4j/driver/exceptions/value/LossyCoercion.java b/driver/src/main/java/org/neo4j/driver/exceptions/value/LossyCoercion.java index ab9a16b894..bd97eee64d 100644 --- a/driver/src/main/java/org/neo4j/driver/exceptions/value/LossyCoercion.java +++ b/driver/src/main/java/org/neo4j/driver/exceptions/value/LossyCoercion.java @@ -30,6 +30,11 @@ public class LossyCoercion extends ValueException { @Serial private static final long serialVersionUID = -6259981390929065201L; + /** + * Creates a new instance. + * @param sourceTypeName the source type name + * @param destinationTypeName the destination type name + */ public LossyCoercion(String sourceTypeName, String destinationTypeName) { super(format("Cannot coerce %s to %s without losing precision", sourceTypeName, destinationTypeName)); } diff --git a/driver/src/main/java/org/neo4j/driver/exceptions/value/NotMultiValued.java b/driver/src/main/java/org/neo4j/driver/exceptions/value/NotMultiValued.java index a6005189b1..3137c20edd 100644 --- a/driver/src/main/java/org/neo4j/driver/exceptions/value/NotMultiValued.java +++ b/driver/src/main/java/org/neo4j/driver/exceptions/value/NotMultiValued.java @@ -29,6 +29,10 @@ public class NotMultiValued extends ValueException { @Serial private static final long serialVersionUID = -7380569883011364090L; + /** + * Creates a new instance. + * @param message the message + */ public NotMultiValued(String message) { super(message); } diff --git a/driver/src/main/java/org/neo4j/driver/exceptions/value/Uncoercible.java b/driver/src/main/java/org/neo4j/driver/exceptions/value/Uncoercible.java index c0a20f5f42..75fc5b197a 100644 --- a/driver/src/main/java/org/neo4j/driver/exceptions/value/Uncoercible.java +++ b/driver/src/main/java/org/neo4j/driver/exceptions/value/Uncoercible.java @@ -30,6 +30,11 @@ public class Uncoercible extends ValueException { @Serial private static final long serialVersionUID = -6259981390929065201L; + /** + * Creates a new instance. + * @param sourceTypeName the source type name + * @param destinationTypeName the destination type name + */ public Uncoercible(String sourceTypeName, String destinationTypeName) { super(format("Cannot coerce %s to %s", sourceTypeName, destinationTypeName)); } diff --git a/driver/src/main/java/org/neo4j/driver/exceptions/value/Unsizable.java b/driver/src/main/java/org/neo4j/driver/exceptions/value/Unsizable.java index cfcb14264b..2a31cc6573 100644 --- a/driver/src/main/java/org/neo4j/driver/exceptions/value/Unsizable.java +++ b/driver/src/main/java/org/neo4j/driver/exceptions/value/Unsizable.java @@ -28,6 +28,10 @@ public class Unsizable extends ValueException { @Serial private static final long serialVersionUID = 741487155344252339L; + /** + * Creates a new instance. + * @param message the message + */ public Unsizable(String message) { super(message); } diff --git a/driver/src/main/java/org/neo4j/driver/exceptions/value/ValueException.java b/driver/src/main/java/org/neo4j/driver/exceptions/value/ValueException.java index 54bbc93fab..740cdf9602 100644 --- a/driver/src/main/java/org/neo4j/driver/exceptions/value/ValueException.java +++ b/driver/src/main/java/org/neo4j/driver/exceptions/value/ValueException.java @@ -29,6 +29,10 @@ public class ValueException extends ClientException { @Serial private static final long serialVersionUID = -1269336313727174998L; + /** + * Creates a new instance. + * @param message the message + */ public ValueException(String message) { super(message); } diff --git a/driver/src/main/java/org/neo4j/driver/internal/packstream/PackStream.java b/driver/src/main/java/org/neo4j/driver/internal/packstream/PackStream.java index a38386bebd..411114f595 100644 --- a/driver/src/main/java/org/neo4j/driver/internal/packstream/PackStream.java +++ b/driver/src/main/java/org/neo4j/driver/internal/packstream/PackStream.java @@ -36,7 +36,7 @@ * Extra markers should not be added casually and such additions must be follow a strict process involving both client and server software. * * The table below shows all allocated marker byte values. - *

+ *
* * * diff --git a/driver/src/main/java/org/neo4j/driver/reactive/RxQueryRunner.java b/driver/src/main/java/org/neo4j/driver/reactive/RxQueryRunner.java index f529822d50..0188a27195 100644 --- a/driver/src/main/java/org/neo4j/driver/reactive/RxQueryRunner.java +++ b/driver/src/main/java/org/neo4j/driver/reactive/RxQueryRunner.java @@ -123,10 +123,20 @@ default RxResult run(String query) { */ RxResult run(Query query); + /** + * Creates a value from a record instance. + * @param record the record + * @return the value + */ static Value parameters(Record record) { return record == null ? Values.EmptyMap : parameters(record.asMap()); } + /** + * Creates a value from a map instance. + * @param map the map + * @return the value + */ static Value parameters(Map map) { if (map == null || map.isEmpty()) { return Values.EmptyMap; diff --git a/driver/src/main/java/org/neo4j/driver/summary/QueryType.java b/driver/src/main/java/org/neo4j/driver/summary/QueryType.java index 2d7fce6205..491f3901e6 100644 --- a/driver/src/main/java/org/neo4j/driver/summary/QueryType.java +++ b/driver/src/main/java/org/neo4j/driver/summary/QueryType.java @@ -28,35 +28,63 @@ * @since 1.0 */ public enum QueryType { + /** + * Read only. + */ READ_ONLY, + /** + * Read write. + */ READ_WRITE, + /** + * Write only. + */ WRITE_ONLY, + /** + * Schema write. + */ SCHEMA_WRITE; private static final String UNEXPECTED_TYPE_MSG_FMT = "Unknown query type: `%s`."; private static final Function UNEXPECTED_TYPE_EXCEPTION_SUPPLIER = (type) -> new ClientException(String.format(UNEXPECTED_TYPE_MSG_FMT, type)); + /** + * Creates a query type from a {@link String} value. + * @param type the type string value + * @return the query type + */ public static QueryType fromCode(String type) { return fromCode(type, UNEXPECTED_TYPE_EXCEPTION_SUPPLIER); } + /** + * Creates a query type from a {@link String} value and exception function. + * @param type the type string value + * @param exceptionFunction the function producing exception if no mapping is found + * @return the query type + */ public static QueryType fromCode(String type, Function exceptionFunction) { switch (type) { - case "r": + case "r" -> { return QueryType.READ_ONLY; - case "rw": + } + case "rw" -> { return QueryType.READ_WRITE; - case "w": + } + case "w" -> { return QueryType.WRITE_ONLY; - case "s": + } + case "s" -> { return QueryType.SCHEMA_WRITE; - default: + } + default -> { if (exceptionFunction != null) { throw exceptionFunction.apply(type); } else { return null; } + } } } } diff --git a/driver/src/main/java/org/neo4j/driver/types/TypeSystem.java b/driver/src/main/java/org/neo4j/driver/types/TypeSystem.java index 98332c94e9..16099f188e 100644 --- a/driver/src/main/java/org/neo4j/driver/types/TypeSystem.java +++ b/driver/src/main/java/org/neo4j/driver/types/TypeSystem.java @@ -37,43 +37,123 @@ static TypeSystem getDefault() { return TYPE_SYSTEM; } + /** + * Returns a {@link Type} instance representing any type. + * @return the type instance + */ Type ANY(); + /** + * Returns a {@link Type} instance representing boolean. + * @return the type instance + */ Type BOOLEAN(); + /** + * Returns a {@link Type} instance representing bytes. + * @return the type instance + */ Type BYTES(); + /** + * Returns a {@link Type} instance representing string. + * @return the type instance + */ Type STRING(); + /** + * Returns a {@link Type} instance representing number. + * @return the type instance + */ Type NUMBER(); + /** + * Returns a {@link Type} instance representing integer. + * @return the type instance + */ Type INTEGER(); + /** + * Returns a {@link Type} instance representing float. + * @return the type instance + */ Type FLOAT(); + /** + * Returns a {@link Type} instance representing list. + * @return the type instance + */ Type LIST(); + /** + * Returns a {@link Type} instance representing map. + * @return the type instance + */ Type MAP(); + /** + * Returns a {@link Type} instance representing node. + * @return the type instance + */ Type NODE(); + /** + * Returns a {@link Type} instance representing relationship. + * @return the type instance + */ Type RELATIONSHIP(); + /** + * Returns a {@link Type} instance representing path. + * @return the type instance + */ Type PATH(); + /** + * Returns a {@link Type} instance representing point. + * @return the type instance + */ Type POINT(); + /** + * Returns a {@link Type} instance representing date. + * @return the type instance + */ Type DATE(); + /** + * Returns a {@link Type} instance representing time. + * @return the type instance + */ Type TIME(); + /** + * Returns a {@link Type} instance representing local time. + * @return the type instance + */ Type LOCAL_TIME(); + /** + * Returns a {@link Type} instance representing local date time. + * @return the type instance + */ Type LOCAL_DATE_TIME(); + /** + * Returns a {@link Type} instance representing date time. + * @return the type instance + */ Type DATE_TIME(); + /** + * Returns a {@link Type} instance representing duration. + * @return the type instance + */ Type DURATION(); + /** + * Returns a {@link Type} instance representing NULL. + * @return the type instance + */ Type NULL(); } diff --git a/pom.xml b/pom.xml index 8649e97720..72d6138806 100644 --- a/pom.xml +++ b/pom.xml @@ -588,6 +588,7 @@ + org/neo4j/driver/**/*.java @@ -601,6 +602,9 @@ jar + + true + aggregate
Allocated marker byte values.
MarkerBinaryTypeDescription