I have an enum class and method getColor, which returns a color depending on the index or black color when index doesn't exist. I would like to convert this method to Java Streams but I have a problem with how to do it.
My method:
public static Color getColor(String colorIndex) {
    if (StringUtils.isNotBlank(colorIndex)) {
        int i = Integer.parseInt(colorIndex);
        for (Color color : values()) {
            if (color.colorIndex == i) {
                return color;
            }
        }
    }
    return BLACK;
}
 
     
     
    