public Map<PropertyPath, Object> toPropertyMap(O object) { return new WriteContext(schemaRoot, object).getMap(); }
public Map<PropertyPath, Object> getMap() { serialize(ROOT, root); QueueItem<PropertyPath, Object> currentItem; while ((currentItem = queue.pollFirst()) != null) { PropertyPath path = currentItem.key; Object value = currentItem.value; if (!properties.containsKey(path)) { if (value == null) { put(path, null); } else { Schema<ValueType> schema = getSchema(path); ValueType valueType = schema.getValue(); if (schema.hasChildren() // Composite (not scalar)? && !valueType.isReference()) { // Not a reference - multiple references to same object are allowed checkIllegalReference(path, value); } valueType.serialize(path, currentItem.value, this); } } } return unmodifiableMap(properties); }
@Override public void serialize(PropertyPath path, Object object, WriteContext context) { context.put(path, (Double) object); }
@Override public NodeId toNodeId(Object object, WriteContext writeContext) { NodeId nodeId = identifiableType.toNodeId(object, writeContext); writeContext.serialize(targetRoot.node(nodeId), object); return nodeId; }
@Override public void serialize(PropertyPath path, Object object, WriteContext context) { context.put(path, (Boolean) object); }
@Override public void serialize(PropertyPath path, Object object, WriteContext context) { context.put(path, (String) object); }
@Override public void serialize(PropertyPath path, Object object, WriteContext context) { Set<?> set = (Set<?>) object; context.put(path, CONSTANT); for (Object element : set) { PropertyPath elementPath = path; for (Key key : keys) { NodeId keyNode = key.toNodeId(element, context); elementPath = elementPath.node(keyNode); } context.serialize(elementPath, element); } }
@Override public void serialize(PropertyPath path, Object object, WriteContext context) { context.put(path, (Long) object); }
@Override public void serialize(PropertyPath path, Object object, WriteContext context) { Map<?, ?> map = (Map<?, ?>) object; context.put(path, CONSTANT); for (Map.Entry<?, ?> entry : map.entrySet()) { Object key = entry.getKey(); Object value = entry.getValue(); PropertyPath entryPath = path.node(keyType.toNodeId(key, context)); if (value == null) { // Skip nested serialization of null values context.put(entryPath, NULL); } else { context.serialize(entryPath, value); } } }
@Override public void serialize(PropertyPath path, Object object, WriteContext context) { context.put(path, object.toString()); }
@Override public void serialize(PropertyPath path, Object object, WriteContext context) { context.put(path, ((Integer) object).longValue()); }
@Override public void serialize(PropertyPath path, Object object, WriteContext context) { context.put(path, Persistent.object(alias)); BiConsumer<String, AccessibleProperty> propertySerializer = (name, property) -> { PropertyPath subPath = path.property(name); Object value = property.get(object); context.serialize(subPath, value); }; properties.forEach(propertySerializer); if (identifier != null && identifier.property.isWritable()) { propertySerializer.accept(identifier.name, identifier.property); } }
@Override public void serialize(PropertyPath path, Object object, WriteContext context) { context.put(path, fmt.print((DateTime) object)); }
@Override public void serialize(PropertyPath path, Object object, WriteContext context) { context.put(path, object.toString()); }
@Override public void serialize(PropertyPath path, Object object, WriteContext context) { context.put(path, object.toString()); }
@Override public void serialize(PropertyPath path, Object object, WriteContext context) { context.put(path, ((Float) object).doubleValue()); }
@Override public void serialize(PropertyPath path, Object object, WriteContext context) { context.put(path, object.toString()); }