/*
 * 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.lockableContainers;

import doublex.lib.locks.Locks;

/**
 *
 * @author DoubleX
 * @param <C>
 * @param <K>
 */
public final class LockableContainer<C, K> implements IContainable<C>  {

    private final Locks<K> mLocks = new Locks<>();
    private C mContents = null;

    @Override
    public final void tryPutContents(final C contents) {
        if (canPutContents()) putContents(contents);
    }

    @Override
    public final C triedTakenContents() {
        return canTakeContents() ? takenContents() : null;
    }

    public final Locks<K> locks() {
        return mLocks;
    }

    private boolean canPutContents() {
        return !mLocks.isLocked() && isEmpty();
    }

    private void putContents(final C contents) {
        mContents = contents;
    }

    private boolean canTakeContents() {
        return !mLocks.isLocked() && !isEmpty();
    }

    private boolean isEmpty() {
        return mContents == null;
    };

    private C takenContents() {
        final C contents = mContents;
        clearContents();
        return contents;
    }

    private void clearContents() {
        mContents = null;
    }

};

@@ -244,16 +244,17 @@
 b.locks.
+I
 Locks;%0A%0A
@@ -394,21 +394,21 @@
    p
-rivate
+ublic
  final 
+I
 Lock
@@ -422,24 +422,8 @@
 ocks
- = new Locks%3C%3E()
 ;%0A  
@@ -453,16 +453,102 @@
  null;%0A%0A
+    public LockableContainer(final ILocks%3CK%3E locks) %7B%0A        mLocks = locks;%0A    %7D;%0A%0A
     @Ove
@@ -796,74 +796,8 @@
  %7D%0A%0A
-    public final Locks%3CK%3E locks() %7B%0A        return mLocks;%0A    %7D%0A%0A
     

Update LockableContainer.java