Skip to content

Commit b33bbda

Browse files
add StringUtil for repetitive string operations
1 parent 82b11be commit b33bbda

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright 2020 Philipp Salvisberg <philipp.salvisberg@trivadis.com>
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.utplsql.sqldev.dal;
17+
18+
import java.util.Collections;
19+
import java.util.List;
20+
21+
public class StringUtil {
22+
// do not instantiate this class
23+
private StringUtil() {
24+
super();
25+
}
26+
27+
public static String getCSV(List<String> list, int indentSpaces) {
28+
final StringBuilder sb = new StringBuilder();
29+
final String indent = String.join("", Collections.nCopies(indentSpaces, " "));
30+
for (final String path : list) {
31+
if (sb.length() > 0) {
32+
sb.append(",\n");
33+
}
34+
sb.append(indent);
35+
sb.append("'");
36+
sb.append(path);
37+
sb.append("'");
38+
}
39+
sb.append("\n");
40+
return sb.toString();
41+
}
42+
}

0 commit comments

Comments
 (0)