Esempio n. 1
0
 /**
  * Tests if this object is equal to another
  *
  * @param a_obj the other object
  * @return true: this object is equal to the other one
  * @author Klaus Meffert
  * @since 2.3
  */
 public boolean equals(final Object a_obj) {
   if (a_obj == null) {
     return false;
   }
   if (a_obj == this) {
     return true;
   }
   if (!(a_obj instanceof KeyedValues)) {
     return false;
   }
   final KeyedValues kvs = (KeyedValues) a_obj;
   final int count = size();
   if (count != kvs.size()) {
     return false;
   }
   for (int i = 0; i < count; i++) {
     final Comparable k1 = getKey(i);
     final Comparable k2 = kvs.getKey(i);
     if (!k1.equals(k2)) {
       return false;
     }
     final Number v1 = getValue(i);
     final Number v2 = kvs.getValue(i);
     if (v1 == null) {
       if (v2 != null) {
         return false;
       }
     } else {
       if (!v1.equals(v2)) {
         return false;
       }
     }
   }
   return true;
 }
Esempio n. 2
0
 /**
  * @return clone of the current instance
  * @author Klaus Meffert
  * @since 2.3
  */
 public Object clone() {
   try {
     final KeyedValues clone = (KeyedValues) super.clone();
     clone.m_data = Collections.synchronizedList(new ArrayList());
     final Iterator iterator = m_data.iterator();
     while (iterator.hasNext()) {
       final KeyedValue kv = (KeyedValue) iterator.next();
       clone.m_data.add(kv.clone());
     }
     return clone;
   } catch (CloneNotSupportedException cex) {
     throw new CloneException(cex);
   }
 }