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

io.polaris.core.hash.Number128 Maven / Gradle / Ivy

There is a newer version: 3.2.1
Show newest version
package io.polaris.core.hash;

import java.util.Objects;

/**
 * 128位数字表示,分高位和低位
 *
 * @author hexiufeng
 * @author Qt
 * @since 1.8,  Aug 01, 2023
 */
public class Number128 extends Number {
	private static final long serialVersionUID = 1L;

	private long lowValue;
	private long highValue;

	/**
	 * 构造
	 *
	 * @param lowValue  低位
	 * @param highValue 高位
	 */
	public Number128(long lowValue, long highValue) {
		this.lowValue = lowValue;
		this.highValue = highValue;
	}

	/**
	 * 获取低位值
	 *
	 * @return 地位值
	 */
	public long getLowValue() {
		return lowValue;
	}

	/**
	 * 设置低位值
	 *
	 * @param lowValue 低位值
	 */
	public void setLowValue(long lowValue) {
		this.lowValue = lowValue;
	}

	/**
	 * 获取高位值
	 *
	 * @return 高位值
	 */
	public long getHighValue() {
		return highValue;
	}

	/**
	 * 设置高位值
	 *
	 * @param hiValue 高位值
	 */
	public void setHighValue(long hiValue) {
		this.highValue = hiValue;
	}

	/**
	 * 获取高低位数组,long[0]:低位,long[1]:高位
	 *
	 * @return 高低位数组,long[0]:低位,long[1]:高位
	 */
	public long[] getLongArray() {
		return new long[]{lowValue, highValue};
	}

	@Override
	public int intValue() {
		return (int) longValue();
	}

	@Override
	public long longValue() {
		return this.lowValue;
	}

	@Override
	public float floatValue() {
		return longValue();
	}

	@Override
	public double doubleValue() {
		return longValue();
	}

	@Override
	public boolean equals(final Object o) {
		if (this == o) {
			return true;
		}
		if (o == null || getClass() != o.getClass()) {
			return false;
		}
		final Number128 number128 = (Number128) o;
		return lowValue == number128.lowValue && highValue == number128.highValue;
	}

	@Override
	public int hashCode() {
		return Objects.hash(lowValue, highValue);
	}


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy