All Downloads are FREE. Search and download functionalities are using the official Maven repository.

edu.ksu.canvas.requestOptions.BaseOptions Maven / Gradle / Ivy

package edu.ksu.canvas.requestOptions;

import java.util.ArrayList;
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 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 list) {
        optionsMap.put(key, list.stream().map(i->i.toString()).collect(Collectors.toList()));
    }

    protected void addStringList(String key, List list) {
        optionsMap.put(key, new ArrayList(list));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy