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

io.annot8.common.data.bounds.ContentBounds Maven / Gradle / Ivy

The newest version!
/* Annot8 (annot8.io) - Licensed under Apache-2.0. */
package io.annot8.common.data.bounds;

import io.annot8.api.bounds.Bounds;
import io.annot8.api.data.Content;
import jakarta.json.bind.annotation.JsonbCreator;
import java.util.Optional;

/**
 * Implementation of Bounds indicating that an annotation covers the entire content.
 *
 * 

This class is a singleton, and should be accessed via getInstance() */ public final class ContentBounds implements Bounds { private static final ContentBounds INSTANCE = new ContentBounds(); private ContentBounds() { // Empty constructor } /** * Get instance * * @return the singleton instance of ContentBounds */ @JsonbCreator public static ContentBounds getInstance() { return INSTANCE; } @Override public String toString() { return "ContentBounds"; } @Override public , R> Optional getData(C content, Class requiredClass) { D data = content.getData(); if (requiredClass.isAssignableFrom(data.getClass())) { @SuppressWarnings("unchecked") R r = (R) data; return Optional.of(r); } else { return Optional.empty(); } } @Override public > boolean isValid(C content) { return true; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy