package ru.nsu.ccfit.bogush.factory;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import ru.nsu.ccfit.bogush.threadpool.BlockingQueue;


public class Storage <T extends CarFactoryObject> extends SimplyNamed {
	private BlockingQueue<T> queue;
	private final int capacity;
	private Class<T> contentType;

	private static final String LOGGER_NAME = "Storage";
	private static final Logger logger = LogManager.getLogger(LOGGER_NAME);

	public Storage(Class<T> contentType, int capacity) {
		logger.trace("initialize Storage<" + contentType.getSimpleName() + "> with capacity " + capacity);
		this.contentType = contentType;
		this.capacity = capacity;
		this.queue = new BlockingQueue<T>(capacity);
	}

	public void store(T thing) throws InterruptedException {
		queue.put(thing);
		logger.debug(thing + " stored in " + this);
	}

	public T take() throws InterruptedException {
		T result = queue.take();
		logger.debug(result + " taken from " + this);
		return result;
	}

	public void addSizeSubscriber(BlockingQueue.SizeSubscriber sizeSubscriber) {
		logger.trace("addCarSoldSubscriber " + sizeSubscriber);
		queue.addSizeSubscriber(sizeSubscriber);
	}

	public int size() {
		return queue.size();
	}

	public int capacity() { return capacity; }

	public boolean isEmpty() {
		return queue.isEmpty();
	}

	public boolean isFull() {
		return queue.isFull();
	}

	@Override
	public String toString() {
		return super.toString() + "(size=" + queue.size() + " capacity=" + capacity + ")";
	}
}

@@ -223,31 +223,11 @@
 ect%3E
- extends SimplyNamed
  %7B%0A
+
 %09pri
@@ -799,21 +799,21 @@
 %09logger.
-debug
+trace
 (thing +
@@ -927,13 +927,13 @@
 ger.
-debug
+trace
 (res
@@ -1425,28 +1425,80 @@
 urn 
-super.toString() + %22
+ getClass().getSimpleName() + %22%3C%22 + contentType.getSimpleName() +%0A%09%09%09%09%22%3E
 (siz
@@ -1517,17 +1517,21 @@
 size() +
- 
+%0A%09%09%09%09
 %22 capaci

Change toString() Remove super class Change logs