@Override @SuppressWarnings("unchecked") public MetaValue clone() { CollectionValueSupport result = (CollectionValueSupport) super.clone(); int size = getSize(); if (size > 0) { result.elements = new MetaValue[size]; System.arraycopy(elements, 0, result.elements, 0, size); } return result; }
/** * Create a collection value * * @param type the type * @param value the value * @param mapping the mapping * @return the generic value */ public CollectionValue createCollectionValue(CollectionMetaType type, Object value, Map<Object, MetaValue> mapping) { if (value == null) return null; Collection<?> collection = (Collection<?>)value; MetaValue[] elements = new MetaValue[collection.size()]; int i = 0; for(Object ce : collection) { // recalculate element info, since usually more deterministic TypeInfo typeInfo = configuration.getTypeInfo(ce.getClass()); MetaType metaType = metaTypeFactory.resolve(typeInfo); elements[i++] = internalCreate(ce, typeInfo, metaType); } CollectionValue result = new CollectionValueSupport(type, elements); mapping.put(value, result); return result; }
/** * Create a collection value * * @param type the type * @param value the value * @param mapping the mapping * @return the generic value */ public CollectionValue createCollectionValue(CollectionMetaType type, Object value, Map<Object, MetaValue> mapping) { if (value == null) return null; Collection collection = (Collection)value; MetaValue[] elements = new MetaValue[collection.size()]; int i = 0; for(Object ce : collection) { // recalculate element info, since usually more deterministic TypeInfo typeInfo = configuration.getTypeInfo(ce.getClass()); MetaType metaType = metaTypeFactory.resolve(typeInfo); elements[i++] = internalCreate(ce, typeInfo, metaType); } CollectionValue result = new CollectionValueSupport(type, elements); mapping.put(value, result); return result; }
/** * Process a collection. * * @param collection the persisted xml meta data * @param value the collection value * @return a collection value */ protected CollectionValue createCollectionValue(PersistedCollectionValue collection, CollectionMetaType type) { List<MetaValue> elementList = new ArrayList<MetaValue>(); if(collection.getValues() != null && collection.getValues().isEmpty() == false) { for(PersistedValue element : collection.getValues()) { elementList.add( createMetaValue(element, type.getElementType())); } } return new CollectionValueSupport(type, elementList.toArray(new MetaValue[elementList.size()])); }
@Override @SuppressWarnings("unchecked") public MetaValue clone() { CollectionValueSupport result = (CollectionValueSupport) super.clone(); int size = getSize(); if (size > 0) { result.elements = new MetaValue[size]; System.arraycopy(elements, 0, result.elements, 0, size); } return result; }
private MetaValue createViewMetaValue(View view) { Map<String, MetaValue> viewMap = new HashMap<String, MetaValue>(); viewMap.put("id", SimpleValueSupport.wrap(view.getVid().getId())); viewMap.put("creator", SimpleValueSupport.wrap(view.getCreator().toString())); Vector<Address> members = view.getMembers(); MetaValue[] memberValues = new MetaValue[members.size()]; for (int i = 0; i < memberValues.length; i++) { memberValues[i] = SimpleValueSupport.wrap(members.get(i).toString()); } viewMap.put("members", new CollectionValueSupport(MEMBERS_TYPE, memberValues)); if (memberValues.length > 0) { viewMap.put("coordinator", memberValues[0]); } MetaValue viewValue = new MapCompositeValueSupport(viewMap, VIEW_TYPE); return viewValue; }
new CollectionValueSupport(PROTOCOL_OBJECT_NAMES_TYPE, onValues.toArray(new MetaValue[onValues.size()]))); return new CollectionValueSupport(TYPE, elements.toArray(new MetaValue[elements.size()]));
return new CollectionValueSupport(TYPE, dataElements);