fix: Several issues wrt JavaDoc and the module-path. (#2865)

The latest version of the Maven JavaDoc plugin and JavaDoc itself have been rightfully complaining that some pieces of SDN have been using internal API of the driver and Cypher-DSL which would not be available on the module-path.

This has been fixed. The schema-name support from Cypher-DSL is now a direct dependency and not relying on the shaded version any long.

Several issues in the `Neo4jSpelSupport` have been fixed along the way.
This commit is contained in:
Michael Simons
2024-02-21 12:15:17 +00:00
parent d220cd4f73
commit 28ce97a647
5 changed files with 22 additions and 16 deletions

View File

@@ -198,6 +198,11 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-cypher-dsl-schema-name-support</artifactId>
<version>${cypher-dsl.version}</version>
</dependency>
<dependency>
<groupId>org.neo4j.driver</groupId>
<artifactId>neo4j-java-driver</artifactId>
@@ -370,6 +375,10 @@
<groupId>org.neo4j</groupId>
<artifactId>neo4j-cypher-dsl</artifactId>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-cypher-dsl-schema-name-support</artifactId>
</dependency>
<dependency>
<groupId>org.neo4j.driver</groupId>
<artifactId>neo4j-java-driver</artifactId>

View File

@@ -60,7 +60,6 @@ import org.neo4j.cypherdsl.core.StatementBuilder.OngoingUpdate;
import org.neo4j.cypherdsl.core.SymbolicName;
import org.neo4j.cypherdsl.core.renderer.Configuration;
import org.neo4j.cypherdsl.core.renderer.Renderer;
import org.neo4j.cypherdsl.core.utils.Assertions;
import org.springframework.data.domain.Sort;
import org.springframework.data.mapping.MappingException;
import org.springframework.data.mapping.PersistentProperty;
@@ -701,7 +700,7 @@ public enum CypherGenerator {
expression = Cypher.property(property.substring(0, firstDot), tail);
} else {
try {
Assertions.isTrue(SourceVersion.isIdentifier(property), "Name must be a valid identifier.");
Assert.isTrue(SourceVersion.isIdentifier(property), "Name must be a valid identifier.");
expression = Cypher.name(property);
} catch (IllegalArgumentException e) {
if (e.getMessage().endsWith(".")) {

View File

@@ -38,7 +38,6 @@ import java.util.stream.StreamSupport;
import org.neo4j.driver.Record;
import org.neo4j.driver.Value;
import org.neo4j.driver.Values;
import org.neo4j.driver.internal.value.NullValue;
import org.neo4j.driver.types.MapAccessor;
import org.neo4j.driver.types.Node;
import org.neo4j.driver.types.Relationship;
@@ -895,7 +894,7 @@ final class DefaultNeo4jEntityConverter implements Neo4jEntityConverter {
} else if (propertyContainer.containsKey(Constants.NAME_OF_ALL_PROPERTIES)) {
return propertyContainer.get(Constants.NAME_OF_ALL_PROPERTIES).get(graphPropertyName);
} else {
return NullValue.NULL;
return Values.NULL;
}
}
}

View File

@@ -19,7 +19,7 @@ import org.apiguardian.api.API;
import org.neo4j.driver.Value;
/**
* A wrapper or marker for a Neo4j {@link org.neo4j.driver.internal.value.MapValue} that needs to be unwrapped when used
* A wrapper or marker for a Neo4j {@code org.neo4j.driver.internal.value.MapValue} that needs to be unwrapped when used
* for properties.
* This class exists solely for projection / filtering purposes: It allows the {@link DefaultNeo4jEntityConverter} to keep
* the composite properties together as long as possible (in the form of above's {@code MapValue}. Thus, the key in the

View File

@@ -15,6 +15,7 @@
*/
package org.springframework.data.neo4j.repository.query;
import java.io.Serial;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Locale;
@@ -24,10 +25,8 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import org.apache.commons.logging.LogFactory;
import org.apiguardian.api.API;
import org.neo4j.cypherdsl.core.internal.SchemaNames;
import org.springframework.core.log.LogAccessor;
import org.neo4j.cypherdsl.support.schema_name.SchemaNames;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.neo4j.core.mapping.CypherGenerator;
@@ -57,8 +56,6 @@ public final class Neo4jSpelSupport {
public static String FUNCTION_ALL_OF = "allOf";
public static String FUNCTION_ORDER_BY = "orderBy";
private static final LogAccessor LOG = new LogAccessor(LogFactory.getLog(Neo4jSpelSupport.class));
/**
* Takes {@code arg} and tries to either extract a {@link Sort sort} from it or cast it to a sort. That sort is
* than past to the {@link CypherGenerator} that renders a valid order by fragment which replaces the SpEL placeholder
@@ -90,9 +87,8 @@ public final class Neo4jSpelSupport {
*/
public static LiteralReplacement literal(@Nullable Object arg) {
LiteralReplacement literalReplacement = StringBasedLiteralReplacement
return StringBasedLiteralReplacement
.withTargetAndValue(LiteralReplacement.Target.UNSPECIFIED, arg == null ? "" : arg.toString());
return literalReplacement;
}
public static LiteralReplacement anyOf(@Nullable Object arg) {
@@ -113,7 +109,7 @@ public final class Neo4jSpelSupport {
private static String joinStrings(Object arg, String joinOn) {
if (arg instanceof Collection) {
return ((Collection<?>) arg).stream()
.map(o -> SchemaNames.sanitize(o.toString()).get())
.map(o -> SchemaNames.sanitize(o.toString()).orElseThrow())
.collect(Collectors.joining(joinOn));
}
@@ -130,7 +126,7 @@ public final class Neo4jSpelSupport {
* comes in handy in places where non-parameterizable things should be created dynamic, for example matching on
* set of dynamic labels, types order ordering in a dynamic way.
*/
interface LiteralReplacement {
public interface LiteralReplacement {
/**
* The target of this replacement. While a replacement can be used theoretically everywhere in the query, the target
@@ -155,7 +151,10 @@ public final class Neo4jSpelSupport {
* the creation of too many small objects.
*/
private static final Map<String, LiteralReplacement> INSTANCES =
new LinkedHashMap<String, LiteralReplacement>(DEFAULT_CACHE_SIZE) {
new LinkedHashMap<>(DEFAULT_CACHE_SIZE) {
@Serial
private static final long serialVersionUID = 195460174410223375L;
@Override
protected boolean removeEldestEntry(Map.Entry<String, LiteralReplacement> eldest) {
return size() > DEFAULT_CACHE_SIZE;
@@ -167,7 +166,7 @@ public final class Neo4jSpelSupport {
static LiteralReplacement withTargetAndValue(LiteralReplacement.Target target, @Nullable String value) {
String valueUsed = value == null ? "" : value;
String key = new StringBuilder(target.name()).append("_").append(valueUsed).toString();
String key = target.name() + "_" + valueUsed;
long stamp = LOCK.tryOptimisticRead();
if (LOCK.validate(stamp) && INSTANCES.containsKey(key)) {