org.jsimpledb.change.MapFieldClear Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jsimpledb-main Show documentation
Show all versions of jsimpledb-main Show documentation
JSimpleDB classes that map Java model classes onto the core API.
The newest version!
/*
* Copyright (C) 2015 Archie L. Cobbs. All rights reserved.
*/
package org.jsimpledb.change;
import org.jsimpledb.JObject;
import org.jsimpledb.JTransaction;
/**
* Notification object that gets passed to {@link org.jsimpledb.annotation.OnChange @OnChange}-annotated methods
* when a map field is cleared.
*
* @param the type of the object containing the changed field
*/
public class MapFieldClear extends MapFieldChange {
/**
* Constructor.
*
* @param jobj Java object containing the map field that was cleared
* @param storageId the storage ID of the affected field
* @param fieldName the name of the field that changed
* @throws IllegalArgumentException if {@code jobj} or {@code fieldName} is null
*/
public MapFieldClear(T jobj, int storageId, String fieldName) {
super(jobj, storageId, fieldName);
}
@Override
public R visit(ChangeSwitch target) {
return target.caseMapFieldClear(this);
}
@Override
public void apply(JTransaction jtx, JObject jobj) {
jtx.readMapField(jobj.getObjId(), this.getStorageId(), false).clear();
}
// Object
@Override
public String toString() {
return "MapFieldClear[object=" + this.getObject() + ",field=\"" + this.getFieldName() + "\"]";
}
}