1 16 17 package org.apache.commons.configuration; 18 19 import java.util.Iterator ; 20 21 30 public class StrictConfigurationComparator implements ConfigurationComparator 31 { 32 35 public StrictConfigurationComparator() 36 { 37 } 38 39 48 public boolean compare(Configuration a, Configuration b) 49 { 50 if (a == null && b == null) 51 { 52 return true; 53 } 54 else if (a == null || b == null) 55 { 56 return false; 57 } 58 59 for (Iterator keys = a.getKeys(); keys.hasNext();) 60 { 61 String key = (String ) keys.next(); 62 Object value = a.getProperty(key); 63 if (!value.equals(b.getProperty(key))) 64 { 65 return false; 66 } 67 } 68 69 for (Iterator keys = b.getKeys(); keys.hasNext();) 70 { 71 String key = (String ) keys.next(); 72 Object value = b.getProperty(key); 73 if (!value.equals(a.getProperty(key))) 74 { 75 return false; 76 } 77 } 78 79 return true; 80 } 81 } 82 | Popular Tags |