import java.util.Optional;

public final class Main {

    public static void main (String[] args) {
        var yellow = Color.findByName("YELLOW");
        yellow.ifPresent(c -> {
            var rgb = c.getRgb();
            System.out.println("yellow: rgb=" + rgb);
        });

        // Alternatively, we may write as follows, but...
        var blue = Color.findByName("BLUE");
        if (blue.isPresent()) {
            var rgb = blue.get().getRgb();
            System.out.println("blue: rgb=" + rgb);
        }
    }

    public interface Color {

        /** Represents blue. */
        static final Color BLUE = () -> 0xff;

	    /**
	        Returns the Color instance that matches with the specified name.
	
	        @param name
	            ...
	        @return
	            An {@link Optional<T> Optional} object containing the Color
	            instance that matches with {@code name}, or an empty Optional
	            object (if nothing matches).
	    */
        static Optional<Color> findByName(String name) {
            return name.equals("BLUE")
                ? Optional.of(Color.BLUE)
                : Optional.empty();
        }

        /**
	        Returns the 24-bit integer value representing RGB.

            @return
                ...
        */
        int getRgb();
    }
}
