public abstract class Library extends Node
GenerateLibrary
. Implementations for the abstract methods specified in this classes are
not supposed to be implemented manually.GenerateLibrary
Node.Child, Node.Children
Modifier | Constructor and Description |
---|---|
protected |
Library()
Default constructor for sub-classes.
|
Modifier and Type | Method and Description |
---|---|
abstract boolean |
accepts(Object receiver)
Returns
true if this library instance supports sending messages with the given
receiver. |
accept, adoptChildren, atomic, atomic, copy, deepCopy, getChildren, getCost, getDebugProperties, getDescription, getEncapsulatingSourceSection, getLock, getParent, getRootNode, getSourceSection, insert, insert, isAdoptable, isSafelyReplaceableBy, notifyInserted, onReplace, replace, replace, reportPolymorphicSpecialize, toString
protected Library()
public abstract boolean accepts(Object receiver)
true
if this library instance supports sending messages with the given
receiver. If accepts returns false
and a library message is sent anyway then an
AssertionError
is thrown if assertions are enabled (-ea). Otherwise a
NullPointerException
or ClassCastException
may be thrown by the method.
A library that was created using a receiver value i.e. a
LibraryFactory.create(Object)
only guarantees to accept the value it was constructed
with. For other values, the method may return false
. Such libraries need to
check for acceptance before calling a library method with a receiver. If receiver values are
not accepted then a new library needs to be created or fetched. Dispatched versions of
libraries always return true
for any value as they take care of dispatching to
any receiver type.
It is not necessary to call accepts manually for most use cases. Instead the
CachedLibrary
should be used instead. For slow-paths the
internally dispatched
versions of the uncached library
should be used.
The accepts message may be exported by receiver types. When exported it can only be further restricted in addition to the default accepts implementation.
for ways how to dispatch libraries.