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

com.jwebmp.guicedinjection.pairing.OptionalPair Maven / Gradle / Ivy

Go to download

Guice Injection allows you to access multiple Guice Binders and Modules across separate archives. Allowing you to configure your applications with injection from multiple dependancies. Servlets, EJB's, and Stand-Alone is supported. Requires JDK 8 or 10.

There is a newer version: 0.66.0.1
Show newest version
package com.jwebmp.guicedinjection.pairing;

import javax.validation.constraints.NotNull;
import java.util.Optional;

/**
 * Specifies a generic pair
 *
 * @param 
 * 		Key
 * @param 
 * 		Value
 */
public class OptionalPair
		extends Pair
{

	/**
	 * Constructs a new blank pair
	 */
	public OptionalPair()
	{
		//No config required
	}

	/**
	 * Constructs a new key value pair
	 *
	 * @param key
	 * 		The key to use
	 * @param value
	 * 		the value to use
	 */
	public OptionalPair(K key, V value)
	{
		super(key, value);
	}

	@Override
	public String toString()
	{
		return "Key[" + getKey() + "];Value[" + getValue() + "]";
	}

	/**
	 * Sets the value for the given pair
	 *
	 * @param value
	 * 		The value to set
	 *
	 * @return Optional nullable of the value
	 */
	@Override
	public OptionalPair setValue(V value)
	{
		super.setValue(value);
		return this;
	}

	/**
	 * Sets the key for the given pair
	 *
	 * @param key
	 * 		The key to return
	 *
	 * @return The optional pair
	 */
	@Override
	public OptionalPair setKey(@NotNull K key)
	{
		super.setKey(key);
		return this;
	}

	public Optional getKeyOptional()
	{
		return Optional.ofNullable(getKey());
	}

	/**
	 * Returns the optional object of the value
	 *
	 * @return Optional nullable of the value
	 */
	public Optional getValueOptional()
	{
		return Optional.ofNullable(getValue());
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy