Skip navigation links

Package javaslang.control

Control structures like the disjoint union type Either, the optional value type Option and Try for exception handling.

See: Description

Package javaslang.control Description

Control structures like the disjoint union type Either, the optional value type Option and Try for exception handling.

Either

The control package contains an implementation of the Either control which is either Left or Right. A given Either is projected to a Left or a Right. Both cases can be further processed with control operations map, flatMap, filter. If a Right is projected to a Left, the Left control operations have no effect on the Right value. If a Left is projected to a Right, the Right control operations have no effect on the Left value.

Option

The Option control is a replacement for Optional. An Option is either Option.Some value or Option.None. In contrast to Optional, Option supports null values, i.e. it is possible to call new Some(null). However, Option.of(null) results in None.

Try

Exceptions are handled with the Try control which is either a Try.Success, containing a result, or a Try.Failure, containing an Exception.

Try internally handles exceptions by wrapping exceptions in a Cause. A Cause is unchecked, i.e. a RuntimeException, and is Fatal or NonFatal. Fatal exceptions cannot be handled and are thrown without further processing. NonFatal exceptions are wrapped in a Failure.

Since:
1.0.0
Skip navigation links

Copyright © 2016. All Rights Reserved.