Giter Club home page Giter Club logo

left-pad-java's Introduction

left-pad for Java 8

Build Status

This is an implementation of the left-pad library with special support for Java 8's Functional paradigm. It is lightweight and supports industrial usage thanks to its 100% test coverage and continuous integration.

It works well with modern libraries like Spring Data and jooq.

Usage

At it's heart, left-pad is easy to use and simple to grasp. However, its interface is built on decades of programming language research.

The simplest usage looks like new LeftPad(length, character).apply(string).

It also supports an advanced functional style whereby you define a new LeftPad functor and apply it as a unary function which accepts a CharSequence.

Example:

LeftPad fourPadded = new LeftPad(4);
fourPadded.apply("foo"); // => " foo"
fourPadded.apply("x");   // => "   x"

// using Java 8 Streams
// this will yield [" x", " y", " z"]
asList("x", "y", "z").stream().map(new LeftPad(2)).collect(Collectors.toList())

LeftPad also supports TDD practices since you always create a LeftPad object instance before calling the function. This makes it easy to mock.

You can even use your favorite dependency injection framework to efficiently pass a configured LeftPad object throughout your code without impacting testability.

Adding to Your Project

Clone this repository, run mvn install, and this project as a dependency.

maven:

<dependency>
    <groupId>net.raboof</groupId>
    <artifactId>left-pad</artifactId>
    <version>1.0-SNAPSHOT</version>
</dependency>

gradle:

compile 'net.raboof:left-pad:1.0-SNAPSHOT'

sbt:

libraryDependencies += "net.raboof" % "left-pad" % "1.0-SNAPSHOT"

license

Licensed under The Apache License, Version 2.0. See the LICENSE file.

left-pad-java's People

Contributors

absurdhero avatar

Stargazers

 avatar  avatar

Watchers

 avatar

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.