/** * This is a marker interface for metadata provider implementations that should be used to register those as an OSGi * service. * * @author Kai Kreuzer - Initial contribution and API * */ @NonNullByDefault public interface MetadataProvider extends Provider<Metadata> { }
/** * This is a marker interface for all command types. * * @author Kai Kreuzer - Initial contribution and API * */ @NonNullByDefault public interface Command extends Type { }
/** * An item provider provides instances of {@link GenericItem}. These * items can be constructed from some static configuration files or * they can be derived from some dynamic logic. * * @author Kai Kreuzer - Initial contribution and API * */ @NonNullByDefault public interface ItemProvider extends Provider<Item> { }
/** * A primitive type consists of a single value like a string, a number, etc. * * @author Kai Kreuzer - Initial contribution and API * */ @NonNullByDefault public interface PrimitiveType extends Type { }
/** * Interface returned by all scheduled jobs. It can be used to wait for the value, * cancel the job or check how much time till the scheduled job will run. * * @author Hilbrand Bouwkamp - initial contribution */ @NonNullByDefault public interface ScheduledCompletableFuture<T> extends ScheduledFuture<T> { /** * @return Returns the {@link CompletableFuture} associated with the scheduled job. */ CompletableFuture<T> getPromise(); }
/** * This interface describes a provider for time zone. * * @author Erdoan Hadzhiyusein - Initial contribution and API */ @NonNullByDefault public interface TimeZoneProvider { /** * Gets the configured time zone as {@link ZoneId} or the system default time zone if not configured properly. * * @return the configured time zone as {@link ZoneId} or the system default time zone if not configured properly. */ ZoneId getTimeZone(); }
/** * Handler to act up on changes of the access token. * * @author Hilbrand Bouwkamp - Initial contribution */ @NonNullByDefault public interface AccessTokenRefreshListener { /** * Notifies of a successful token response from {@link OAuthClientService#refreshToken()}. * * @param tokenResponse token response */ void onAccessTokenResponse(AccessTokenResponse tokenResponse); }
/** * Interface for classes that instances provide an identifier. * * @author Markus Rathgeb - Initial contribution */ @NonNullByDefault public interface Identifiable<T> { /** * Get the unique identifier. * * @return the unique identifier */ T getUID(); }
/** * This interface describes a provider for a location. * * @author Stefan Triller - Initial contribution and API */ @NonNullByDefault public interface LocationProvider { /** * Provides access to the location of the installation * * @return location of the current installation or null if the location is not set */ @Nullable PointType getLocation(); }
/** * A complex type consists out of a sorted list of primitive constituents. * Each constituent can be referred to by a unique name. * * @author Kai Kreuzer - Initial contribution and API * */ @NonNullByDefault public interface ComplexType extends Type { /** * Returns all constituents with their names as a sorted map * * @return all constituents with their names */ public SortedMap<String, PrimitiveType> getConstituents(); }
/** * The interface describe a provider for a locale. * * @author Markus Rathgeb - Initial contribution and API */ @NonNullByDefault public interface LocaleProvider { /** * Get a locale. * * The locale could be used e.g. as a fallback if there is no other one defined explicitly. * * @return a locale (non-null) */ Locale getLocale(); }
/** * Provides some default predicates that are helpful when working with items. * * @author Kai Kreuzer - Initial contribution and API * */ @NonNullByDefault public final class ItemPredicates { /** * Creates a {@link Predicate} which can be used to filter {@link Item}s for a given label. * * @param label to filter * @return created {@link Predicate} */ public static Predicate<Item> hasLabel(String label) { return i -> label.equalsIgnoreCase(i.getLabel()); } }
/** * Interface that extends {@link TemporalAdjuster} and adds more functionality. * This interface is passed to the scheduler for repeating schedules. * * @author Hilbrand Bouwkamp - initial contribution */ @NonNullByDefault public interface SchedulerTemporalAdjuster extends TemporalAdjuster { /** * Used by the scheduler to determine if it should continue scheduling jobs. * If returns true the implementation of this interface determines the job * should not run again given. No new job will be scheduled. * * @param temporal The temporal to determine if the next run should be scheduled * @return true if running is done and the job should not run anymore. */ boolean isDone(Temporal temporal); }
/** * Runnable that can be passed data and can throw a checked exception. * * @author Peter Kriens - initial contribution and API */ @NonNullByDefault public interface CronJob { /** * The service property that specifies the cron schedule. The type is String+. */ String CRON = "cron"; /** * Run a cron job. * * @param data The data for the job * @throws Exception Exception thrown */ public void run(Map<String, Object> data) throws Exception; }
/** * Implementations of this service provide strategies for merging info from * different StateDescriptionProviders into one StateDescription. * * @author Lyubomir Papazov - Initial contribution * */ @NonNullByDefault public interface StateDescriptionService { /** * Implementations of this method merge the StateDescriptions provided from * multiple StateDescriptionProviders into one final StateDescription. * * @param itemName the item for which to get the StateDescription (must not be null) * @param locale locale (can be null) * @return state description or null if no state description could be found */ @Nullable StateDescription getStateDescription(String itemName, @Nullable Locale locale); }
/** * This Factory creates concrete instances of the known ItemTypes. * * @author Thomas.Eichstaedt-Engelen */ @NonNullByDefault public interface ItemFactory { /** * Creates a new Item instance of type <code>itemTypeName</code> and the name <code>itemName</code> * * @param itemTypeName * @param itemName * @return a new Item of type <code>itemTypeName</code> or <code>null</code> if no matching class is known. */ @Nullable Item createItem(@Nullable String itemTypeName, String itemName); /** * Returns the list of all supported ItemTypes of this Factory. * * @return the supported ItemTypes */ String[] getSupportedItemTypes(); }
/** * OSGi service to obtain a {@link SafeCallerBuilder}. * * Safe-calls are used within the framework in order to protect it from hanging/blocking binding code and log meaningful * messages to detect and identify such hanging code. * * @author Simon Kaufmann - initial contribution and API. */ @NonNullByDefault public interface SafeCaller { /** * Default timeout for actions in milliseconds. */ long DEFAULT_TIMEOUT = TimeUnit.SECONDS.toMillis(5); /** * Create a safe call builder for the given object. * * @param target the object on which calls should be protected by the safe caller * @param interfaceType the interface which defines the relevant methods * @return a safe call builder instance. */ <T> SafeCallerBuilder<T> create(T target, Class<T> interfaceType); }
/** * This is a marker interface for all state types. * * @author Kai Kreuzer - Initial contribution and API * */ @NonNullByDefault public interface State extends Type { /** * Convert this {@link State}'s value into another type * * @param target the desired {@link State} type * @return the {@link State}'s value in the given type's representation, or <code>null</code> if the conversion was * not possible */ default <T extends @Nullable State> @Nullable T as(@Nullable Class<T> target) { if (target != null && target.isInstance(this)) { return target.cast(this); } else { return null; } } }
/** * This is a data transfer object that is used to serialize metadata for a certain namespace and item. * * @author Kai Kreuzer - Initial contribution and API * */ @NonNullByDefault public class MetadataDTO { public @Nullable String value; public @Nullable Map<String, Object> config; }
/** * Implementation of a {@link PeriodicScheduler}. * * @author Peter Kriens - initial contribution and API * @author Simon Kaufmann - adapted to CompletableFutures * @author Hilbrand Bouwkamp - moved periodic scheduling to it's own interface */ @Component(service = PeriodicScheduler.class) @NonNullByDefault public class PeriodicSchedulerImpl implements PeriodicScheduler { private @NonNullByDefault({}) Scheduler scheduler; @Override public <T> ScheduledCompletableFuture<T> schedule(SchedulerRunnable runnable, Duration... delays) { return scheduler.schedule(runnable, new PeriodicAdjuster(delays)); } @Reference void setScheduler(Scheduler scheduler) { this.scheduler = scheduler; } void unsetScheduler(Scheduler scheduler) { this.scheduler = null; } }