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

pl.allegro.tech.hermes.management.domain.owner.OwnerSource Maven / Gradle / Ivy

There is a newer version: 2.10.4
Show newest version
package pl.allegro.tech.hermes.management.domain.owner;

import java.util.List;
import java.util.Optional;
import pl.allegro.tech.hermes.api.ErrorCode;
import pl.allegro.tech.hermes.api.Owner;
import pl.allegro.tech.hermes.management.domain.ManagementException;

public interface OwnerSource {

  String name();

  boolean exists(String ownerId);

  Owner get(String id) throws OwnerNotFound;

  default boolean isDeprecated() {
    return false;
  }

  /** Override if the implemented owner source supports autocompletion. */
  default Optional autocompletion() {
    return Optional.empty();
  }

  interface Autocompletion {
    List ownersMatching(String searchString);
  }

  class OwnerNotFound extends ManagementException {

    public OwnerNotFound(String source, String id) {
      super("Owner of id '" + id + "' not found in source " + source);
    }

    @Override
    public ErrorCode getCode() {
      return ErrorCode.OWNER_NOT_FOUND;
    }
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy