| EMMA Coverage Report (generated Sat Dec 08 18:30:31 GMT 2007) |
|---|
| [all classes][uk.co.zonetora.fj.util] |
| name | class, % | method, % | block, % | line, % |
|---|---|---|---|---|
| Just.java | 100% (1/1) | 33% (2/6) | 52% (11/21) | 50% (4/8) |
| name | class, % | method, % | block, % | line, % |
|---|---|---|---|---|
| class Just | 100% (1/1) | 33% (2/6) | 52% (11/21) | 50% (4/8) |
| fromJust (): Object | 0% (0/1) | 0% (0/3) | 0% (0/1) | |
| fromMaybe (Object): Object | 0% (0/1) | 0% (0/3) | 0% (0/1) | |
| isJust (): boolean | 0% (0/1) | 0% (0/2) | 0% (0/1) | |
| isNothing (): boolean | 0% (0/1) | 0% (0/2) | 0% (0/1) | |
| Just (Object): void | 100% (1/1) | 100% (6/6) | 100% (3/3) | |
| maybe (Object, Arrow): Object | 100% (1/1) | 100% (5/5) | 100% (1/1) |
| 1 | /* |
| 2 | * Created on 23 Oct 2007 |
| 3 | */ |
| 4 | package uk.co.zonetora.fj.util; |
| 5 | |
| 6 | public class Just<T> implements Maybe<T> { |
| 7 | |
| 8 | private final T value; |
| 9 | |
| 10 | public Just(T value) { |
| 11 | this.value = value; |
| 12 | } |
| 13 | |
| 14 | public T fromJust() { |
| 15 | return this.value; |
| 16 | } |
| 17 | |
| 18 | public boolean isJust() { |
| 19 | return true; |
| 20 | } |
| 21 | |
| 22 | public boolean isNothing() { |
| 23 | return false; |
| 24 | } |
| 25 | |
| 26 | public T fromMaybe(T defaultValue) { |
| 27 | return this.value; |
| 28 | } |
| 29 | |
| 30 | public <S> S maybe(S defaultValue, Arrow<T, S> code) { |
| 31 | return code.run(this.value); |
| 32 | } |
| 33 | |
| 34 | } |
| [all classes][uk.co.zonetora.fj.util] |
| EMMA 2.0.5312 (C) Vladimir Roubtsov |