-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathEntity.java
64 lines (57 loc) · 2.04 KB
/
Entity.java
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
55
56
57
58
59
60
61
62
63
64
/*
* Made with all the love in the world
* by scireum in Remshalden, Germany
*
* Copyright by scireum GmbH
* http://www.scireum.de - [email protected]
*/
package sirius.db.mixing;
/**
* Describes methods implemented in {@link BaseEntity} and therefore available for all entities.
* <p>
* The reason to define an extra interface is to have a base interface when defining database independent entities.
* They are commonly defined as interfaces and then implemented by one or more subclasses of specific entities.
* However e.g. the templates often refer to the interface itself so there is only one UI to manage all kinds of
* entities. Therefore we need a super interface so that Tagliatelle (which only sees the interface) knows which
* methods are available.
*/
public interface Entity {
/**
* Determines if the entity is new (not yet written to the database).
*
* @return <tt>true</tt> if the entity has not been written to the database yet, <tt>false</tt> otherwise
*/
boolean isNew();
/**
* Each entity type can be addressed by its class or by a unique name, which is its simple class name in upper
* case.
*
* @return the type name of this entity type
* @see #getUniqueName()
*/
String getTypeName();
/**
* Returns an unique name of this entity.
* <p>
* This unique string representation of this entity is made up of its type along with its id.
*
* @return an unique representation of this entity or an empty string if the entity was not written to the
* database yet
*/
String getUniqueName();
/**
* Returns a string representation of the entity ID.
* <p>
* If the entity is new, "new" will be returned.
*
* @return the entity ID as string or "new" if the entity {@link #isNew()}.
*/
String getIdAsString();
/**
* Provides a simple re-definition so that this method is visible to Tagliatelle as well.
*
* @return a string representation of this entity
*/
@Override
String toString();
}