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

io.quarkus.panache.common.Parameters Maven / Gradle / Ivy

There is a newer version: 3.17.0.CR1
Show newest version
package io.quarkus.panache.common;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

/**
 * 

* Utility class to build populated `Map` instances. Page instances are mutable (builder-like). *

* *

* Usage: *

* *
 * Map<String, Object> params = Parameters.with("foo", foo)
 *     .and("bar", bar)
 *     .and("gee", gee)
 *     .map();
 * 
* * @author Stéphane Épardaud */ public class Parameters { private final Map values = new HashMap<>(); /** * Add a parameter to this {@link Parameters}. * * @param name name of the parameter to add * @param value value of the parameter to add * @return this instance, modified. * @see {@link Parameters#map()} */ public Parameters and(String name, Object value) { values.put(name, value); return this; } /** * Constructs an unmodifiable {@link Map} with the current parameters. * * @return an unmodifiable {@link Map} with the current parameters. */ public Map map() { return Collections.unmodifiableMap(values); } /** * Build a {@link Parameters} with a single parameter. * * @param name name of the first parameter * @param value value of the first parameter * @return a {@link Parameters} with a single parameter. * @see {@link Parameters#and(String, Object)} * @see {@link Parameters#map()} */ public static Parameters with(String name, Object value) { return new Parameters().and(name, value); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy