Light Java library used to store entities to various storage.
StoreIt provides an abstraction layer to store, get, list, update and delete all kind of entities.
To allow an entity to be stored into a StoreIt storage, it has to implement StoredEntity
interface, to provides a
getId()
method.
Form the root package, install StoredIt locally:
mvn install
Add dependency in your pom.xml
according to the storage your want to use:
<dependency>
<groupId>com.ingensi.data</groupId>
<artifactId>storeit-elasticsearch</artifactId>
<version>${storeit.version}</version>
</dependency>
To store an entity with StoreIt
, you need a StoredEntity
class. Here is an example with a User
class:
public class User implements StoredEntity {
private final String username;
private final String firstname;
private final String lastname;
public User(String username, String firstname, String lastname) {
this.username = username;
this.firstname = firstname;
this.lastname = lastname;
}
public String getUsername() {
return username;
}
public String getFirstname() {
return firstname;
}
public String getLastname() {
return lastname;
}
@Override
public String getId() {
return username;
}
}
Then you are able to create, get, list, update or delete User into various storage by instantiating a Storage<User>
:
Storage<User> storage = new xxxStorage<>(
// DEPENDS ON THE STORAGE IMPLEMENTATION
);
// store new user
storage.store(new User("fbar", "foo", "bar"));
// list all users
Collection<User> users = storage.list();
// update user
storage.store(new User("fbar", "Jason", "Wilson"));
// get specific user
User bob = storage.get("bob");
// delete a user
storage.delete("fbar");
Each implemented module contains its own specific documentation.
Look at existing implementations to learn how to implement your own Storage
. Don't forget to contribute :)