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

org.dellroad.stuff.pobj.PersistentObjectVersionException Maven / Gradle / Ivy


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

package org.dellroad.stuff.pobj;

/**
 * Optimistic locking exception thrown by {@link PersistentObject#setRoot PersistentObject.setRoot()}
 * when the expected version number does not agree.
 */
@SuppressWarnings("serial")
public class PersistentObjectVersionException extends PersistentObjectException {

    private final long actualVersion;
    private final long expectedVersion;

    public PersistentObjectVersionException(long actualVersion, long expectedVersion) {
        super("expected version " + expectedVersion + " but actual version was " + actualVersion);
        this.actualVersion = actualVersion;
        this.expectedVersion = expectedVersion;
    }

    /**
     * Get the actual, unexpected version number.
     *
     * @return actual version number
     */
    public long getActualVersion() {
        return this.actualVersion;
    }

    /**
     * Get the version number that was expected.
     *
     * @return expected version number
     */
    public long getExpectedVersion() {
        return this.expectedVersion;
    }
}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy