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

io.polaris.core.guid.FixedNodeStrategy Maven / Gradle / Ivy

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

/**
 * @author Qt
 * @since 1.8,  Apr 22, 2024
 */
public class FixedNodeStrategy implements GuidNodeStrategy {
	private final int nodeId;
	private final int bizSize;

	private FixedNodeStrategy(int nodeId, int bizSize) {
		if (bizSize > 12) {
			throw new IllegalArgumentException();
		}
		this.nodeId = nodeId;
		this.bizSize = bizSize;
	}

	public static FixedNodeStrategy newInstance(int nodeId, int bizSize) {
		return new FixedNodeStrategy(nodeId, bizSize);
	}


	@Override
	public int bitSize() {
		return bizSize;
	}

	@Override
	public int nodeId() {
		return nodeId;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy