dev.restate.sdk.common.syscalls.HandlerDefinition Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sdk-common Show documentation
Show all versions of sdk-common Show documentation
Common interfaces of the Restate SDK
The newest version!
// Copyright (c) 2023 - Restate Software, Inc., Restate GmbH
//
// This file is part of the Restate Java SDK,
// which is released under the MIT license.
//
// You can find a copy of the license in file LICENSE in the root
// directory of this repository or package, or at
// https://github.com/restatedev/sdk-java/blob/main/LICENSE
package dev.restate.sdk.common.syscalls;
import java.util.Objects;
public final class HandlerDefinition {
private final HandlerSpecification spec;
private final HandlerRunner runner;
HandlerDefinition(HandlerSpecification spec, HandlerRunner runner) {
this.spec = spec;
this.runner = runner;
}
public HandlerSpecification getSpec() {
return spec;
}
public HandlerRunner getRunner() {
return runner;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
HandlerDefinition, ?, ?> that = (HandlerDefinition, ?, ?>) o;
return Objects.equals(spec, that.spec) && Objects.equals(runner, that.runner);
}
@Override
public int hashCode() {
int result = Objects.hashCode(spec);
result = 31 * result + Objects.hashCode(runner);
return result;
}
@Override
public String toString() {
return "HandlerDefinition{" + "spec=" + spec + ", handler=" + runner + '}';
}
public static HandlerDefinition of(
HandlerSpecification spec, HandlerRunner runner) {
return new HandlerDefinition<>(spec, runner);
}
}