package me.blackphreak.Debug;

import java.util.Arrays;

public enum DebugLevel {
	NONE (0, ""),
	INFO (1, "+"),
	WARN (2, "!"),
	ERR  (4, "-"),
	DEBUG(8, "."),
	ALL  (Integer.MAX_VALUE, "");
	
	private int     _level;
	private String  _symbol;
	
	DebugLevel(int level, String symbol) {
		this._level     = level;
		this._symbol    = symbol;
	}
	
	public int getLevel() {
		return this._level;
	}
	
	public String getSymbol() {
		return this._symbol;
	}
	
	public static DebugLevel getLowest(int lv) {
		var tmp = new Object() {
			DebugLevel lowest = DebugLevel.ALL;
		};
		
		// get the lowest DebugLevel in provided number (variable: lv)
		Arrays.stream(DebugLevel.values()).forEach(dbLv -> {
			if ((dbLv.getLevel() & lv) > 0)
				if (dbLv.getLevel() < tmp.lowest.getLevel())
					tmp.lowest = dbLv;
		});
		
		return tmp.lowest;
	}
}
