All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jsimpledb.change.MapFieldClear Maven / Gradle / Ivy

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() + "\"]";
    }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy