Code Monkey home page Code Monkey logo

sugar's Introduction

Sugar

Sugar for Java

What is this?

Sugar is a small utils library providing static functions to write less verbose Java code.

Nothing groundbreaking here, just some sugar.

Features:

  • Create/Manipulate collections: set, list, map, partition, product, intersect, counts, sums
  • Collection helpers: first, last, sorted, max, min, mean, sum, prepend, append, concat, zip
  • Random: random string, random char, choose elements in collection
  • Parallel: pEach, pMap

Examples

Collections

Map<String, String> newMap = map(kv("key1", "value1"), kv("key1", "value1"), kv("key1", "value1"));

List<Integer> values = list(1,2,3,4);
Integer min = min(values);
Integer last = last(values);
Integer one = first(filter(values,v -> v == 1));
values = map(values, v -> v + 1);

Map<Profile, Integer> counts = counts(objects, o -> o.getProfile());

POJOs

orElse("test", s -> s + "_ok", null);
ifPresent("test", s -> System.out.println(s));
isoDateTime(LocalDateTime.now());

Getting Started

Maven

<dependency>
    <groupId>com.akalea</groupId>
    <artifactId>sugar</artifactId>
    <version>0.0.8</version>
</dependency>

Import functions

import static com.akalea.sugar.Collections.*;
import static com.akalea.sugar.Pojos.*;

sugar's People

Contributors

guybedo avatar bowbahdoe avatar

Stargazers

Davide R. Wiest avatar Gabriel Sales avatar Jaisung Lee avatar Nishant Aanjaney Jalan avatar Uwe Schaefer avatar Taketoday avatar John Mercier avatar  avatar Clayton Kehoe avatar Richard Lawson avatar Mr. J avatar Jochen Bedersdorfer avatar  avatar Thierry Uriot avatar

Watchers

 avatar  avatar

Forkers

bowbahdoe

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.