edu.ksu.canvas.requestOptions.BaseOptions Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of canvas-api Show documentation
Show all versions of canvas-api Show documentation
A native Java library to talk to the Canvas REST API
package edu.ksu.canvas.requestOptions;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public abstract class BaseOptions {
protected Map> optionsMap = new HashMap<>();
public Map> getOptionsMap() {
return optionsMap;
}
/**
* Add a list of enums to the options map
* @param key The key for the options map (ex: "include[]")
* @param list A list of enums
*/
protected void addEnumList(String key, List extends Enum> list) {
optionsMap.put(key, list.stream().map(i -> i.toString()).collect(Collectors.toList()));
}
protected void addSingleItem(String key, String value) {
optionsMap.put(key, Collections.singletonList(value));
}
protected void addNumberList(String key, List extends Number> list) {
optionsMap.put(key, list.stream().map(i->i.toString()).collect(Collectors.toList()));
}
}