Giter Club home page Giter Club logo

groovy-string-extensions's Introduction

groovy-string-extensions

Build Status Coverage Status Quality Gate Dependency Status Dependency Status Dependencies

Maven Central GitHub release Maven Site Groovydoc

License Sputnik

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.5.0

Download latest scripts

wget https://raw.githubusercontent.com/takari/maven-wrapper/master/mvnw
wget https://raw.githubusercontent.com/takari/maven-wrapper/master/mvnw.cmd

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.