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

com.dooapp.gaedo.blueprints.transformers.WriteableKeyEntry Maven / Gradle / Ivy

There is a newer version: 1.0.16
Show newest version
package com.dooapp.gaedo.blueprints.transformers;

import java.util.Map;
import java.util.Map.Entry;

/**
 * An impelmentation of {@link Entry} allowing us to write key, very useful to load objects !
 * @author ndx
 *
 * @param 
 * @param 
 */
public class WriteableKeyEntry implements Map.Entry {
	private K key;
	private V value;

	public WriteableKeyEntry() {

	}

	public WriteableKeyEntry(K key, V value) {
		setKey(key);
		setValue(value);
	}

	@Override
	public K getKey() {
		return key;
	}

	@Override
	public V getValue() {
		return value;
	}

	@Override
	public V setValue(V value) {
		V old = this.value;
		this.value = value;
		return old;
	}

	/**
	 * @param value new value for #value
	 * @category fluent
	 * @category setter
	 * @category value
	 * @return this object for chaining calls
	 */
	public WriteableKeyEntry withValue(V value) {
		this.setValue(value);
		return this;
	}

	public K setKey(K key) {
		K old = this.key;
		this.key = key;
		return old;
	}

	/**
	 * @param key new value for #key
	 * @category fluent
	 * @category setter
	 * @category key
	 * @return this object for chaining calls
	 */
	public WriteableKeyEntry withKey(K key) {
		this.setKey(key);
		return this;
	}

	/**
	 * @return
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("WriteableKeyEntry [");
		if (key != null) {
			builder.append("key=");
			builder.append(key);
			builder.append(", ");
		}
		if (value != null) {
			builder.append("value=");
			builder.append(value);
		}
		builder.append("]");
		return builder.toString();
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy