Skip to content

Commit c86f04f

Browse files
javier-godoypaodb
authored andcommitted
refactor: remove use of lang3 trimToNull
Close #149
1 parent 5c0683d commit c86f04f

File tree

3 files changed

+68
-2
lines changed

3 files changed

+68
-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: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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+
import lombok.experimental.UtilityClass;
23+
24+
/*
25+
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license
26+
* agreements. See the NOTICE file distributed with this work for additional information regarding
27+
* copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
28+
* "License"); you may not use this file except in compliance with the License. You may obtain a
29+
* copy of the License at
30+
*
31+
* http://www.apache.org/licenses/LICENSE-2.0
32+
*
33+
* Unless required by applicable law or agreed to in writing, software distributed under the License
34+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
35+
* or implied. See the License for the specific language governing permissions and limitations under
36+
* the License.
37+
*/
38+
39+
@UtilityClass
40+
class StringUtils {
41+
42+
/**
43+
* Removes control characters from both ends of this String returning {@code null} if the String
44+
* is empty ("") after the trim or if it is {@code null}.
45+
*
46+
* <pre>
47+
* StringUtils.trimToNull(null) = null
48+
* StringUtils.trimToNull("") = null
49+
* StringUtils.trimToNull(" ") = null
50+
* StringUtils.trimToNull("abc") = "abc"
51+
* StringUtils.trimToNull(" abc ") = "abc"
52+
* </pre>
53+
*
54+
* @param str the String to be trimmed, may be null
55+
* @return the trimmed String, {@code null} if only chars &lt;= 32, empty or null String input
56+
*/
57+
static String trimToNull(String str) {
58+
if (str == null) {
59+
return null;
60+
}
61+
str = str.trim();
62+
if (str.isEmpty()) {
63+
return null;
64+
}
65+
return str;
66+
}
67+
68+
}

0 commit comments

Comments
 (0)