Account for a null attributes object
* field attributesCanBeModified - a null attributes object can't be modified in its current state * method makeAttributesModifiable() - initialize a null attributes object to empty
This commit is contained in:
parent
d0cf8bcc80
commit
f0c54d99ed
|
|
@ -182,7 +182,13 @@ public class VariantContextBuilder {
|
||||||
* @param attributes
|
* @param attributes
|
||||||
*/
|
*/
|
||||||
public VariantContextBuilder attributes(final Map<String, Object> attributes) {
|
public VariantContextBuilder attributes(final Map<String, Object> attributes) {
|
||||||
|
if (attributes != null) {
|
||||||
this.attributes = attributes;
|
this.attributes = attributes;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.attributes = new HashMap<String, Object>();
|
||||||
|
}
|
||||||
|
|
||||||
this.attributesCanBeModified = true;
|
this.attributesCanBeModified = true;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
@ -220,6 +226,7 @@ public class VariantContextBuilder {
|
||||||
* Makes the attributes field modifiable. In many cases attributes is just a pointer to an immutable
|
* Makes the attributes field modifiable. In many cases attributes is just a pointer to an immutable
|
||||||
* collection, so methods that want to add / remove records require the attributes to be copied to a
|
* collection, so methods that want to add / remove records require the attributes to be copied to a
|
||||||
*/
|
*/
|
||||||
|
@Ensures({"this.attributesCanBeModified"})
|
||||||
private void makeAttributesModifiable() {
|
private void makeAttributesModifiable() {
|
||||||
if ( ! attributesCanBeModified ) {
|
if ( ! attributesCanBeModified ) {
|
||||||
this.attributesCanBeModified = true;
|
this.attributesCanBeModified = true;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue