io.annot8.api.data.Content Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of annot8-api Show documentation
Show all versions of annot8-api Show documentation
Core API interfaces for the Annot8 project
/* Annot8 (annot8.io) - Licensed under Apache-2.0. */
package io.annot8.api.data;
import io.annot8.api.helpers.WithDescription;
import io.annot8.api.helpers.WithId;
import io.annot8.api.helpers.WithProperties;
import io.annot8.api.helpers.builders.WithFromBuilder;
import io.annot8.api.helpers.builders.WithIdBuilder;
import io.annot8.api.helpers.builders.WithPropertiesBuilder;
import io.annot8.api.helpers.builders.WithSave;
import io.annot8.api.stores.AnnotationStore;
import java.util.function.Supplier;
/**
* Base content interface from which all content implementations extend.
*
* @param the type of data held
*/
public interface Content extends WithId, WithProperties, WithDescription {
/**
* Get the item which this content relates to.
*
* @return item
*/
Item getItem();
/**
* The data associated with this content object
*
* @return the data
*/
D getData();
/**
* The class of the data stored in this Content object
*
* @return data class
*/
Class getDataClass();
/**
* The top level content interface this object implements
*
* @return common content interface
*/
Class extends Content> getContentClass();
/**
* The annotation store for this content
*
* @return annotation store
*/
AnnotationStore getAnnotations();
/** Builder interface to createContent (immutable) Content classes */
interface Builder, D>
extends WithPropertiesBuilder>,
WithFromBuilder, A>,
WithIdBuilder>,
WithSave {
/**
* Set the description of this content object
*
* @param description the content description
* @return this builder for chaining
*/
Content.Builder withDescription(final String description);
/**
* Set the data for this content object
*
* @param data the data
* @return this builder for chaining
*/
default Content.Builder withData(final D data) {
if (data == null) {
withData((Supplier) null);
} else {
withData(() -> data);
}
return this;
}
/**
* Set the data for this content object, accessed via a supplier
*
* @param data the data
* @return this builder for chaining
*/
Content.Builder withData(final Supplier data);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy