Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. Object yamlObject = yaml.load(someYamlDocumentAsString);
  2. // I only want to proceed if this YAML object is a Map<String, Object>
  3. if ((yamlObject instanceof Map<?, ?>)) {
  4. Map<?, ?> propertyMap = (Map<?, ?>) yamlObject;
  5. for (Entry<?, ?> propertyEntry : propertyMap.entrySet()) {
  6. // I am checking each key and throwing if it's not a "String"
  7. Object propertyKey = propertyEntry.getKey();
  8. if (!(propertyKey instanceof CharSequence)) {
  9. throw new BananaException("FIXME"); // FIXME
  10. }
  11. }
  12. } else {
  13. throw new CoconutException("FIXME"); // FIXME
  14. }
  15.  
  16. @SuppressWarnings("unchecked")
  17. Map<String, Object> aBeautifulAndCozyMap = (Map<String, Object>) propertyMap;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement