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

io.hotmoka.node.local.internal.StateIdImpl Maven / Gradle / Ivy

package io.hotmoka.node.local.internal;

import java.util.Arrays;

import io.hotmoka.crypto.Hex;
import io.hotmoka.node.local.api.StateId;

/**
 * Implementation of the identifier of the state of a trie-based store.
 */
public class StateIdImpl implements StateId {
	private final byte[] bytes;

	/**
	 * Creates an identifier represented by the given bytes.
	 * 
	 * @param id the bytes of the identifier
	 */
	public StateIdImpl(byte[] id) {
		this.bytes = id;
	}

	@Override
	public byte[] getBytes() {
		return bytes;
	}

	@Override
	public boolean equals(Object other) {
		return other instanceof StateId si && Arrays.equals(bytes, si.getBytes());
	}

	@Override
	public int hashCode() {
		return Arrays.hashCode(bytes);
	}

	@Override
	public String toString() {
		return Hex.toHexString(bytes);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy