DATACOUCH-110 - SimpleTypeHolders in CouchbaseList
Include the customSimpleTypes from Converters in SimpleTypeHolders
This commit is contained in:
committed by
Michael Nitschinger
parent
ff15112959
commit
5ed6ec3490
@@ -87,7 +87,7 @@ public class CustomConversions {
|
||||
registerConversion(converter);
|
||||
}
|
||||
|
||||
simpleTypeHolder = new SimpleTypeHolder();
|
||||
simpleTypeHolder = new SimpleTypeHolder(customSimpleTypes, true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -498,7 +498,7 @@ public class MappingCouchbaseConverter extends AbstractCouchbaseConverter
|
||||
if (val == null || conversions.isSimpleType(val.getClass())) {
|
||||
writeSimpleInternal(val, target, simpleKey);
|
||||
} else if (val instanceof Collection || val.getClass().isArray()) {
|
||||
target.put(simpleKey, writeCollectionInternal(asCollection(val), new CouchbaseList(), type.getMapValueType()));
|
||||
target.put(simpleKey, writeCollectionInternal(asCollection(val), new CouchbaseList(conversions.getSimpleTypeHolder()), type.getMapValueType()));
|
||||
} else {
|
||||
CouchbaseDocument embeddedDoc = new CouchbaseDocument();
|
||||
TypeInformation<?> valueTypeInfo = type.isMap() ? type.getMapValueType() : ClassTypeInformation.OBJECT;
|
||||
@@ -521,7 +521,7 @@ public class MappingCouchbaseConverter extends AbstractCouchbaseConverter
|
||||
* @return the created couchbase list.
|
||||
*/
|
||||
private CouchbaseList createCollection(final Collection<?> collection, final CouchbasePersistentProperty prop) {
|
||||
return writeCollectionInternal(collection, new CouchbaseList(), prop.getTypeInformation());
|
||||
return writeCollectionInternal(collection, new CouchbaseList(conversions.getSimpleTypeHolder()), prop.getTypeInformation());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -542,7 +542,7 @@ public class MappingCouchbaseConverter extends AbstractCouchbaseConverter
|
||||
if (elementType == null || conversions.isSimpleType(elementType)) {
|
||||
target.put(element);
|
||||
} else if (element instanceof Collection || elementType.isArray()) {
|
||||
target.put(writeCollectionInternal(asCollection(element), new CouchbaseList(), componentType));
|
||||
target.put(writeCollectionInternal(asCollection(element), new CouchbaseList(conversions.getSimpleTypeHolder()), componentType));
|
||||
} else {
|
||||
CouchbaseDocument embeddedDoc = new CouchbaseDocument();
|
||||
writeInternal(element, embeddedDoc, componentType);
|
||||
|
||||
@@ -54,12 +54,34 @@ public class CouchbaseList implements CouchbaseStorable {
|
||||
* @param initialPayload the initial data to store.
|
||||
*/
|
||||
public CouchbaseList(final List<Object> initialPayload) {
|
||||
payload = initialPayload;
|
||||
this(initialPayload, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new (empty) list with an existing {@link SimpleTypeHolder}.
|
||||
*
|
||||
* @param simpleTypeHolder context instance.
|
||||
*/
|
||||
public CouchbaseList(final SimpleTypeHolder simpleTypeHolder) {
|
||||
this(new ArrayList<Object>(), simpleTypeHolder);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new list with a given payload on construction and an existing {@link SimpleTypeHolder}.
|
||||
*
|
||||
* @param initialPayload the initial data to store.
|
||||
* @param simpleTypeHolder context instance.
|
||||
*/
|
||||
public CouchbaseList(final List<Object> initialPayload, final SimpleTypeHolder simpleTypeHolder) {
|
||||
this.payload = initialPayload;
|
||||
Set<Class<?>> additionalTypes = new HashSet<Class<?>>();
|
||||
additionalTypes.add(CouchbaseDocument.class);
|
||||
additionalTypes.add(CouchbaseList.class);
|
||||
simpleTypeHolder = new SimpleTypeHolder(additionalTypes, true);
|
||||
if (simpleTypeHolder != null) {
|
||||
this.simpleTypeHolder = new SimpleTypeHolder(additionalTypes, simpleTypeHolder);
|
||||
} else {
|
||||
this.simpleTypeHolder = new SimpleTypeHolder(additionalTypes, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user