Minestra

A small utilities for Java8.

License

License

Categories

Categories

Net
GroupId

GroupId

net.argius
ArtifactId

ArtifactId

minestra
Last Version

Last Version

1.2.1
Release Date

Release Date

Type

Type

jar
Description

Description

Minestra
A small utilities for Java8.
Project URL

Project URL

http://argius.github.io/minestra/
Source Code Management

Source Code Management

https://github.com/argius/minestra

Download minestra

How to add to project

<!-- https://jarcasting.com/artifacts/net.argius/minestra/ -->
<dependency>
    <groupId>net.argius</groupId>
    <artifactId>minestra</artifactId>
    <version>1.2.1</version>
</dependency>
// https://jarcasting.com/artifacts/net.argius/minestra/
implementation 'net.argius:minestra:1.2.1'
// https://jarcasting.com/artifacts/net.argius/minestra/
implementation ("net.argius:minestra:1.2.1")
'net.argius:minestra:jar:1.2.1'
<dependency org="net.argius" name="minestra" rev="1.2.1">
  <artifact name="minestra" type="jar" />
</dependency>
@Grapes(
@Grab(group='net.argius', module='minestra', version='1.2.1')
)
libraryDependencies += "net.argius" % "minestra" % "1.2.1"
[net.argius/minestra "1.2.1"]

Dependencies

test (6)

Group / Artifact Type Version
junit : junit jar 4.12
org.hamcrest : hamcrest-junit jar 2.0.0.0
ch.qos.logback : logback-core jar 1.1.2
ch.qos.logback : logback-classic jar 1.1.2
org.apache.commons : commons-lang3 jar 3.3.1
org.apache.commons : commons-collections4 jar 4.0

Project Modules

There are no modules declared in this project.

Minestra

Build Status

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
<dependency>
    <groupId>net.argius</groupId>
    <artifactId>minestra</artifactId>
    <version>1.2.1</version>
</dependency>
  • 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<String> 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<String> list1 = IntStream.of(1, 2, 3).mapToObj(x -> "#" + x).collect(Collectors.toList());
List<String> 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<Path> filter1 = PathFilter.sizeGT(100 * 1024L); // file size is larger than 100KB
Predicate<Path> 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<Path> 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.

Versions

Version
1.2.1
1.2.0
1.2.0-RC1
1.1.0
1.1.0-RC1
1.0.0
1.0.0-beta3