You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@causeway.apache.org by ah...@apache.org on 2025/02/13 14:59:08 UTC

(causeway) branch main updated: CAUSEWAY-3857: minor code simplification

This is an automated email from the ASF dual-hosted git repository.

ahuber pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/causeway.git


The following commit(s) were added to refs/heads/main by this push:
     new 48a94564c0b CAUSEWAY-3857: minor code simplification
48a94564c0b is described below

commit 48a94564c0b41650c16d43716db237aee7a69af5
Author: Andi Huber <ah...@apache.org>
AuthorDate: Thu Feb 13 10:47:06 2025 +0100

    CAUSEWAY-3857: minor code simplification
---
 .../attributes/markup/HighlightBehavior.java           | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/components/attributes/markup/HighlightBehavior.java b/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/components/attributes/markup/HighlightBehavior.java
index 09837989dcb..cf34f19bba0 100644
--- a/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/components/attributes/markup/HighlightBehavior.java
+++ b/viewers/wicket/ui/src/main/java/org/apache/causeway/viewer/wicket/ui/components/attributes/markup/HighlightBehavior.java
@@ -41,13 +41,17 @@ record HighlightBehavior(
     ) {
 
     public static Optional<HighlightBehavior> lookup(final @Nullable SyntaxHighlighter syntaxHighlighter) {
-        if(syntaxHighlighter==null) return Optional.empty();
-        return switch(syntaxHighlighter) {
-            case NONE -> Optional.empty();
-            case PRISM_DEFAULT -> Optional.of(cache.computeIfAbsent(syntaxHighlighter, key->new HighlightBehavior(PrismTheme.DEFAULT)));
-            case PRISM_COY -> Optional.of(cache.computeIfAbsent(syntaxHighlighter, key->new HighlightBehavior(PrismTheme.COY)));
-            default -> throw _Exceptions.unmatchedCase(syntaxHighlighter);
-        };
+        if(syntaxHighlighter==null
+                || syntaxHighlighter==SyntaxHighlighter.NONE) {
+            return Optional.empty();
+        }
+        return Optional.of(cache.computeIfAbsent(syntaxHighlighter, key->
+            switch(syntaxHighlighter) {
+                case PRISM_DEFAULT -> new HighlightBehavior(PrismTheme.DEFAULT);
+                case PRISM_COY -> new HighlightBehavior(PrismTheme.COY);
+                default -> throw _Exceptions.unmatchedCase(syntaxHighlighter);
+            }    
+        ));
     }
     
     private static final Map<SyntaxHighlighter, HighlightBehavior> cache = new ConcurrentHashMap<>();