run linter
This commit is contained in:
parent
530ef6b71a
commit
132080d451
@ -1,23 +1,23 @@
|
||||
import cs2030s.fp.Actually;
|
||||
import cs2030s.fp.Immutator;
|
||||
import cs2030s.fp.Constant;
|
||||
import cs2030s.fp.Action;
|
||||
import cs2030s.fp.Actually;
|
||||
import cs2030s.fp.Constant;
|
||||
import cs2030s.fp.Immutator;
|
||||
import cs2030s.fp.Transformer;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Scanner;
|
||||
|
||||
class Lab5 {
|
||||
public static String getGrade(String module, String student, String assessment,
|
||||
Map<String, Map<String, Map<String, String>>> db) {
|
||||
Constant<Actually<Map<String, Map<String, Map<String, String>>>>> cDb = new Constant<>() {
|
||||
Constant<Actually<Map<String, Map<String, Map<String, String>>>>> constantDb = new Constant<>() {
|
||||
@Override
|
||||
public Actually<Map<String, Map<String, Map<String, String>>>> init() {
|
||||
return Actually.ok(db);
|
||||
}
|
||||
};
|
||||
|
||||
Constant<String> cNoEntry = new Constant<>() {
|
||||
Constant<String> constantNoEntry = new Constant<>() {
|
||||
@Override
|
||||
public String init() {
|
||||
return "No such entry";
|
||||
@ -45,12 +45,12 @@ class Lab5 {
|
||||
|
||||
};
|
||||
|
||||
return cDb
|
||||
return constantDb
|
||||
.init()
|
||||
.next(getModule)
|
||||
.next(getStudent)
|
||||
.next(getAssessment)
|
||||
.except(cNoEntry);
|
||||
.except(constantNoEntry);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
@ -1,4 +1,5 @@
|
||||
package cs2030s.fp;
|
||||
|
||||
/**
|
||||
* The Action interface that can be called
|
||||
* on an object of type T to act.
|
||||
|
@ -1,4 +1,5 @@
|
||||
package cs2030s.fp;
|
||||
|
||||
/**
|
||||
* The Actionable interface that can
|
||||
* act when given an action.
|
||||
|
@ -1,6 +1,19 @@
|
||||
package cs2030s.fp;
|
||||
|
||||
public abstract class Actually<T> implements Immutatorable<T>, Actionable<T> {
|
||||
|
||||
public static <T> Actually<T> ok(T value) {
|
||||
return new Success<T>(value);
|
||||
}
|
||||
|
||||
public static <T> Actually<T> err(Exception e) {
|
||||
// It is okay to do an unchecked cast here as failure types don't use
|
||||
// the value T.
|
||||
@SuppressWarnings("unchecked")
|
||||
Actually<T> failure = (Actually<T>) new Failure(e);
|
||||
return failure;
|
||||
}
|
||||
|
||||
public abstract T unwrap() throws Exception;
|
||||
|
||||
public abstract T except(Constant<? extends T> c);
|
||||
@ -11,14 +24,6 @@ public abstract class Actually<T> implements Immutatorable<T>, Actionable<T> {
|
||||
|
||||
public abstract <R> Actually<R> next(Immutator<Actually<R>, ? super T> immutator);
|
||||
|
||||
public static <T> Actually<T> ok(T value) {
|
||||
return new Success<T>(value);
|
||||
}
|
||||
|
||||
public static <T> Actually<T> err(Exception e) {
|
||||
Actually<T> failure = (Actually<T>) new Failure(e);
|
||||
return failure;
|
||||
}
|
||||
|
||||
private static class Success<T> extends Actually<T> {
|
||||
private final T value;
|
||||
|
@ -1,4 +1,5 @@
|
||||
package cs2030s.fp;
|
||||
|
||||
/**
|
||||
* The Immutator interface that can transform
|
||||
* to type T2, an object of type T1.
|
||||
|
@ -1,4 +1,5 @@
|
||||
package cs2030s.fp;
|
||||
|
||||
/**
|
||||
* The Immutatorable interface that can
|
||||
* transform when given something that is
|
||||
|
Loading…
Reference in New Issue
Block a user