This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/causeway.git
The following commit(s) were added to refs/heads/master by this push:
new 31cfd1c978 CAUSEWAY-3404: purge StringExtensions
31cfd1c978 is described below
commit 31cfd1c978a480c9f302a37785237112f47aa1b6
Author: Andi Huber <[email protected]>
AuthorDate: Thu May 11 18:57:43 2023 +0200
CAUSEWAY-3404: purge StringExtensions
---
.../org/apache/causeway/applib/util/EnumsTest.java | 18 +++
.../causeway/commons/internal/base/_Strings.java | 37 ++++--
.../commons/internal/base/StringsTest.java | 23 ++++
.../progmodel/ProgrammingModelConstants.java | 2 +-
.../core/metamodel/commons/StringExtensions.java | 131 ---------------------
.../core/metamodel/facetapi/FeatureType.java | 6 +-
.../update/PropertySetterFacetFactory.java | 4 +-
.../commons/StringUtilsTest_enumTitle.java | 40 -------
.../StringUtils_RemoveLeadingWhiteSpace.java | 52 --------
.../commons/StringUtils_StripLeadingSlashTest.java | 25 ++--
.../commons/StringUtils_StripNewLinesTest.java | 58 ---------
.../templresources/TemplateResourceServlet.java | 3 +-
.../core/webapp/routing/RedirectFilter.java | 4 +-
.../core/webapp/routing/RedirectServlet.java | 4 +-
.../CausewayRestfulObjectsInteractionFilter.java | 4 +-
15 files changed, 98 insertions(+), 313 deletions(-)
diff --git
a/api/applib/src/test/java/org/apache/causeway/applib/util/EnumsTest.java
b/api/applib/src/test/java/org/apache/causeway/applib/util/EnumsTest.java
index 9d7c30b6e0..817826b5c6 100644
--- a/api/applib/src/test/java/org/apache/causeway/applib/util/EnumsTest.java
+++ b/api/applib/src/test/java/org/apache/causeway/applib/util/EnumsTest.java
@@ -39,4 +39,22 @@ class EnumsTest {
assertThat(Enums.getEnumNameFromFriendly("All Tables"),
is("ALL_TABLES"));
}
+ @Test
+ void enumTitle() {
+ assertThat(enumTitle("FOO"), is("Foo"));
+ assertThat(enumTitle("FOO_BAR"), is("Foo Bar"));
+ }
+ private static String enumTitle(final String enumName) {
+ return Enums.getFriendlyNameOf(enumName);
+ }
+
+ @Test
+ void enumDeTitle() {
+ assertThat(enumDeTitle("Foo"), is("FOO"));
+ assertThat(enumDeTitle("Foo Bar"), is("FOO_BAR"));
+ }
+ private static String enumDeTitle(final String enumFriendlyName) {
+ return Enums.getEnumNameFromFriendly(enumFriendlyName);
+ }
+
}
diff --git
a/commons/src/main/java/org/apache/causeway/commons/internal/base/_Strings.java
b/commons/src/main/java/org/apache/causeway/commons/internal/base/_Strings.java
index 38dfd8f92c..b136de62be 100644
---
a/commons/src/main/java/org/apache/causeway/commons/internal/base/_Strings.java
+++
b/commons/src/main/java/org/apache/causeway/commons/internal/base/_Strings.java
@@ -48,6 +48,7 @@ import java.util.stream.StreamSupport;
import org.springframework.lang.Nullable;
import org.apache.causeway.commons.internal._Constants;
+import org.apache.causeway.commons.internal.assertions._Assert;
import org.apache.causeway.commons.internal.base._Bytes.BytesOperator;
import org.apache.causeway.commons.internal.functions._Predicates;
@@ -411,6 +412,15 @@ public final class _Strings {
return input + suffix;
}
+ public static @Nullable String removePrefix(final @Nullable String input,
final @NonNull String prefix) {
+ if(input==null) {
+ return null;
+ }
+ return input.startsWith(prefix)
+ ? input.substring(prefix.length())
+ : input;
+ }
+
// -- REDUCTION (BINARY OPERATIOR)
/**
@@ -847,27 +857,38 @@ public final class _Strings {
}
/**
- * A prefix is defined
+ * Returns the name of a Java entity without any prefix. A prefix is
defined
* as the first set of lower-case letters and the name is characters from,
* and including, the first upper case letter. If no upper case letter is
* found then an empty string is returned.
+ *
* <p>
* Calling this method with the following Java names will produce these
* results:
+ *
* <pre>
- * getCarRegistration -> CarRegistration
- * CityMayor -> CityMayor
- * isReady -> Ready
+ * getCarRegistration -> CarRegistration
+ * CityMayor -> CityMayor
+ * isReady -> Ready
* </pre>
+ *
*/
- public static final String asPrefixDropped(final @Nullable CharSequence
chars) {
- return isNotEmpty(chars)
+ public static String baseName(final @NonNull String methodName) {
+ val asPrefixDropped = isNotEmpty(methodName)
? ofCodePoints(
- chars.codePoints()
+ methodName.codePoints()
.dropWhile(c->c != '_' &&
Character.isLowerCase(c)))
- : chars!=null ? "" : null;
+ : methodName!=null ? "" : null;
+ val baseName = asPrefixDropped.isEmpty()
+ ? methodName
+ : asPrefixDropped;
+ val javaBaseName = _Strings.capitalize(baseName.trim());
+ _Assert.assertNotEmpty(javaBaseName,
+ ()->String.format("framework bug: could not create a base name
from '%s'", methodName));
+ return javaBaseName;
}
+
/**
* Within given string, converts any special UTF-8 variants of the space '
' character to the regular one.
*/
diff --git
a/commons/src/test/java/org/apache/causeway/commons/internal/base/StringsTest.java
b/commons/src/test/java/org/apache/causeway/commons/internal/base/StringsTest.java
index c9e6162335..d4c0135dd1 100644
---
a/commons/src/test/java/org/apache/causeway/commons/internal/base/StringsTest.java
+++
b/commons/src/test/java/org/apache/causeway/commons/internal/base/StringsTest.java
@@ -373,4 +373,27 @@ class StringsTest {
return _Strings.asLowerDashed.apply(string);
}
+ // -- PREFIX/SUFFIX
+
+ @Test
+ void shouldStripIfThereIsOne() {
+ assertThat(stripLeadingSlash("/foobar"), is("foobar"));
+ }
+ @Test
+ void shouldLeaveUnchangedIfThereIsNone() {
+ assertThat(stripLeadingSlash("foobar"), is("foobar"));
+ }
+ @Test
+ void shouldConvertSolitarySlashToEmptyString() {
+ assertThat(stripLeadingSlash("/"), is(""));
+ }
+ @Test
+ void identityOnNull() {
+ assertNull(stripLeadingSlash(null));
+ }
+ private static String stripLeadingSlash(final String input) {
+ return _Strings.removePrefix(input, "/");
+ }
+
+
}
diff --git
a/core/config/src/main/java/org/apache/causeway/core/config/progmodel/ProgrammingModelConstants.java
b/core/config/src/main/java/org/apache/causeway/core/config/progmodel/ProgrammingModelConstants.java
index 682906fe31..7d43a134d7 100644
---
a/core/config/src/main/java/org/apache/causeway/core/config/progmodel/ProgrammingModelConstants.java
+++
b/core/config/src/main/java/org/apache/causeway/core/config/progmodel/ProgrammingModelConstants.java
@@ -765,7 +765,7 @@ public final class ProgrammingModelConstants {
return _Strings.capitalize(methodName);
}
// must be a getter
- return _Strings.capitalize(_Strings.asPrefixDropped(methodName));
+ return _Strings.baseName(methodName);
}
// must be a field then
return _Strings.capitalize(member.getName());
diff --git
a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/commons/StringExtensions.java
b/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/commons/StringExtensions.java
deleted file mode 100644
index 0a48d88d7a..0000000000
---
a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/commons/StringExtensions.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.causeway.core.metamodel.commons;
-
-import org.apache.causeway.applib.util.Enums;
-import org.apache.causeway.commons.internal.assertions._Assert;
-import org.apache.causeway.commons.internal.base._Strings;
-import org.apache.causeway.commons.internal.resources._Resources;
-
-import lombok.NonNull;
-import lombok.val;
-
-public final class StringExtensions {
-
- // ////////////////////////////////////////////////////////////
- // removeTabs, removeLeadingWhiteSpace, stripLeadingSlash, stripNewLines,
- // normalize
- // ////////////////////////////////////////////////////////////
-
- public static String removeLeadingWhiteSpace(final String extendee) {
- if (extendee == null) {
- return null;
- }
- return extendee.replaceAll("^\\W*", "");
- }
-
- public static String stripNewLines(final String extendee) {
- return extendee.replaceAll("[\r\n]", "");
- }
-
- public static String stripLeadingSlash(final String extendee) {
- if (!extendee.startsWith("/")) {
- return extendee;
- }
- if (extendee.length() < 2) {
- return "";
- }
- return extendee.substring(1);
- }
-
- public static String removePrefix(final String extendee, final String
prefix) {
- return extendee.startsWith(prefix)
- ? extendee.substring(prefix.length())
- : extendee;
- }
-
- public static String enumTitle(final String enumName) {
- return Enums.getFriendlyNameOf(enumName);
- }
-
- public static String enumDeTitle(final String enumFriendlyName) {
- return Enums.getEnumNameFromFriendly(enumFriendlyName);
- }
-
- /*
- * eg converts <tt>HiddenFacetForMemberAnnotation</tt> to <tt>HFFMA</tt>.
- */
- public static String toAbbreviation(final String extendee) {
- final StringBuilder buf = new StringBuilder();
- for(char c: extendee.toCharArray()) {
- if(Character.isUpperCase(c)) {
- buf.append(c);
- }
- }
- return buf.toString();
- }
-
-
- // //////////////////////////////////////
- // copied in from Apache Commons
- // //////////////////////////////////////
-
- public static boolean startsWith(final String extendee, final String
prefix) {
- final int length = prefix.length();
- if (length >= extendee.length()) {
- return false;
- } else {
- final char startingCharacter = extendee.charAt(length);
- return extendee.startsWith(prefix) &&
Character.isUpperCase(startingCharacter);
- }
- }
-
- public static String combinePath(final String extendee, final String
suffix) {
- return _Resources.combinePath(extendee, suffix);
- }
-
- /**
- * Returns the name of a Java entity without any prefix. A prefix is
defined
- * as the first set of lower-case letters and the name is characters from,
- * and including, the first upper case letter. If no upper case letter is
- * found then an empty string is returned.
- *
- * <p>
- * Calling this method with the following Java names will produce these
- * results:
- *
- * <pre>
- * getCarRegistration -> CarRegistration
- * CityMayor -> CityMayor
- * isReady -> Ready
- * </pre>
- *
- */
- public static String asJavaBaseName(final @NonNull String javaName) {
- val asPrefixDropped = _Strings.asPrefixDropped(javaName);
- val baseName = asPrefixDropped.isEmpty()
- ? javaName
- : asPrefixDropped;
- val javaBaseName = _Strings.capitalize(baseName.trim());
- _Assert.assertNotEmpty(javaBaseName,
- ()->String.format("framework bug: could not create a base name
from '%s'", javaName));
- return javaBaseName;
- }
-
-}
diff --git
a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facetapi/FeatureType.java
b/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facetapi/FeatureType.java
index 5e838412a7..fac48583ea 100644
---
a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facetapi/FeatureType.java
+++
b/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facetapi/FeatureType.java
@@ -24,8 +24,8 @@ import java.lang.reflect.Method;
import org.apache.causeway.applib.Identifier;
import org.apache.causeway.applib.id.LogicalType;
import org.apache.causeway.commons.collections.ImmutableEnumSet;
+import org.apache.causeway.commons.internal.base._Strings;
import
org.apache.causeway.commons.internal.reflection._MethodFacades.MethodFacade;
-import org.apache.causeway.core.metamodel.commons.StringExtensions;
import org.apache.causeway.core.metamodel.facets.FacetFactory;
/**
@@ -123,7 +123,7 @@ public enum FeatureType {
private static Identifier propertyIdentifierFor(
final LogicalType typeIdentifier,
final Method method) {
- final String capitalizedName =
StringExtensions.asJavaBaseName(method.getName());
+ final String capitalizedName = _Strings.baseName(method.getName());
final String beanName = Introspector.decapitalize(capitalizedName);
return Identifier.propertyIdentifier(typeIdentifier, beanName);
}
@@ -131,7 +131,7 @@ public enum FeatureType {
private static Identifier collectionIdentifierFor(
final LogicalType typeIdentifier,
final Method method) {
- final String capitalizedName =
StringExtensions.asJavaBaseName(method.getName());
+ final String capitalizedName = _Strings.baseName(method.getName());
final String beanName = Introspector.decapitalize(capitalizedName);
return Identifier.collectionIdentifier(typeIdentifier, beanName);
}
diff --git
a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/properties/update/PropertySetterFacetFactory.java
b/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/properties/update/PropertySetterFacetFactory.java
index de172fd507..58f5c0c5c5 100644
---
a/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/properties/update/PropertySetterFacetFactory.java
+++
b/core/metamodel/src/main/java/org/apache/causeway/core/metamodel/facets/properties/update/PropertySetterFacetFactory.java
@@ -21,9 +21,9 @@ package
org.apache.causeway.core.metamodel.facets.properties.update;
import javax.inject.Inject;
import org.apache.causeway.commons.collections.Can;
+import org.apache.causeway.commons.internal.base._Strings;
import
org.apache.causeway.core.config.progmodel.ProgrammingModelConstants.AccessorPrefix;
import
org.apache.causeway.core.config.progmodel.ProgrammingModelConstants.ReturnTypeCategory;
-import org.apache.causeway.core.metamodel.commons.StringExtensions;
import org.apache.causeway.core.metamodel.context.MetaModelContext;
import org.apache.causeway.core.metamodel.facetapi.FacetHolder;
import org.apache.causeway.core.metamodel.facetapi.FeatureType;
@@ -52,7 +52,7 @@ extends MethodPrefixBasedFacetFactoryAbstract {
public void process(final ProcessMethodContext processMethodContext) {
val getterMethod = processMethodContext.getMethod();
- final String capitalizedName =
StringExtensions.asJavaBaseName(getterMethod.getName());
+ final String capitalizedName =
_Strings.baseName(getterMethod.getName());
val methodNameCandidates = Can.ofSingleton(
AccessorPrefix.SET.prefix(capitalizedName));
diff --git
a/core/metamodel/src/test/java/org/apache/causeway/core/metamodel/commons/StringUtilsTest_enumTitle.java
b/core/metamodel/src/test/java/org/apache/causeway/core/metamodel/commons/StringUtilsTest_enumTitle.java
deleted file mode 100644
index 60702c7b5e..0000000000
---
a/core/metamodel/src/test/java/org/apache/causeway/core/metamodel/commons/StringUtilsTest_enumTitle.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.causeway.core.metamodel.commons;
-
-import org.junit.jupiter.api.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-class StringUtilsTest_enumTitle {
-
- @Test
- public void enumTitle() {
- assertThat(StringExtensions.enumTitle("FOO"), is("Foo"));
- assertThat(StringExtensions.enumTitle("FOO_BAR"), is("Foo Bar"));
- }
-
- @Test
- public void enumDeTitle() {
- assertThat(StringExtensions.enumDeTitle("Foo"), is("FOO"));
- assertThat(StringExtensions.enumDeTitle("Foo Bar"), is("FOO_BAR"));
- }
-
-}
diff --git
a/core/metamodel/src/test/java/org/apache/causeway/core/metamodel/commons/StringUtils_RemoveLeadingWhiteSpace.java
b/core/metamodel/src/test/java/org/apache/causeway/core/metamodel/commons/StringUtils_RemoveLeadingWhiteSpace.java
deleted file mode 100644
index dbe49dbeed..0000000000
---
a/core/metamodel/src/test/java/org/apache/causeway/core/metamodel/commons/StringUtils_RemoveLeadingWhiteSpace.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.causeway.core.metamodel.commons;
-
-import org.hamcrest.CoreMatchers;
-import org.junit.jupiter.api.Test;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-
-class StringUtils_RemoveLeadingWhiteSpace {
-
- @Test
- public void whenHasLeadingWhiteSpace() {
- final String removed = StringExtensions.removeLeadingWhiteSpace("
foo");
- assertThat(removed, CoreMatchers.is("foo"));
- }
-
- @Test
- public void whenNoLeadingWhiteSpace() {
- final String removed = StringExtensions.removeLeadingWhiteSpace("foo");
- assertThat(removed, CoreMatchers.is("foo"));
- }
-
- @Test
- public void empty() {
- final String removed = StringExtensions.removeLeadingWhiteSpace("");
- assertThat(removed, CoreMatchers.is(""));
- }
-
- @Test
- public void whenNull() {
- final String removed = StringExtensions.removeLeadingWhiteSpace(null);
- assertThat(removed, CoreMatchers.is(CoreMatchers.nullValue()));
- }
-
-}
diff --git
a/core/metamodel/src/test/java/org/apache/causeway/core/metamodel/commons/StringUtils_StripLeadingSlashTest.java
b/core/metamodel/src/test/java/org/apache/causeway/core/metamodel/commons/StringUtils_StripLeadingSlashTest.java
index 05b5727ac6..99d185f8bc 100644
---
a/core/metamodel/src/test/java/org/apache/causeway/core/metamodel/commons/StringUtils_StripLeadingSlashTest.java
+++
b/core/metamodel/src/test/java/org/apache/causeway/core/metamodel/commons/StringUtils_StripLeadingSlashTest.java
@@ -22,29 +22,34 @@ import org.junit.jupiter.api.Test;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+import org.apache.causeway.commons.internal.base._Strings;
class StringUtils_StripLeadingSlashTest {
@Test
- public void shouldStripIfThereIsOne() {
- assertThat(StringExtensions.stripLeadingSlash("/foobar"),
is("foobar"));
+ void shouldStripIfThereIsOne() {
+ assertThat(stripLeadingSlash("/foobar"), is("foobar"));
}
@Test
- public void shouldLeaveUnchangedIfThereIsNone() {
- assertThat(StringExtensions.stripLeadingSlash("foobar"), is("foobar"));
+ void shouldLeaveUnchangedIfThereIsNone() {
+ assertThat(stripLeadingSlash("foobar"), is("foobar"));
}
@Test
- public void shouldConvertSolitarySlashToEmptyString() {
- assertThat(StringExtensions.stripLeadingSlash("/"), is(""));
+ void shouldConvertSolitarySlashToEmptyString() {
+ assertThat(stripLeadingSlash("/"), is(""));
}
@Test
- public void shouldFailOnNull() {
- assertThrows(NullPointerException.class, ()->
- StringExtensions.stripLeadingSlash(null));
+ void identityOnNull() {
+ assertNull(stripLeadingSlash(null));
+ }
+
+ private static String stripLeadingSlash(final String input) {
+ return _Strings.removePrefix(input, "/");
}
}
diff --git
a/core/metamodel/src/test/java/org/apache/causeway/core/metamodel/commons/StringUtils_StripNewLinesTest.java
b/core/metamodel/src/test/java/org/apache/causeway/core/metamodel/commons/StringUtils_StripNewLinesTest.java
deleted file mode 100644
index 8124aa9280..0000000000
---
a/core/metamodel/src/test/java/org/apache/causeway/core/metamodel/commons/StringUtils_StripNewLinesTest.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.causeway.core.metamodel.commons;
-
-import org.junit.jupiter.api.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-class StringUtils_StripNewLinesTest {
-
- @Test
- public void shouldDoNothingIfNone() {
- assertThat(StringExtensions.stripNewLines("abc"), is("abc"));
- }
-
- @Test
- public void shouldStripIfJustBackslashN() {
- assertThat(StringExtensions.stripNewLines("abc\n"), is("abc"));
- }
-
- @Test
- public void shouldStripIfBackslashRBackslashN() {
- assertThat(StringExtensions.stripNewLines("abc\r\n"), is("abc"));
- }
-
- @Test
- public void shouldStripIfJustBackslashR() {
- assertThat(StringExtensions.stripNewLines("abc\r"), is("abc"));
- }
-
- @Test
- public void shouldStripIfSeveral() {
- assertThat(StringExtensions.stripNewLines("abc\r\ndef\r\n"),
is("abcdef"));
- }
-
- @Test
- public void shouldStripIfBackslashRBackslashNBackslashR() {
- assertThat(StringExtensions.stripNewLines("abc\n\r\ndef"),
is("abcdef"));
- }
-
-}
diff --git
a/core/webapp/src/main/java/org/apache/causeway/core/webapp/modules/templresources/TemplateResourceServlet.java
b/core/webapp/src/main/java/org/apache/causeway/core/webapp/modules/templresources/TemplateResourceServlet.java
index ab465f01c4..3f305ab4a5 100644
---
a/core/webapp/src/main/java/org/apache/causeway/core/webapp/modules/templresources/TemplateResourceServlet.java
+++
b/core/webapp/src/main/java/org/apache/causeway/core/webapp/modules/templresources/TemplateResourceServlet.java
@@ -38,7 +38,6 @@ import org.apache.causeway.core.config.RestEasyConfiguration;
import org.apache.causeway.core.config.viewer.web.WebAppContextPath;
import org.apache.causeway.core.metamodel.commons.InputStreamExtensions;
import org.apache.causeway.core.metamodel.commons.ResourceUtil;
-import org.apache.causeway.core.metamodel.commons.StringExtensions;
import static org.apache.causeway.commons.internal.base._Strings.pair;
@@ -79,7 +78,7 @@ public class TemplateResourceServlet extends HttpServlet {
// -- HELPER
private void processRequest(final HttpServletRequest request, final
HttpServletResponse response) {
- final String servletPath =
StringExtensions.stripLeadingSlash(request.getServletPath());
+ final String servletPath =
_Strings.removePrefix(request.getServletPath(), "/");
log.debug("request: {}", servletPath);
val resourceInputStream = Optional
diff --git
a/core/webapp/src/main/java/org/apache/causeway/core/webapp/routing/RedirectFilter.java
b/core/webapp/src/main/java/org/apache/causeway/core/webapp/routing/RedirectFilter.java
index 3eab1bccac..10e49ab2d0 100644
---
a/core/webapp/src/main/java/org/apache/causeway/core/webapp/routing/RedirectFilter.java
+++
b/core/webapp/src/main/java/org/apache/causeway/core/webapp/routing/RedirectFilter.java
@@ -29,7 +29,7 @@ import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.apache.causeway.core.metamodel.commons.StringExtensions;
+import org.apache.causeway.commons.internal.resources._Resources;
public class RedirectFilter implements Filter {
@@ -49,7 +49,7 @@ public class RedirectFilter implements Filter {
final HttpServletRequest httpServletRequest = (HttpServletRequest)
request;
final HttpServletResponse httpServletResponse = (HttpServletResponse)
response;
-
httpServletResponse.sendRedirect(StringExtensions.combinePath(httpServletRequest.getContextPath(),
redirectTo));
+
httpServletResponse.sendRedirect(_Resources.combinePath(httpServletRequest.getContextPath(),
redirectTo));
}
@Override
diff --git
a/core/webapp/src/main/java/org/apache/causeway/core/webapp/routing/RedirectServlet.java
b/core/webapp/src/main/java/org/apache/causeway/core/webapp/routing/RedirectServlet.java
index 3d0d2d3483..715a23ec12 100644
---
a/core/webapp/src/main/java/org/apache/causeway/core/webapp/routing/RedirectServlet.java
+++
b/core/webapp/src/main/java/org/apache/causeway/core/webapp/routing/RedirectServlet.java
@@ -26,7 +26,7 @@ import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.apache.causeway.core.metamodel.commons.StringExtensions;
+import org.apache.causeway.commons.internal.resources._Resources;
import lombok.extern.log4j.Log4j2;
@@ -45,7 +45,7 @@ public class RedirectServlet extends HttpServlet {
protected void doGet(final HttpServletRequest request, final
HttpServletResponse response) throws ServletException, IOException {
try {
-
response.sendRedirect(StringExtensions.combinePath(request.getContextPath(),
redirectTo));
+
response.sendRedirect(_Resources.combinePath(request.getContextPath(),
redirectTo));
} catch (Exception e) {
log.error("failed to redirect request to {}", redirectTo, e);
}
diff --git
a/viewers/restfulobjects/viewer/src/main/java/org/apache/causeway/viewer/restfulobjects/viewer/webmodule/CausewayRestfulObjectsInteractionFilter.java
b/viewers/restfulobjects/viewer/src/main/java/org/apache/causeway/viewer/restfulobjects/viewer/webmodule/CausewayRestfulObjectsInteractionFilter.java
index 8f4c3c49aa..350ea3c233 100644
---
a/viewers/restfulobjects/viewer/src/main/java/org/apache/causeway/viewer/restfulobjects/viewer/webmodule/CausewayRestfulObjectsInteractionFilter.java
+++
b/viewers/restfulobjects/viewer/src/main/java/org/apache/causeway/viewer/restfulobjects/viewer/webmodule/CausewayRestfulObjectsInteractionFilter.java
@@ -47,7 +47,7 @@ import org.apache.causeway.commons.internal.base._Strings;
import org.apache.causeway.commons.internal.collections._Lists;
import org.apache.causeway.commons.internal.exceptions._Exceptions;
import org.apache.causeway.commons.internal.factory._InstanceUtil;
-import org.apache.causeway.core.metamodel.commons.StringExtensions;
+import org.apache.causeway.commons.internal.resources._Resources;
import org.apache.causeway.core.metamodel.specloader.SpecificationLoader;
import
org.apache.causeway.core.metamodel.specloader.validator.MetaModelInvalidException;
import
org.apache.causeway.core.webapp.modules.templresources.TemplateResourceCachingFilter;
@@ -162,7 +162,7 @@ public class CausewayRestfulObjectsInteractionFilter
implements Filter {
private List<String> passThruList = Collections.emptyList();
static void redirect(final HttpServletRequest httpRequest, final
HttpServletResponse httpResponse, final String redirectTo) throws IOException {
-
httpResponse.sendRedirect(StringExtensions.combinePath(httpRequest.getContextPath(),
redirectTo));
+
httpResponse.sendRedirect(_Resources.combinePath(httpRequest.getContextPath(),
redirectTo));
}
public enum WhenNoSession {