-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDistributed.java
More file actions
54 lines (47 loc) · 1.45 KB
/
Distributed.java
File metadata and controls
54 lines (47 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package storage;
import java.util.ArrayList;
import model.Entity;
import model.exceptions.CodecException;
import model.lightchain.Identifier;
/**
* Models distributed component of storage for a lightchain node that keeps entities in general form.
* Note that under the hood, an entity is encoded and kept as an EncodedEntity.
*/
public interface Distributed {
/**
* Checks existence of entity on the database.
*
* @param entityId Identifier of entity.
* @return true if a entity with that identifier exists, false otherwise.
*/
boolean has(Identifier entityId);
/**
* Adds entity to the database.
*
* @param e given entity to be added.
* @return true if entity did not exist on the database, false if entity is already in
* database.
*/
boolean add(Entity e) throws CodecException;
/**
* Removes entity with given identifier.
*
* @param e identifier of the entity.
* @return true if entity exists on database and removed successfully, false if entity does not exist on
* database.
*/
boolean remove(Entity e) throws CodecException;
/**
* Returns the entity with given identifier.
*
* @param e identifier of the entity.
* @return the entity itself if exists and null otherwise.
*/
Entity get(Identifier e) throws CodecException;
/**
* Returns all entities stored in database.
*
* @return all stored entities in database.
*/
ArrayList<Entity> all() throws CodecException;
}