/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package doublex.lib.locks;

/**
 *
 * @author DoubleX
 * @param <K>
 */
public final class MutableLock<K> extends AbstractLock<K> implements 
        IMutableLockable<K> {

    private K mKey;

    public MutableLock(final K key) {
        changeKey(key);
    }

    @Override
    public void tryChangeKey(final K oldKey, final K newKey) {
        if (canChangeKey(oldKey)) {
            changeKey(newKey);
        }
    }

    @Override
    boolean isCorrectKey(final K key) {
        return mKey.equals(key);
    }

    private boolean canChangeKey(final K oldKey) {
        return !isLocked() && isCorrectKey(oldKey);
    }

    private void changeKey(final K key) {
        mKey = key;
    }

};

@@ -203,16 +203,123 @@
 ib.locks
+.lock;%0A%0Aimport doublex.lib.locks.IMutableLockable;%0Aimport doublex.lib.locks.exceptions.KeyMismatchException
 ;%0A%0A/**%0A 
@@ -627,23 +627,96 @@
 ey) 
-%7B%0A        if (c
+%0A            throws KeyMismatchException %7B%0A        if (!isLocked()) %7B%0A            checkC
 anCh
@@ -730,19 +730,17 @@
 (oldKey)
-) %7B
+;
 %0A       
@@ -890,17 +890,19 @@
 ate 
-boolean c
+void checkC
 anCh
@@ -929,61 +929,130 @@
 ey) 
-%7B%0A        return !isLocked() && isCorrectKey(oldKey);
+throws KeyMismatchException %7B%0A        if (!isCorrectKey(oldKey)) %7B%0A            throw new KeyMismatchException();%0A        %7D
 %0A   

Update MutableLock.java