@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null || (obj instanceof TableValue) == false) return false; TableValue other = (TableValue) obj; if (tableType.equals(other.getMetaType()) == false) return false; if (size() != other.size()) return false; for (Entry<List<MetaValue>, CompositeValue> entry : dataMap.entrySet()) { List<MetaValue> list = entry.getKey(); MetaValue[] indexes = list.toArray(new MetaValue[list.size()]); CompositeValue thisValue = entry.getValue(); CompositeValue otherValue = other.get(indexes); if (thisValue == null && otherValue == null) return true; if (thisValue == null && otherValue != null) return false; if (thisValue.equals(otherValue) == false) return false; } return true; }
/** * Create a map * * @param tableValue the table value * @param keyType the key type * @param valueType the value type * @return the map */ protected Map createMap(TableValue tableValue, TypeInfo keyType, TypeInfo valueType) { if (tableValue == null) return null; Map<Object, Object> result = new HashMap<Object, Object>(); Collection<CompositeValue> values = tableValue.values(); for (CompositeValue entry : values) { Object key = unwrap(entry.get(DefaultMetaTypeFactory.MAP_KEY), keyType); Object val = unwrap(entry.get(DefaultMetaTypeFactory.MAP_VALUE), valueType); result.put(key, val); } return result; }
@Override public boolean isValue(Object obj) { if (obj == null || obj instanceof TableValue == false) return false; TableMetaType other = ((TableValue) obj).getMetaType(); return equals(other); }
/** * Create a map * * @param tableValue the table value * @param keyType the key type * @param valueType the value type * @return the map */ protected Map<?,?> createMap(TableValue tableValue, TypeInfo keyType, TypeInfo valueType) { if (tableValue == null) return null; Map<Object, Object> result = new HashMap<Object, Object>(); Collection<CompositeValue> values = tableValue.values(); for (CompositeValue entry : values) { Object key = unwrap(entry.get(DefaultMetaTypeFactory.MAP_KEY), keyType); Object val = unwrap(entry.get(DefaultMetaTypeFactory.MAP_VALUE), valueType); result.put(key, val); } return result; }
@Override public boolean isValue(Object obj) { if (obj == null || obj instanceof TableValue == false) return false; TableMetaType other = ((TableValue) obj).getMetaType(); return equals(other); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null || (obj instanceof TableValue) == false) return false; TableValue other = (TableValue) obj; if (tableType.equals(other.getMetaType()) == false) return false; if (size() != other.size()) return false; for (Entry<List<MetaValue>, CompositeValue> entry : dataMap.entrySet()) { List<MetaValue> list = entry.getKey(); MetaValue[] indexes = list.toArray(new MetaValue[list.size()]); CompositeValue thisValue = entry.getValue(); CompositeValue otherValue = other.get(indexes); if (thisValue == null && otherValue == null) return true; if (thisValue == null && otherValue != null) return false; if (thisValue.equals(otherValue) == false) return false; } return true; }
/** * Create the persistence table value. * * @param value the table value * @param the persisted table * @return the persistence table xml meta data */ protected PersistedTableValue createTableValue(TableValue value) { PersistedTableValue table = new PersistedTableValue(); // Fix the entries List<PersistedCompositeValue> entries = table.getEntries(); if(entries == null) { entries = new ArrayList<PersistedCompositeValue>(); table.setEntries(entries); } // Process values Collection<CompositeValue> values = value.values(); for(CompositeValue entry : values) { entries.add(createCompositeValue(entry, entry.getMetaType())); } return table; }