@Override public boolean put(DynamicData key, DynamicData value) { if (key.getTypeDescriptor().getKind() == this.m_keyContentType.getKind()) { if (value.getTypeDescriptor().getKind() == this.m_contentType.getKind()) { if (this.m_members.size() != this.m_maxSize) { if (!this.existsInMap(key)) { this.m_keyMembers.add(key); this.m_members.add(value); return true; } else { return false; } } else { throw new DynamicTypeException( this.m_className + " Element cannot be added. The maximum size specified for this map has been reached."); } } else { throw new DynamicTypeException( this.m_className + " Element cannot be added. The value type is not the same specified in the value content type."); } } else { throw new DynamicTypeException( this.m_className + " Element cannot be added. The key type is not the same specified in the key content type."); } }
@Override public void deserialize(SerializerImpl impl, BinaryInputStream message, String name) throws IOException { int size = impl.deserializeUI32(message, ""); for (int i = 0; i < size; ++i) { DynamicData key = Kiara.getDynamicValueBuilder().createData(this.m_keyContentType); DynamicData value = Kiara.getDynamicValueBuilder().createData(this.m_contentType); key.deserialize(impl, message, ""); value.deserialize(impl, message, ""); this.m_keyMembers.add(key); this.m_members.add(value); } }
@Override public DynamicData get(DynamicData key) { if (key.getTypeDescriptor().getKind() != this.m_keyContentType.getKind()) { throw new DynamicTypeException( this.m_className + " The key type specified (" + key.getTypeDescriptor().getKind() + ") is not the same as the one defined in the map descriptor."); } for (int i = 0; i < this.m_members.size(); ++i) { if (this.m_keyMembers.get(i).equals(key)) { return this.m_members.get(i); } } return null; }