com.infomaximum.cluster.graphql.struct.subscribe.SubscribeKey Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cluster-graphql Show documentation
Show all versions of cluster-graphql Show documentation
Library for creating a light cluster
The newest version!
package com.infomaximum.cluster.graphql.struct.subscribe;
import com.infomaximum.cluster.core.remote.struct.RemoteObject;
import com.infomaximum.cluster.struct.Component;
import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.UUID;
public class SubscribeKey implements RemoteObject {
private final byte[] key;
public SubscribeKey(Component component, byte[] subscribeKey) {
this(component.getRemotes().cluster.node.getRuntimeId(), component.getId(), subscribeKey);
}
public SubscribeKey(UUID nodeRuntimeId, int componentId, byte[] subscribeKey) {
key = ByteBuffer.allocate(Long.BYTES + Long.BYTES + Integer.BYTES + subscribeKey.length)
.putLong(nodeRuntimeId.getMostSignificantBits())
.putLong(nodeRuntimeId.getLeastSignificantBits())
.putInt(componentId)
.put(subscribeKey)
.array();
}
@Override
public boolean equals(Object other) {
if (!(other instanceof SubscribeKey)) {
return false;
}
return Arrays.equals(key, ((SubscribeKey) other).key);
}
@Override
public int hashCode() {
return Arrays.hashCode(key);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy