finishing touches
This commit is contained in:
@@ -12,5 +12,5 @@
|
||||
*/
|
||||
|
||||
interface Applicable<T> {
|
||||
<R> Applicable<R> apply(Immutator<Probably<R>, Probably<T>> immutator);
|
||||
<R> Applicable<R> apply(Probably<Immutator<R, T>> probablyImmutator);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,6 @@
|
||||
* @author Yadunand Prem (10B)
|
||||
*/
|
||||
|
||||
interface Immutator<R,P> {
|
||||
interface Immutator<R, P> {
|
||||
public R invoke(P param);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* CS2030S Lab 4
|
||||
* AY22/23 Semester 1
|
||||
*
|
||||
* @author Put Your Name (Lab Group)
|
||||
* @author Yadunand Prem (10B)
|
||||
*/
|
||||
|
||||
class Improbable<T> implements Immutator<Probably<T>, T> {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
* CS2030S Lab 4
|
||||
* AY22/23 Semester 1
|
||||
*
|
||||
* @author Put Your Name (Lab Group)
|
||||
* @author Yadunand Prem (10B)
|
||||
*/
|
||||
|
||||
class IsModEq implements Immutator<Boolean, Integer> {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* CS2030S Lab 4
|
||||
* AY22/23 Semester 1
|
||||
*
|
||||
* @author Put Your Name (Lab Group)
|
||||
* @author Yadunand Prem (10B)
|
||||
*/
|
||||
|
||||
class Print implements Action<Object> {
|
||||
|
||||
@@ -124,11 +124,11 @@ class Probably<T> implements Actionable<T>, Immutatorable<T>, Applicable<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R> Probably<R> apply(Immutator<Probably<R>, Probably<T>> immutator) {
|
||||
if (this.value == null) {
|
||||
return none();
|
||||
public <R> Probably<R> apply(Probably<Immutator<R, T>> probablyImmutator) {
|
||||
if (this.value != null && probablyImmutator.value != null) {
|
||||
return just(probablyImmutator.value.invoke(this.value));
|
||||
}
|
||||
return immutator.invoke(this);
|
||||
return none();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user