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

info.unterrainer.commons.httpserver.extensions.AsyncExtensionContext Maven / Gradle / Ivy

There is a newer version: 0.3.14
Show newest version
package info.unterrainer.commons.httpserver.extensions;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import io.javalin.http.Context;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

@NoArgsConstructor()
@Accessors(fluent = true)
public class AsyncExtensionContext {

	private Map parameters = new HashMap<>();

	public AsyncExtensionContext addParameter(final Context ctx, final String parameterKey) {
		parameters.put(parameterKey, ctx.attribute(parameterKey));
		return this;
	}

	public AsyncExtensionContext addParameter(final String parameterKey, final Object parameterValue) {
		parameters.put(parameterKey, parameterValue);
		return this;
	}

	public Object get(final String parameterKey) {
		return parameters.get(parameterKey);
	}

	public Set> entrySet() {
		return parameters.entrySet();
	}

	public Set keySet() {
		return parameters.keySet();
	}

	public Collection valueSet() {
		return parameters.values();
	}

	public boolean containsKey(final String parameterKey) {
		return parameters.containsKey(parameterKey);
	}

	public boolean containsValue(final Object parameterValue) {
		return parameters.containsValue(parameterValue);
	}

	public void clear() {
		parameters.clear();
	}
}