April 05
Prde. Ismael H. F. Santos -  ismael@tecgraf.puc-rio.br                                                          2
Exemplo Map
nValida Map com requiredAttrs e apenas com permittedAttrs
nstatic <K, V> boolean validate(Map<K, V> attrMap,
n                                                 Set<K> requiredAttrs, Set<K> permittedAttrs) {
n     boolean valid = true;
n     Set<K> attrs = attrMap.keySet();
n     if( !attrs.containsAll(requiredAttrs) ) {
n        Set<K> missing = new HashSet<K>(requiredAttrs); 
n        missing.removeAll(attrs);
n        System.out.println("Missing attributes: " + missing);  valid = false;
n      }
n      if ( !permittedAttrs.containsAll(attrs) ) {
n          Set<K> illegal = new HashSet<K>(attrs);
n          illegal.removeAll(permittedAttrs);
n          System.out.println("Illegal attributes: " + illegal); valid = false;
n       }
n       return valid;
n}