fix issues
This commit is contained in:
parent
bd2d0766ae
commit
d8e797ae3a
@ -5,9 +5,10 @@
|
||||
* Contains a single abstract method apply.
|
||||
* CS2030S Lab 4
|
||||
* AY22/23 Semester 1
|
||||
*
|
||||
* @author Yadunand Prem (10B)
|
||||
*/
|
||||
|
||||
interface Applicable<T> {
|
||||
<R> Applicable<R> apply(Probably<Immutator<R, T>> probablyImmutator);
|
||||
<R> Applicable<R> apply(Probably<? extends Immutator<? extends R, ? super T>> probablyImmutator);
|
||||
}
|
||||
|
@ -9,5 +9,5 @@
|
||||
*/
|
||||
|
||||
interface Immutatorable<T> {
|
||||
public <R> Immutatorable<R> transform(Immutator<R, T> immutator);
|
||||
public <R> Immutatorable<R> transform(Immutator<? extends R, ? super T> immutator);
|
||||
}
|
||||
|
@ -105,21 +105,18 @@ class Probably<T> implements Actionable<T>, Immutatorable<T>, Applicable<T> {
|
||||
action.call(this.value);
|
||||
}
|
||||
|
||||
public Probably<T> check(IsModEq eq) {
|
||||
public Probably<T> check(Immutator<Boolean, ? super T> eq) {
|
||||
if (this.value == null) {
|
||||
return none();
|
||||
}
|
||||
if (this.value instanceof Integer) {
|
||||
Integer val = (Integer) this.value;
|
||||
if (eq.invoke(val)) {
|
||||
if (eq.invoke(this.value)) {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
return none();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R> Probably<R> transform(Immutator<R, T> immutator) {
|
||||
public <R> Probably<R> transform(Immutator<? extends R, ? super T> immutator) {
|
||||
if (this.value == null) {
|
||||
return none();
|
||||
}
|
||||
@ -127,9 +124,9 @@ class Probably<T> implements Actionable<T>, Immutatorable<T>, Applicable<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R> Probably<R> apply(Probably<Immutator<R, T>> probablyImmutator) {
|
||||
if (this.value != null && probablyImmutator.value != null) {
|
||||
return just(probablyImmutator.value.invoke(this.value));
|
||||
public <R> Probably<R> apply(Probably<? extends Immutator<? extends R, ? super T>> probablyImmutator) {
|
||||
if (probablyImmutator.value != null) {
|
||||
return this.transform(probablyImmutator.value);
|
||||
}
|
||||
return none();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user