finishing touches
This commit is contained in:
parent
05a6f3e572
commit
caccc490fe
@ -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);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* The Immutator interface that can transform
|
||||
* The Immutator interface that can transform
|
||||
* to type T2, an object of type T1.
|
||||
*
|
||||
* Contains a single abstract method invoke.
|
||||
@ -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,12 +5,12 @@
|
||||
* CS2030S Lab 4
|
||||
* AY22/23 Semester 1
|
||||
*
|
||||
* @author Put Your Name (Lab Group)
|
||||
* @author Yadunand Prem (10B)
|
||||
*/
|
||||
|
||||
class Print implements Action<Object> {
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void call(Object item) {
|
||||
System.out.println(item);
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user