Package com.abstratt.kirra
Class Entity
- java.lang.Object
-
- com.abstratt.kirra.NamedElement<Namespace>
-
- com.abstratt.kirra.TopLevelElement
-
- com.abstratt.kirra.Entity
-
- All Implemented Interfaces:
BehaviorScope
,DataScope
,NameScope
,Serializable
,Comparable<NamedElement<Namespace>>
public class Entity extends TopLevelElement implements BehaviorScope, DataScope
An entity defines the type ofInstance
s that contains properties, relationships and behavior elements.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
concrete
protected Map<String,String>
disabledActions
A map of disabled action names -> reasons.protected boolean
instantiable
protected String
mnemonicSlot
protected Map<String,Operation>
operations
protected List<String>
orderedDataElements
protected Map<String,Property>
properties
protected Map<String,Relationship>
relationships
protected boolean
role
protected boolean
standalone
protected Collection<TypeRef>
subTypes
protected Collection<TypeRef>
superTypes
protected boolean
topLevel
protected boolean
user
-
Fields inherited from class com.abstratt.kirra.TopLevelElement
namespace
-
Fields inherited from class com.abstratt.kirra.NamedElement
description, label, name, symbol, userVisible
-
-
Constructor Summary
Constructors Constructor Description Entity()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
Map<String,String>
getDisabledActions()
Returns the map of names of disabled actions and optionally reasons for the disablement.String
getEntityNamespace()
String
getMnemonicSlot()
Returns the name of the property or relationship to be used to identify instances of this entity.Operation
getOperation(String name)
List<Operation>
getOperations()
List<String>
getOrderedDataElements()
The lists of names of data elements, in the order they should be presented to users.List<Property>
getProperties()
Property
getProperty(String name)
Relationship
getRelationship(String name)
List<Relationship>
getRelationships()
Collection<TypeRef>
getSuperTypes()
Entities may be derived from other entities.TypeRef.TypeKind
getTypeKind()
int
hashCode()
boolean
isA(TypeRef anotherType)
boolean
isConcrete()
Only concrete entities may be instantiated.boolean
isInstantiable()
One reason entities may not be instantiatable is that they are not concrete.boolean
isRole()
Does this entity represent a user role in the system?boolean
isStandalone()
Returns whether this entity is standalone.boolean
isTopLevel()
Returns whether this entity is top-level.boolean
isUser()
Does this entity repesent a user entity in the system?void
setConcrete(boolean concrete)
void
setDisabledActions(Map<String,String> disabledActions)
void
setInstantiable(boolean instantiable)
void
setMnemonicSlot(String mnemonicSlot)
void
setOperations(List<Operation> operations)
void
setOrderedDataElements(List<String> orderedDataElements)
void
setProperties(List<Property> properties)
void
setRelationships(List<Relationship> entityRelationships)
void
setRole(boolean role)
void
setStandalone(boolean standalone)
void
setSubTypes(Collection<TypeRef> subTypes)
void
setSuperTypes(Collection<TypeRef> superTypes)
void
setTopLevel(boolean topLevel)
void
setUser(boolean user)
-
Methods inherited from class com.abstratt.kirra.TopLevelElement
getNamespace, getTypeRef, setNamespace
-
Methods inherited from class com.abstratt.kirra.NamedElement
compareTo, getDescription, getLabel, getName, getSymbol, isUserVisible, setDescription, setLabel, setName, setSymbol, setUserVisible, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.abstratt.kirra.NameScope
getTypeRef
-
-
-
-
Field Detail
-
concrete
protected boolean concrete
-
instantiable
protected boolean instantiable
-
standalone
protected boolean standalone
-
topLevel
protected boolean topLevel
-
role
protected boolean role
-
user
protected boolean user
-
mnemonicSlot
protected String mnemonicSlot
-
superTypes
protected Collection<TypeRef> superTypes
-
subTypes
protected Collection<TypeRef> subTypes
-
disabledActions
protected Map<String,String> disabledActions
A map of disabled action names -> reasons.
-
relationships
protected Map<String,Relationship> relationships
-
-
Method Detail
-
equals
public boolean equals(Object obj)
- Overrides:
equals
in classNamedElement<Namespace>
-
getDisabledActions
public Map<String,String> getDisabledActions()
Returns the map of names of disabled actions and optionally reasons for the disablement. For instance, checkout should be disabled while the shopping cart is empty.
-
getEntityNamespace
public String getEntityNamespace()
-
getOperation
public Operation getOperation(String name)
- Specified by:
getOperation
in interfaceBehaviorScope
-
getOperations
public List<Operation> getOperations()
- Specified by:
getOperations
in interfaceBehaviorScope
-
getProperties
public List<Property> getProperties()
- Specified by:
getProperties
in interfaceDataScope
-
getProperty
public Property getProperty(String name)
- Specified by:
getProperty
in interfaceDataScope
-
getRelationship
public Relationship getRelationship(String name)
-
getRelationships
public List<Relationship> getRelationships()
-
getSuperTypes
public Collection<TypeRef> getSuperTypes()
Entities may be derived from other entities.
-
getTypeKind
public TypeRef.TypeKind getTypeKind()
- Specified by:
getTypeKind
in interfaceNameScope
-
getMnemonicSlot
public String getMnemonicSlot()
Returns the name of the property or relationship to be used to identify instances of this entity. For instance, for a Person, "fullName" may be a good choice.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classNamedElement<Namespace>
-
isA
public boolean isA(TypeRef anotherType)
- Overrides:
isA
in classTopLevelElement
-
isConcrete
public boolean isConcrete()
Only concrete entities may be instantiated.
-
isStandalone
public boolean isStandalone()
Returns whether this entity is standalone. An entity is standalone if it has no required container references.
-
isTopLevel
public boolean isTopLevel()
Returns whether this entity is top-level. An entity is top-level if:- it is standalone
- or is explicitly annotated as top-level or at least one super type is a top-level class
- Returns:
true
if the given class corresponds to a top-level entity,false
otherwise
-
setConcrete
public void setConcrete(boolean concrete)
-
setRelationships
public void setRelationships(List<Relationship> entityRelationships)
-
setStandalone
public void setStandalone(boolean standalone)
-
setSuperTypes
public void setSuperTypes(Collection<TypeRef> superTypes)
-
setSubTypes
public void setSubTypes(Collection<TypeRef> subTypes)
-
setTopLevel
public void setTopLevel(boolean topLevel)
-
isRole
public boolean isRole()
Does this entity represent a user role in the system?
-
setRole
public void setRole(boolean role)
-
isUser
public boolean isUser()
Does this entity repesent a user entity in the system?
-
setUser
public void setUser(boolean user)
-
setMnemonicSlot
public void setMnemonicSlot(String mnemonicSlot)
-
setInstantiable
public void setInstantiable(boolean instantiable)
-
isInstantiable
public boolean isInstantiable()
One reason entities may not be instantiatable is that they are not concrete. Another may that they can only be created via actions on other instances.
-
getOrderedDataElements
public List<String> getOrderedDataElements()
The lists of names of data elements, in the order they should be presented to users.
-
-