Skip to content

lambig/Either

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Note: This Repository will be no longer maintained. (Due to confusing name & Neither defection) Consider using Union;

Either<L, R>

Easy implementation of Union class-like something

Instance Provider

EitherOf.class is the one and only instance provider.

left(L): Left<L, R>

Returns instance with left value.
Either<Long, String> either = EitherOf.left(1L);

right(R): Right<L, R>

Returns instance with right value.
Either<Long, String> either = EitherOf.right("abc");

none(): Neither<L, R>

Returns instance without any value.
Either<Leng, String> neither = EitherOf.none();

l(L): LeftProvider

Use this in case you need to declare type explicitly.
EitherOf.l(1L).<String>r();

r(R): RightProvider

Use this in case you need to declare type explicitly.
EitherOf.r("abc").<Long>l();

Supported methods

  • left(): L
  • right(): R
  • leftOptional(): Optional
  • rightOptional(): Optional
  • hasLeft(): boolean
  • hasRight(): boolean
  • asJoined(Function<? super L, ? extends O>, Function<? super R, ? extends O>): O
  • asJoined(BiFunction<? super L, ? super R, ? extends O>): O
  • asJoinedOptional(Function<? super L, ? extends O>, Function<? super R, ? extends O>): Optional
  • asJoinedOptional(BiFunction<? super L, ? super R, ? extends O>): Optional
  • acceptWith(Consumer<? super L>, Consumer<? super R>): void
  • acceptWith(BiConsumer<? super L, ? super R>): void
  • acceptLeftWith(Consumer<? super L>): void
  • acceptRightWith(Consumer<? super R>): void
  • peekWith(Consumer<? super L>, Consumer<? super R>): Either<L, R>
  • peekWith(BiConsumer<? super L, ? super R>): Either<L, R>
  • peekLeftWith(Consumer<? super L>): Either<L, R>
  • peekRightWith(Consumer<? super R>): Either<L, R>

About

Easy implementation of Union class-like something

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages