public class MergeAnnotation extends AbstractChangeable implements Annotation, Serializable
Modifier and Type | Class and Description |
---|---|
protected class |
MergeAnnotation.PropertyForwarder
Listener used to forward changes for any of the underlying annotations to
listeners on this annotation.
|
Modifier and Type | Field and Description |
---|---|
static ChangeType |
ANNOTATION_ADD
ChangeType of ChangeEvent fired before and after an annotation is added
to MergeAnnotation.
|
static ChangeType |
ANNOTATION_CHANGED
ChangeType of ChangeEvent fired before and after an annotation is added
to MergeAnnotation.
|
static ChangeType |
ANNOTATION_REMOVE
ChangeType of ChangeEvent fired before and after an annotation is added
to MergeAnnotation.
|
EMPTY_ANNOTATION, PROPERTY
Constructor and Description |
---|
MergeAnnotation() |
Modifier and Type | Method and Description |
---|---|
void |
addAnnotation(Annotation ann)
Add a new Annotation to to the end of the list to be merged.
|
Map |
asMap()
Return a map that contains the same key/values as this Annotation.
|
boolean |
containsProperty(Object key)
Returns whether there the property is defined.
|
List |
getAnnotations()
Gets an unmodifiable view of the list of Annotations that are part of the
MergeAnnotation.
|
protected ChangeSupport |
getChangeSupport(ChangeType changeType)
Called to retrieve the ChangeSupport for this object.
|
Object |
getProperty(Object key)
Retrieve the value of a property by key.
|
Set |
keys()
Get a set of key objects.
|
void |
removeAnnotation(Annotation ann)
Remove an Annotation from the list.
|
void |
removeProperty(Object key)
Delete a property.
|
void |
setProperty(Object key,
Object value)
Set the value of a property.
|
addChangeListener, addChangeListener, generateChangeSupport, hasListeners, hasListeners, isUnchanging, removeChangeListener, removeChangeListener
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addChangeListener, addChangeListener, isUnchanging, removeChangeListener, removeChangeListener
public static final ChangeType ANNOTATION_CHANGED
public static final ChangeType ANNOTATION_ADD
public static final ChangeType ANNOTATION_REMOVE
public MergeAnnotation()
public void addAnnotation(Annotation ann) throws ChangeVetoException
ann
- the Annotation to addChangeVetoException
- if the annotation could not be addedpublic List getAnnotations()
List
of the Annotations that form
this MergeAnnotation.public void removeAnnotation(Annotation ann) throws ChangeVetoException
ann
- an Annotation
to be removed.ChangeVetoException
- if an error occursprotected ChangeSupport getChangeSupport(ChangeType changeType)
AbstractChangeable
Your implementation of this method should have the following structure:
It is usual for the forwarding listeners (someForwarder in this example) to
be transient and lazily instantiated. Be sure to register & unregister the
forwarder in the code that does the ChangeEvent handling in setter methods.
ChangeSupport cs = super.getChangeSupport(ct);
if(someForwarder == null && ct.isMatching(SomeInterface.SomeChangeType)) {
someForwarder = new ChangeForwarder(...
this.stateVariable.addChangeListener(someForwarder, VariableInterface.AChange);
}
return cs;
getChangeSupport
in class AbstractChangeable
public void setProperty(Object key, Object value) throws ChangeVetoException
Annotation
Set the value of a property.
This method throws an exception if either properties can not be added to this object, or that this particular property is immutable or illegal within the implementation.
Normal raw access to the property. For cleverer access, use methods in AnnotationType.setProperty
in interface Annotation
key
- the key objectvalue
- the new value for this keyChangeVetoException
- if this annotation object can't be changed, or
if the change was vetoed.public void removeProperty(Object key) throws ChangeVetoException
Annotation
removeProperty
in interface Annotation
key
- the key objectChangeVetoException
- if the change is vetoedpublic Object getProperty(Object key)
Annotation
Retrieve the value of a property by key.
Unlike the Map collections, it will complain if the key does not exist. It will only return null if the key is defined and has value null.
Normal raw access to the property. For cleverer access, use methods in AnnotationType.getProperty
in interface Annotation
key
- the key of the property to retrievepublic boolean containsProperty(Object key)
Annotation
containsProperty
in interface Annotation
key
- the key Object to search forpublic Set keys()
Annotation
keys
in interface Annotation
public Map asMap()
Annotation
If the annotation changes, the map may not reflect this. The Map may be unmodifiable.
asMap
in interface Annotation
Copyright © 2014 BioJava. All rights reserved.