Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Object yamlObject = yaml.load(someYamlDocumentAsString);
- // I only want to proceed if this YAML object is a Map<String, Object>
- if ((yamlObject instanceof Map<?, ?>)) {
- Map<?, ?> propertyMap = (Map<?, ?>) yamlObject;
- for (Entry<?, ?> propertyEntry : propertyMap.entrySet()) {
- // I am checking each key and throwing if it's not a "String"
- Object propertyKey = propertyEntry.getKey();
- if (!(propertyKey instanceof CharSequence)) {
- throw new BananaException("FIXME"); // FIXME
- }
- }
- } else {
- throw new CoconutException("FIXME"); // FIXME
- }
- @SuppressWarnings("unchecked")
- Map<String, Object> aBeautifulAndCozyMap = (Map<String, Object>) propertyMap;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement