package com.minelittlepony.pony.data; /** * Interface for enums that can be parsed from an image trigger pixel value. * @author Chris Albers * * @param */ public interface ITriggerPixelMapped & ITriggerPixelMapped> { /** * Gets the pixel colour matching this enum value. */ int getTriggerPixel(); /** * Gets the enum value corresponding to the given enum type and pixel value. * If none are found, the first parameter is returned as the default. * * @param type Return type and default value. * @param pixelValue The pixel colour to search for. */ @SuppressWarnings("unchecked") static & ITriggerPixelMapped> T getByTriggerPixel(T type, int pixelValue) { for (T i : (T[])type.getClass().getEnumConstants()) { if (i.getTriggerPixel() == pixelValue) return i; } return type; } }