I have a map that stores a set of questions and answers. There cannot be questions with empty answers or answers with empty questions. Below is how I have initialized my map.
Optional<Map<String, String>> questionsAndAnswers();
I'm validating the empty strings for questions/answers in the following manner.
questionsAndAnswers().ifPresent(questionsAndAnswers -> {
        if (questionsAndAnswers.isEmpty()) {
            throw new IllegalArgumentException("questions cannot be empty if present");
        } else if (questionsAndAnswers.keySet().contains("") || questionsAndAnswers.values().contains("")) {
            throw new IllegalArgumentException("Questions or answers cannot be empty");
        }
    });
Is there a better way to achieve this? Any advice would be much appreciated.
UPDATE: There's no specific need for me to have these checks done in two separate conditions.
 
     
     
     
    