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

io.permazen.change.SetFieldClear Maven / Gradle / Ivy

There is a newer version: 5.1.0
Show newest version

/*
 * Copyright (C) 2015 Archie L. Cobbs. All rights reserved.
 */

package io.permazen.change;

import io.permazen.JObject;
import io.permazen.JTransaction;

/**
 * Notification object that gets passed to {@link io.permazen.annotation.OnChange @OnChange}-annotated methods
 * when a set field is cleared.
 *
 * @param  the type of the object containing the changed field
 */
public class SetFieldClear extends SetFieldChange {

    /**
     * Constructor.
     *
     * @param jobj Java object containing the set 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 SetFieldClear(T jobj, int storageId, String fieldName) {
        super(jobj, storageId, fieldName);
    }

    @Override
    public  R visit(ChangeSwitch target) {
        return target.caseSetFieldClear(this);
    }

    @Override
    public void apply(JTransaction jtx, JObject jobj) {
        jtx.readSetField(jobj.getObjId(), this.getStorageId(), false).clear();
    }

// Object

    @Override
    public String toString() {
        return "SetFieldClear[object=" + this.getObject() + ",field=\"" + this.getFieldName() + "\"]";
    }
}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy