com.codepoetics:ambivalence

Sonatype helps open source projects to set up Maven repositories on https://oss.sonatype.org/

GroupId

GroupId

com.codepoetics
ArtifactId

ArtifactId

ambivalence
Last Version

Last Version

0.2
Release Date

Release Date

Type

Type

bundle
Description

Description

Sonatype helps open source projects to set up Maven repositories on https://oss.sonatype.org/
Source Code Management

Source Code Management

http://github.com/poetix/ambivalence

Download ambivalence

Dependencies

test (2)

Group / Artifact Type Version
junit : junit jar 4.11
org.hamcrest : hamcrest-library jar 1.3

Project Modules

There are no modules declared in this project.

ambivalence

Build Status

<dependency>
    <groupId>com.codepoetics</groupId>
    <artifactId>ambivalence</artifactId>
    <version>0.2</version>
</dependency>

An Either type for Java 8, in case you needed one.

Features:

  • join and forEither to access values safely.
  • left and right projections, with map and flatMap.
  • equals, hashCode and toString implemented.
  • Tryable wraps an exception-throwing lambda so that it returns Either<T, Exception>.
  • Eithers provides Stream collectors which split a stream of Either values and optionally collect the left values.
Either<String, Integer> stringOrInt1 = Either.ofLeft("a string");
Either<String, Integer> stringOrInt2 = Either.ofRight(23);

System.out.println(stringOrInt1.join(String::toUpperCase, Object::toString)); // prints "A STRING"
System.out.println(stringOrInt2.join(String::toUpperCase, Object::toString)); // prints "23"

Versions

Version
0.2