1515 */
1616package org .springframework .data .neo4j .repository .query ;
1717
18+ import java .io .Serial ;
1819import java .util .Collection ;
1920import java .util .LinkedHashMap ;
2021import java .util .Locale ;
2425import java .util .regex .Pattern ;
2526import java .util .stream .Collectors ;
2627
27- import org .apache .commons .logging .LogFactory ;
2828import org .apiguardian .api .API ;
29- import org .neo4j .cypherdsl .core .internal .SchemaNames ;
30- import org .springframework .core .log .LogAccessor ;
29+ import org .neo4j .cypherdsl .support .schema_name .SchemaNames ;
3130import org .springframework .data .domain .Pageable ;
3231import org .springframework .data .domain .Sort ;
3332import org .springframework .data .neo4j .core .mapping .CypherGenerator ;
@@ -57,8 +56,6 @@ public final class Neo4jSpelSupport {
5756 public static String FUNCTION_ALL_OF = "allOf" ;
5857 public static String FUNCTION_ORDER_BY = "orderBy" ;
5958
60- private static final LogAccessor LOG = new LogAccessor (LogFactory .getLog (Neo4jSpelSupport .class ));
61-
6259 /**
6360 * Takes {@code arg} and tries to either extract a {@link Sort sort} from it or cast it to a sort. That sort is
6461 * than past to the {@link CypherGenerator} that renders a valid order by fragment which replaces the SpEL placeholder
@@ -90,9 +87,8 @@ public static LiteralReplacement orderBy(@Nullable Object arg) {
9087 */
9188 public static LiteralReplacement literal (@ Nullable Object arg ) {
9289
93- LiteralReplacement literalReplacement = StringBasedLiteralReplacement
90+ return StringBasedLiteralReplacement
9491 .withTargetAndValue (LiteralReplacement .Target .UNSPECIFIED , arg == null ? "" : arg .toString ());
95- return literalReplacement ;
9692 }
9793
9894 public static LiteralReplacement anyOf (@ Nullable Object arg ) {
@@ -113,7 +109,7 @@ private static LiteralReplacement labels(@Nullable Object arg, String joinOn) {
113109 private static String joinStrings (Object arg , String joinOn ) {
114110 if (arg instanceof Collection ) {
115111 return ((Collection <?>) arg ).stream ()
116- .map (o -> SchemaNames .sanitize (o .toString ()).get ())
112+ .map (o -> SchemaNames .sanitize (o .toString ()).orElseThrow ())
117113 .collect (Collectors .joining (joinOn ));
118114 }
119115
@@ -130,7 +126,7 @@ private static String joinStrings(Object arg, String joinOn) {
130126 * comes in handy in places where non-parameterizable things should be created dynamic, for example matching on
131127 * set of dynamic labels, types order ordering in a dynamic way.
132128 */
133- interface LiteralReplacement {
129+ public interface LiteralReplacement {
134130
135131 /**
136132 * The target of this replacement. While a replacement can be used theoretically everywhere in the query, the target
@@ -155,7 +151,10 @@ private static class StringBasedLiteralReplacement implements LiteralReplacement
155151 * the creation of too many small objects.
156152 */
157153 private static final Map <String , LiteralReplacement > INSTANCES =
158- new LinkedHashMap <String , LiteralReplacement >(DEFAULT_CACHE_SIZE ) {
154+ new LinkedHashMap <>(DEFAULT_CACHE_SIZE ) {
155+ @ Serial
156+ private static final long serialVersionUID = 195460174410223375L ;
157+
159158 @ Override
160159 protected boolean removeEldestEntry (Map .Entry <String , LiteralReplacement > eldest ) {
161160 return size () > DEFAULT_CACHE_SIZE ;
@@ -167,7 +166,7 @@ protected boolean removeEldestEntry(Map.Entry<String, LiteralReplacement> eldest
167166 static LiteralReplacement withTargetAndValue (LiteralReplacement .Target target , @ Nullable String value ) {
168167
169168 String valueUsed = value == null ? "" : value ;
170- String key = new StringBuilder ( target .name ()). append ( "_" ). append ( valueUsed ). toString () ;
169+ String key = target .name () + "_" + valueUsed ;
171170
172171 long stamp = LOCK .tryOptimisticRead ();
173172 if (LOCK .validate (stamp ) && INSTANCES .containsKey (key )) {
0 commit comments