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

cn.hutool.core.lang.mutable.MutablePair Maven / Gradle / Ivy

Go to download

Hutool是一个小而全的Java工具类库,通过静态方法封装,降低相关API的学习成本,提高工作效率,使Java拥有函数式语言般的优雅,让Java语言也可以“甜甜的”。

There is a newer version: 5.8.34
Show newest version
package cn.hutool.core.lang.mutable;

import cn.hutool.core.lang.Pair;

/**
 * 可变{@link Pair}实现,可以修改键和值
 *
 * @param  键类型
 * @param  值类型
 * @since 5.7.16
 */
public class MutablePair extends Pair implements Mutable>{
	private static final long serialVersionUID = 1L;

	/**
	 * 构造
	 *
	 * @param key   键
	 * @param value 值
	 */
	public MutablePair(K key, V value) {
		super(key, value);
	}

	/**
	 * 设置键
	 *
	 * @param key 新键
	 * @return this
	 */
	public MutablePair setKey(K key) {
		this.key = key;
		return this;
	}

	/**
	 * 设置值
	 *
	 * @param value 新值
	 * @return this
	 */
	public MutablePair setValue(V value) {
		this.value = value;
		return this;
	}

	@Override
	public Pair get() {
		return this;
	}

	@Override
	public void set(Pair pair) {
		this.key = pair.getKey();
		this.value = pair.getValue();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy