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

de.otto.synapse.message.CompoundKey Maven / Gradle / Ivy

Go to download

A library used at otto.de to implement Spring Boot based event-sourcing microservices.

There is a newer version: 0.33.1
Show newest version
package de.otto.synapse.message;

import jakarta.annotation.Nonnull;

import java.util.Objects;

import static java.util.Objects.requireNonNull;

public final class CompoundKey implements Key {

    private static final long serialVersionUID = -39690651225375664L;

    private final String partitionKey;
    private final String compactionKey;

    CompoundKey(final @Nonnull String partitionKey,
                        final @Nonnull String compactionKey) {
        this.partitionKey = requireNonNull(partitionKey);
        this.compactionKey = requireNonNull(compactionKey);
    }

    @Override
    public String partitionKey() {
        return partitionKey;
    }

    @Override
    public String compactionKey() {
        return compactionKey;
    }

    @Override
    public boolean isCompoundKey() {
        return true;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        CompoundKey that = (CompoundKey) o;
        return Objects.equals(partitionKey, that.partitionKey) &&
                Objects.equals(compactionKey, that.compactionKey);
    }

    @Override
    public int hashCode() {
        return Objects.hash(partitionKey, compactionKey);
    }

    @Override
    public String toString() {
        return partitionKey + ':' + compactionKey;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy