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

io.annot8.api.capabilities.Capabilities Maven / Gradle / Ivy

There is a newer version: 1.2
Show newest version
/* Annot8 (annot8.io) - Licensed under Apache-2.0. */
package io.annot8.api.capabilities;

import java.util.stream.Stream;

/** Interface for capturing the capabilities of an Annot8 component */
public interface Capabilities {
  /**
   * Describes the things (e.g. content, annotations, groups) created by a component
   *
   * @return Stream of {@link Capability} objects describing what is created
   */
  Stream creates();

  /**
   * Helper method for filtering {@link #creates()} to a specific type of Capability
   *
   * @param type The type of capability to filter to
   * @param  Class extending Capability
   * @return Stream of {@link Capability} objects describing what is created
   */
  default  Stream creates(Class type) {
    return creates().filter(c -> type.isAssignableFrom(c.getClass())).map(type::cast);
  }

  /**
   * Describes the things (e.g. content, annotations, groups) processed by a component
   *
   * @return Stream of {@link Capability} objects describing what is processed
   */
  Stream processes();

  /**
   * Helper method for filtering {@link #processes()} to a specific type of Capability
   *
   * @param type The type of capability to filter to
   * @param  Class extending Capability
   * @return Stream of {@link Capability} objects describing what is processed
   */
  default  Stream processes(Class type) {
    return processes().filter(c -> type.isAssignableFrom(c.getClass())).map(type::cast);
  }

  /**
   * Describes the things (e.g. content, annotations, groups) deleted by a component
   *
   * @return Stream of {@link Capability} objects describing what is deleted
   */
  Stream deletes();

  /**
   * Helper method for filtering {@link #deletes()} to a specific type of Capability
   *
   * @param type The type of capability to filter to
   * @param  Class extending Capability
   * @return Stream of {@link Capability} objects describing what is deleted
   */
  default  Stream deletes(Class type) {
    return deletes().filter(c -> type.isAssignableFrom(c.getClass())).map(type::cast);
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy