package com.kinancity.core.proxy.policies;

import java.util.Optional;

import com.kinancity.core.proxy.ProxySlot;

import lombok.Getter;

/**
 * Ideal unlimited use policy.
 * 
 * Only gets blocked if marked over limit Can be released with reset
 * 
 * @author drallieiv
 *
 */
@Getter
public class UnlimitedUsePolicy implements ProxyPolicy {

	private boolean overLimit = false;

	public void reset() {
		overLimit = false;
	}

	@Override
	public void markOverLimit() {
		overLimit = true;
	}

	@Override
	public boolean isAvailable() {
		return !overLimit;
	}

	public String toString() {
		return "unlimited";
	}

	@Override
	public UnlimitedUsePolicy clone() {
		return new UnlimitedUsePolicy();
	}

	@Override
	public Optional<ProxySlot> getFreeSlot() {
		if (overLimit) {
			return Optional.empty();
		}
		return Optional.of(new ProxySlot());
	}

}

@@ -178,12 +178,13 @@
 %0A * 
-Only
+Never
  get
@@ -196,56 +196,27 @@
 cked
- if marked over limit Can be released with reset
+. Always available.
 %0A * 
@@ -315,91 +315,72 @@
 %7B%0A%0A%09
-private boolean overLimit = false;%0A%0A%09public void reset() %7B%0A%09%09overLimit = fals
+@Override%0A%09public boolean isAvailable() %7B%0A%09%09return tru
 e;%0A%09%7D%0A
+    
 %0A%09@O
@@ -422,153 +422,32 @@
 ) %7B%0A
-%09%09overLimit = true;%0A%09%7D%0A%0A%09@Override%0A%09public boolean isAvailable() %7B%0A%09%09return !overLimit;%0A%09%7D%0A%0A%09public String toString() %7B%0A%09%09return %22unlimited%22;%0A%09%7D%0A
+        %09return;%0A%09%7D%0A    
 %0A%09@O
@@ -591,98 +591,103 @@
 %7B%0A%09%09
-if (overLimit) %7B%0A%09%09%09return Optional.empty(
+return Optional.of(new ProxySlot()
 );%0A
-%09
 %09%7D%0A%09
-%09return Optional.of(new ProxySlot())
+%0A%09public String toString() %7B%0A%09%09return %22unlimited%22
 ;%0A%09%7D%0A
+%09
 %0A%7D%0A

Make UnlimitedPolicy truly unlimited