Skip to content

Commit 637c616

Browse files
committed
refactor: remove use of lang3 trimToNull
Close #149
1 parent fd49850 commit 637c616

File tree

3 files changed

+64
-2
lines changed

3 files changed

+64
-2
lines changed

src/main/java/com/flowingcode/vaadin/addons/gridhelpers/GridHelperClassNameGenerator.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import java.util.stream.Stream;
3030
import lombok.Getter;
3131
import lombok.Setter;
32-
import org.apache.commons.lang3.StringUtils;
3332

3433
@SuppressWarnings("serial")
3534
final class GridHelperClassNameGenerator<T> implements SerializableFunction<T, String> {

src/main/java/com/flowingcode/vaadin/addons/gridhelpers/HeaderFooterStylesHelper.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
import lombok.RequiredArgsConstructor;
4343
import lombok.SneakyThrows;
4444
import lombok.experimental.Delegate;
45-
import org.apache.commons.lang3.StringUtils;
4645

4746
@SuppressWarnings("serial")
4847
@RequiredArgsConstructor
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*-
2+
* #%L
3+
* Grid Helpers Add-on
4+
* %%
5+
* Copyright (C) 2022 - 2025 Flowing Code
6+
* %%
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* #L%
19+
*/
20+
package com.flowingcode.vaadin.addons.gridhelpers;
21+
/*
22+
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license
23+
* agreements. See the NOTICE file distributed with this work for additional information regarding
24+
* copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
25+
* "License"); you may not use this file except in compliance with the License. You may obtain a
26+
* copy of the License at
27+
*
28+
* http://www.apache.org/licenses/LICENSE-2.0
29+
*
30+
* Unless required by applicable law or agreed to in writing, software distributed under the License
31+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
32+
* or implied. See the License for the specific language governing permissions and limitations under
33+
* the License.
34+
*/
35+
36+
class StringUtils {
37+
38+
/**
39+
* Removes control characters from both ends of this String returning {@code null} if the String
40+
* is empty ("") after the trim or if it is {@code null}.
41+
*
42+
* <pre>
43+
* StringUtils.trimToNull(null) = null
44+
* StringUtils.trimToNull("") = null
45+
* StringUtils.trimToNull(" ") = null
46+
* StringUtils.trimToNull("abc") = "abc"
47+
* StringUtils.trimToNull(" abc ") = "abc"
48+
* </pre>
49+
*
50+
* @param str the String to be trimmed, may be null
51+
* @return the trimmed String, {@code null} if only chars &lt;= 32, empty or null String input
52+
*/
53+
static String trimToNull(String s) {
54+
if (s == null) {
55+
return null;
56+
}
57+
s = s.trim();
58+
if (s.isEmpty()) {
59+
return null;
60+
}
61+
return s;
62+
}
63+
64+
}

0 commit comments

Comments
 (0)