Created
October 23, 2021 23:17
-
-
Save RodrigoPinho/72b71eef4ee1e02ce3ea60a224dc746f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static String getGuardedPatternMessage(Object object) { | |
return switch (object) { | |
case String s && (s.length() > 10)-> | |
"Big string, size: " + s.length(); | |
case String s -> | |
"Small string, size: " + s.length(); | |
default -> "Unsupported Object: " + object.getClass().getSimpleName(); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment