https://github.com/guybedo/sugar
Helpers for java
https://github.com/guybedo/sugar
Last synced: about 1 year ago
JSON representation
Helpers for java
- Host: GitHub
- URL: https://github.com/guybedo/sugar
- Owner: guybedo
- Created: 2024-03-01T18:46:15.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2025-01-28T19:33:28.000Z (over 1 year ago)
- Last Synced: 2025-04-05T15:11:20.219Z (about 1 year ago)
- Language: Java
- Homepage:
- Size: 51.8 KB
- Stars: 13
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
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
```Java
Map newMap = map(kv("key1", "value1"), kv("key1", "value1"), kv("key1", "value1"));
List 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 counts = counts(objects, o -> o.getProfile());
```
## POJOs
```Java
orElse("test", s -> s + "_ok", null);
ifPresent("test", s -> System.out.println(s));
isoDateTime(LocalDateTime.now());
```
Getting Started
---------------
Maven
-----
```xml
com.akalea
sugar
0.0.13
```
Import functions
----------------
```Java
import static com.akalea.sugar.Collections.*;
import static com.akalea.sugar.Pojos.*;
```