groovy-string-extensions
A (very small) collection of Groovy (v2.0+) extensions for String and GString.
Maven:
<dependency>
<groupId>org.venutolo</groupId>
<artifactId>groovy-string-extensions</artifactId>
<version>0.1.0</version>
</dependency>
Gradle:
compile 'org.venutolo:groovy-string-extensions:0.1.0'
Extensions Methods
Note: The GString methods do not modify the GString instance, and instead return a separate GString instance. The GString methods also do not modify the embedded values.
.joinLines()
static String joinLines(String self)
static GString joinLines(GString self)
Provides a method to trim leading and trailing whitespace and join multiple with a single space.
Example:
String s = '''
This is a multi-line String
that I want to join into one
single line.
'''
assert s.joinLines() == 'This is a multi-line String that I want to join into one single line.'
.trimAndCollapseWhitespace()
static String trimAndCollapseWhitespace(String self)
static String trimAndCollapseWhitespace(GString self)
Provides a method to trim leading and trailing whitespace and collapse multiple whitespace characters to one single space.
Example:
GString query = """
SELECT *
FROM cities
WHERE country = ${country}
AND region = ${region}
"""
assert query.trimAndCollapseWhitespace() == "SELECT * FROM cities WHERE country = ${country} AND region = ${region}"
Make Release
./mvnw -B release:clean release:prepare release:perform
Update Maven Wrapper
Use Maven Wrapper plugin
mvn -N io.takari:maven:wrapper -Dmaven=3.3.9
Download latest scripts
wget https://raw.githubusercontent.com/takari/maven-wrapper/master/mvnw
wget https://raw.githubusercontent.com/takari/maven-wrapper/master/mvnw.cmd