public abstract class AbstractAnnotation extends Object implements Annotation, Serializable
getProperties()
and propertiesAllocated()
.
Where possible implementations should be backed with a
LinkedHashMap
or similar so properties are iterated in the order
they were added.EMPTY_ANNOTATION
Modifier | Constructor and Description |
---|---|
protected |
AbstractAnnotation()
Protected no-args constructor intended for sub-classes.
|
protected |
AbstractAnnotation(Annotation ann)
Copy-constructor.
|
|
AbstractAnnotation(Map annMap)
Create a new Annotation by copying the key-value pairs from a map.
|
Modifier and Type | Method and Description |
---|---|
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.
|
boolean |
equals(Object o) |
protected abstract Map |
getProperties()
Implement this to return the Map delegate.
|
Object |
getProperty(Object key)
Retrieve the value of a property by key.
|
int |
hashCode() |
Set |
keys()
Get a set of key objects.
|
protected abstract boolean |
propertiesAllocated()
A convenience method to see if we have allocated the properties
Map.
|
void |
removeProperty(Object key)
Delete a property.
|
void |
setProperty(Object key,
Object value)
Set the value of a property.
|
String |
toString() |
protected AbstractAnnotation()
protected AbstractAnnotation(Annotation ann)
This does a shallow copy of the annotation. The result is an annotation with the same properties and values, but which is independant of the original annotation.
ann
- the Annotation to copypublic AbstractAnnotation(Map annMap)
annMap
- the Map to copy from.protected abstract Map getProperties()
LinkedHashMap
or similar so properties are iterated in the order
they were added.protected abstract boolean propertiesAllocated()
public Object getProperty(Object key) throws NoSuchElementException
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 retrieveNoSuchElementException
- if there is no property with the keypublic void setProperty(Object key, Object value)
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 keypublic void removeProperty(Object key) throws NoSuchElementException
Annotation
removeProperty
in interface Annotation
key
- the key objectNoSuchElementException
- if the property doesn't existpublic 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 © 2000–2018 BioJava. All rights reserved.