https://github.com/argius/minestra
A small utilities library for Java 8 and later.
https://github.com/argius/minestra
collection java library utilities
Last synced: 6 months ago
JSON representation
A small utilities library for Java 8 and later.
- Host: GitHub
- URL: https://github.com/argius/minestra
- Owner: argius
- License: apache-2.0
- Created: 2015-07-09T14:18:48.000Z (almost 11 years ago)
- Default Branch: develop
- Last Pushed: 2020-01-27T15:31:10.000Z (over 6 years ago)
- Last Synced: 2024-12-12T09:18:23.121Z (over 1 year ago)
- Topics: collection, java, library, utilities
- Language: Java
- Homepage: http://argius.github.io/minestra/
- Size: 710 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Minestra
========
[](https://travis-ci.org/argius/minestra)
Minestra is a small utilities library for Java8 and later.
The word 'minestra' means soup in Italian. I love soups and there is no particular meaning for this name.
See "Examples" section if you want to know more about features in this library.
* Minestra has been compiled with compact1 profile.
site: http://argius.github.io/minestra/
Dependency
----------
You can download Minestra from Maven Central.
MvnRepository URL: https://mvnrepository.com/artifact/net.argius/minestra
- Maven
```
net.argius
minestra
1.2.1
```
- Gradle
```
compile 'net.argius:minestra:1.2.1'
```
Examples
--------
See also test classes.
### ImmArray
The classes of `ImmArray` are mere array wrappers and provides functional operations without functional DSL.
Neither pipeline nor any performance improvement strategies.
```
// import java.util.*;
// import minestra.collection.*;
ImmArray a = ImmArray.of(Arrays.asList("1"), Optional.of("2"), ImmArray.of("3", "A"),
Optional.empty(), Arrays.asList("5"), "B", Stream.of("6", "7"))
.flatten();
for (String s : a) {
System.out.printf("%s, ", s);
}
// => 1, 2, 3, A, 5, B, 6, 7,
```
```
// import java.util.*;
// import java.util.stream.*;
// import minestra.collection.*;
List list1 = IntStream.of(1, 2, 3).mapToObj(x -> "#" + x).collect(Collectors.toList());
List list2 = IntImmArray.of(1, 2, 3).mapToObj(x -> "#" + x).toList();
```
### PathIterator and PathFilter
`PathIterator` is an iterator which walks through a file tree like `Files.find()`.
`PathFilter` is a filter-generator for filtering objects of `java.nio.file.Path`.
```
// import java.time.*;
// import java.nio.file.*;
// import minestra.file.*;
Predicate filter1 = PathFilter.sizeGT(100 * 1024L); // file size is larger than 100KB
Predicate filter2 = PathFilter.mtimeBetween(
Instant.parse("2017-04-01T00:00:00Z"), Instant.parse("2018-03-31T23:59:59Z")
); // mtime is between 2017-04-01 and 2018-03-31T23:59:59 (UTC)
Predicate filter3 = filter1.and(filter2);
PathIterator.streamOf(Paths.get("/tmp"))
.filter(filter3)
.forEach(System.out::println);
for (Path x : PathIterator.of(Paths.get("/tmp"))) {
if (filter3.test(x)) {
System.out.println(x);
}
}
```
### PathString
`PathString` is an extension of `java.nio.file.Path` .
```
// import minestra.file.PathString;
PathString path1 = PathString.of("/tmp/file.dat");
System.out.println(path1.extension()); // => Optional[dat]
PathString path2 = PathString.of("/tmp/file");
System.out.println(path2.extension()); // => Optional.empty
```
### LetterCaseConverter
`LetterCaseConverter` is a letter-case converter.
```
// import java.util.Arrays;
// import minestra.text.*;
String[] a = {
LetterCaseConverter.capitalize("hello"),
LetterCaseConverter.uncapitalize("World"),
LetterCaseConverter.toCamelCase("read_all_files"),
LetterCaseConverter.toPascalCase("forget-me-not"),
LetterCaseConverter.toSnakeCase("CaseConverter"),
LetterCaseConverter.toChainCase("toString")};
System.out.println(Arrays.toString(a));
// => [Hello, world, readAllFiles, ForgetMeNot, case_converter, to-string]
```
### PropsRef, ResourceSheaf
`PropsRef` provides access to Properties.
`ResourceSheaf` is similar to `ResourceBundle`, and provides access to message resources.
```
// import java.util.*;
// import minestra.text.*;
// resource file:
// minestra/messages_en
// key1=en
// minestra/messages
// key1=no-suffix
// key2=MSG
ResourceSheaf res = ResourceSheaf.create(getClass()).withLocation("minestra/").withMessages().withLocales(Locale.ENGLISH);
Properties props = new Properties();
props.setProperty("key1", "A");
props.setProperty("key2", "B");
props.setProperty("key3", "C");
PropsRef pr = PropsRef.aggregate(res, PropsRef.wrap(props));
pr.getProperty("key1"); // => en
pr.string("key1"); // => en
pr.string("key2"); // => MSG
pr.string("key3"); // => C
```
License
-------
Apache 2.0 License.