Java - Write code to cast To Char and return Optional<Character>

Requirements

Write code to cast To Char and return Optional<Character>

Demo

//package com.book2s;

import java.util.Optional;

public class Main {
    public static void main(String[] argv) {
        String text = "b";
        System.out.println(castToChar(text));
    }//from w w  w .  ja  v  a  2  s  .com

    public static Optional<Character> castToChar(String text) {
        return (!looksLikeCharacter(text)) ? Optional.<Character> empty()
                : Optional.of(text.charAt(0));
    }

    public static boolean looksLikeCharacter(String text) {
        return (text.length() == 1) ? true : false;
    }
}