package speiger.src.coreengine.utils.io.dataTag.compression;

import java.io.IOException;

public interface DataTagLimiter {
	public static final DataTagLimiter INFINTE = _ -> {};
	
	public static DataTagLimiter limit(int byteLimit) {
		return new Instance(byteLimit);
	}
	
	public void countBytes(int amount) throws IOException;
	
	public static class Instance implements DataTagLimiter {
		final int max;
		int read = 0;
		
		public Instance(int max) {
			this.max = max;
		}
		
		@Override
		public void countBytes(int amount) throws IOException {
			read += amount;
			if(read > amount) throw new IllegalStateException("To many Bytes Read");
		}
	}
}
