org.eidola.kernel
Class Class
java.lang.Object
|
+--org.eidola.kernel.event.EventBroadcaster
|
+--org.eidola.kernel.Container
|
+--org.eidola.kernel.Element
|
+--org.eidola.kernel.NamedElement
|
+--org.eidola.kernel.Capsule
|
+--org.eidola.kernel.Class
- public class Class
- extends Capsule
An Eidola type.
Eidola determines type by the generalization relationship:
a class explicitly declares which other classes are its parents,
and the generalization relationship is then a transitive, reflexive relation over
the chain of parents; see Class.Compilation.getGeneralizations()
.
For a class to legally claim another as its generalization, it must have a
matching subsignature. This means that (this is the Big Important Rule
here) for every public member of every parent class, there must be a matching
public member of the child class.
Familiar object-oriented languages will implicitly inherit members,
but the Big Important Rule means that in Eidola, subclasses explicitly
declare when they are inheriting a member. To allow inheritance, the public
members of a class fall under a slightly relaxed membership rule: instead of
requiring that a class own all of its public members, any generalization
of the class may own them. It is therefore possible for a class to borrow members
from its generalizations.
Private members necessarily get inherited from generalizations, but this only
happens at runtime and is invisible to static typing and scoping, so
it's safe to ignore it for now.
A class can claim multiple parents. In fact, since all potentially ambiguous
inheritance happens explicitly, it is fine to have a cycle in the generalization
graph. Yes, it seems strange, but it's fine when you work through it -- all this
means is that all the classes in the cycle have identical signatures.
Structure:
- name
- owner
- public members
- private members
- parents
Signature:
- name
- signatures of public members
See note on synchronization and concurrent read safety in Container
.
- Version:
- [Development version]
- Author:
- Paul Cantrell
Constructor Summary |
Class()
Creates a new empty class. |
Methods inherited from class org.eidola.kernel.Capsule |
addMember, addPrivate, addPublic, findMember, findPrivate, findPublic, getPrivate, getPublic, removeMember, removePrivate, removePublic, setMembers, setPrivate, setPublic |
PARENTS
public static final ContainerPart PARENTS
- Part of an element.
- See Also:
StructureChanged
Class
public Class()
- Creates a new empty class.
getParents
public Set getParents()
- Returns the set of parents, the generalizations this class explicitly declares.
- See Also:
Class.Compilation.getGeneralizations()
setParents
public void setParents(Collection newParents)
throws IllegalElementType
- Changes the set of parents.
Events: StructureChanged
- Parameters:
newParents
- A collection of Class
es which will be the new
parents. This method makes in internal copy of this collection,
so it is safe to pass a collection and subsequently modify it.
addParent
public void addParent(Class parent)
throws IllegalElementType
- Adds a parent.
Events: StructureChanged
- Parameters:
parent
- The class to add.
removeParent
public void removeParent(Class parent)
- Removes a parent.
Events: StructureChanged
- Parameters:
parent
- The class to remove.
handleContentEvent
public void handleContentEvent(ContainerEvent event)
- Handles an event passed on from a member. This handler
passes
SignatureChanged
events up the chain of public members,
and calls Container.handleContentEvent(ContainerEvent)
.
- Overrides:
handleContentEvent
in class Container
handleParentEvent
public void handleParentEvent(ContainerEvent event)
- Handles an event passed on from a parent. This handler
broadcasts a
CompileRequired
event when it receives a
SignatureChanged
event from a parent.
makeNewCompilation
protected Container.Compilation makeNewCompilation()
- Description copied from class:
Container
- Creates a new
Container.Compilation
of an appropriate type for this container.
This method only exists because Java does not use runtime types to resolve
inner class names; in other words, there are no virtual inner classes.
Under normal circumstances, you will not need to call this method directly;
use Container.compile()
instead. It is a good idea to synchronize on the
container when calling this method.
- Overrides:
makeNewCompilation
in class Container
dump
public void dump(int i)
- Description copied from class:
Container
- Does a debug dump of this container to System.out.
- Overrides:
dump
in class Container