cornerstone library

Classes

ConvertCornerstoneExceptionToFailure
Converts CornerstoneException into Failure with identical name and details.
ConvertToFailure<T extends Object?>
Accepts an exeption and return equivalent failure. A reusable model to make your repository functions doesn't need to keep testing exception handling. Just mock it and off you go.
ConvertToSnapshot<T extends Object>
Convert to snapshot is a mockable function which used to generate Snapshot from data. Used in utility repos such as CornerstonePersistentRepositoryMixin.
CornerstoneSnapshot
Base snapshot abstract with several convenience properties. Don't forget to add timestamp in your implementation's props. On the other hand, don't add clock.
CreatorDataSource<Type, Param>
Implement this abstract in your data source if it can perform data creation. Note that 1 class can implements from multiple abstracts.
DeleterDataSource<Type, Param>
Implement this abstract in your data source if it can perform data deletion. Note that 1 class can implements from multiple abstracts.
Failure<T extends Object?>
Failure is a "nice" way to represent errors instead of throwing an exception.
LocallyPersistentRepository<T>
Cachable repository to the local storage.
MultipleGetterDataSource<Type, Param>
Implement this abstract in your data source if it can fetch some data. Note that 1 class can implements from multiple abstracts.
SafeCreatorDataSource<Type, Param>
Similar to CreatorDataSource, only returns Either form right away.
SafeDeleterDataSource<Type, Param>
Similar to DeleterDataSource, only returns Either form right away.
SafeMultipleGetterDataSource<Type, Param>
Similar to MultipleGetterDataSource, only returns Either form right away.
SafeSingleGetterDataSource<Type, Param>
Similar to SingleGetterDataSource, only returns Either form right away.
SafeUpdaterDataSource<Type, Param>
Similar to UpdaterDataSource, only returns Either form right away.
SingleGetterDataSource<Type, Param>
Implement this abstract in your data source if it can fetch some data. Note that 1 class can implements from multiple abstracts.
UpdaterDataSource<Type, Param>
Implement this abstract in your data source if it can perform data update Note that 1 class can implements from multiple abstracts.
UseCase<F, Type, Param>
Use case contains the app's business logic / rules, e.g. validations. It should be independent from any other non-business logic-related functionalities.

Mixins

CornerstonePersistentRepositoryMixin<Snap extends Object>
If you use this. You have to call Hive.init() first. For example:

Functions

dateTimeFromString(String date) DateTime
Parse string date to DateTime object
dateTimeToString(DateTime date) String
Parse DateTime object to String

Exceptions / Errors

CornerstoneException<T>
An exception to encapsulate other exceptions from data source layer or below to make repository layer even more decoupled. The fields of this class is identical to Failure for easier conversion in the repository.