Skip to content
Browse files

Fix the unit test problem, to finalize 2.0.0-RC1

  • Loading branch information...
1 parent cf5eb12 commit 758d306a15e01e9332528d525d1fff5b081d80e8 @cowtowncoder cowtowncoder committed Feb 19, 2012
View
18 pom.xml
@@ -148,12 +148,18 @@ High-Performance Primitive Collections (HPPC, see http://labs.carrotsearch.com/h
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Vendor>fasterml.com</Bundle-Vendor>
<Import-Package>
-com.fasterml.jackson.core,
-,com.fasterml.jackson.databind
-,com.fasterml.jackson.databind.node
-,com.fasterml.jackson.databind.ser
-,com.fasterml.jackson.databind.type
-,com.fasterml.jackson.databind.util
+com.fasterxml.jackson.core
+,com.fasterxml.jackson.core.util
+,com.fasterxml.jackson.databind
+,com.fasterxml.jackson.databind.deser
+,com.fasterxml.jackson.databind.deser.std
+,com.fasterxml.jackson.databind.jsontype
+,com.fasterxml.jackson.databind.module
+,com.fasterxml.jackson.databind.node
+,com.fasterxml.jackson.databind.ser
+,com.fasterxml.jackson.databind.ser.std
+,com.fasterxml.jackson.databind.type
+,com.fasterxml.jackson.databind.util
,com.carrotsearch.hppc, com.carrotsearch.hppc.predicates
</Import-Package>
<Private-Package>
View
42 src/main/java/com/fasterxml/jackson/datatype/hppc/deser/HppcDeserializers.java
@@ -0,0 +1,42 @@
+package com.fasterxml.jackson.datatype.hppc.deser;
+
+import com.fasterxml.jackson.databind.BeanDescription;
+import com.fasterxml.jackson.databind.DeserializationConfig;
+import com.fasterxml.jackson.databind.JavaType;
+import com.fasterxml.jackson.databind.JsonDeserializer;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.deser.Deserializers;
+
+public class HppcDeserializers extends Deserializers.Base
+ {
+ @Override
+ public JsonDeserializer<?> findBeanDeserializer(JavaType type,
+ DeserializationConfig config, BeanDescription beanDesc)
+ throws JsonMappingException
+ {
+ return HppcContainerDeserializers.findDeserializer(config, type);
+ }
+
+ /*
+ @Override
+ public JsonDeserializer<?> findCollectionLikeDeserializer(
+ CollectionLikeType type, DeserializationConfig config,
+ BeanDescription arg3,
+ BeanProperty arg4, TypeDeserializer arg5,
+ JsonDeserializer<?> arg6) throws JsonMappingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public JsonDeserializer<?> findMapLikeDeserializer(MapLikeType type,
+ DeserializationConfig config,
+ BeanDescription arg3, BeanProperty arg4, KeyDeserializer arg5,
+ TypeDeserializer arg6, JsonDeserializer<?> arg7)
+ throws JsonMappingException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+*/
+
+ }
View
5 src/main/java/com/fasterxml/jackson/datatype/hppc/ser/ContainerSerializerBase.java
@@ -30,6 +30,11 @@ protected ContainerSerializerBase(JavaType type, String schemaElementType)
_schemeElementType = schemaElementType;
}
+ protected ContainerSerializerBase(ContainerSerializerBase<?> src) {
+ super(src._handledType, true);
+ _schemeElementType = src._schemeElementType;
+ }
+
public JsonSerializer<?> getSerializer(JavaType type)
{
if (_handledType.isAssignableFrom(type.getRawClass())) {
View
55 src/main/java/com/fasterxml/jackson/datatype/hppc/ser/HppcSerializers.java
@@ -0,0 +1,55 @@
+package com.fasterxml.jackson.datatype.hppc.ser;
+
+import com.carrotsearch.hppc.ObjectContainer;
+import com.fasterxml.jackson.databind.BeanDescription;
+import com.fasterxml.jackson.databind.JavaType;
+import com.fasterxml.jackson.databind.JsonSerializer;
+import com.fasterxml.jackson.databind.MapperFeature;
+import com.fasterxml.jackson.databind.SerializationConfig;
+import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
+import com.fasterxml.jackson.databind.ser.Serializers;
+import com.fasterxml.jackson.databind.ser.std.ObjectArraySerializer;
+import com.fasterxml.jackson.databind.type.CollectionLikeType;
+import com.fasterxml.jackson.databind.type.MapLikeType;
+
+public class HppcSerializers extends Serializers.Base
+{
+ public HppcSerializers() { }
+
+ @Override
+ public JsonSerializer<?> findCollectionLikeSerializer(SerializationConfig config,
+ CollectionLikeType containerType,
+ BeanDescription beanDesc, TypeSerializer elementTypeSerializer,
+ JsonSerializer<Object> elementValueSerializer)
+ {
+ if (ObjectContainer.class.isAssignableFrom(containerType.getRawClass())) {
+ // hmmh. not sure if we can find 'forceStaticTyping' anywhere...
+ boolean staticTyping = config.isEnabled(MapperFeature.USE_STATIC_TYPING);
+ ObjectArraySerializer ser = new ObjectArraySerializer(containerType.getContentType(),
+ staticTyping, elementTypeSerializer, elementValueSerializer);
+ return new ObjectContainerSerializer(containerType, ser);
+ }
+ return null;
+ }
+
+ @Override
+ public JsonSerializer<?> findMapLikeSerializer(SerializationConfig config,
+ MapLikeType arg1, BeanDescription arg2,
+ JsonSerializer<Object> arg4, TypeSerializer arg5,
+ JsonSerializer<Object> arg6) {
+ // TODO: handle XxxMap with Object keys and/or values
+ return null;
+ }
+
+ /**
+ * Anything that we don't explicitly mark as Map- or Collection-like
+ * will end up here...
+ */
+ @Override
+ public JsonSerializer<?> findSerializer(SerializationConfig config,
+ JavaType type, BeanDescription beanDesc)
+ {
+ return HppcContainerSerializers.getMatchingSerializer(type);
+ }
+
+}
View
34 src/main/java/com/fasterxml/jackson/datatype/hppc/ser/ObjectContainerSerializer.java
@@ -26,6 +26,12 @@
*/
protected final ObjectArraySerializer _delegate;
+ /*
+ /**********************************************************************
+ /* Life-cycle
+ /**********************************************************************
+ */
+
public ObjectContainerSerializer(CollectionLikeType containerType,
ObjectArraySerializer delegate)
{
@@ -34,6 +40,23 @@ public ObjectContainerSerializer(CollectionLikeType containerType,
_delegate = delegate;
}
+ protected ObjectContainerSerializer(ObjectContainerSerializer base,
+ ObjectArraySerializer delegate)
+ {
+ super(base);
+ _delegate = delegate;
+ }
+
+ protected JsonSerializer<?> withDelegate(ObjectArraySerializer newDelegate) {
+ return (newDelegate == _delegate) ? this : new ObjectContainerSerializer(this, newDelegate);
+ }
+
+ /*
+ /**********************************************************************
+ /* Serialization
+ /**********************************************************************
+ */
+
@Override
public void serialize(ObjectContainer<?> value, JsonGenerator jgen, SerializerProvider provider)
throws IOException, JsonGenerationException
@@ -53,19 +76,10 @@ protected void serializeContents(ObjectContainer<?> value, JsonGenerator jgen, S
throws IOException, JsonGenerationException {
throw new IllegalStateException();
}
-
- /**
- * Need to get callback to resolve value serializer, if static typing
- * is used (either being forced, or because value type is final)
- */
- public void resolve(SerializerProvider prov)
- throws JsonMappingException
- {
- }
@Override
public JsonSerializer<?> createContextual(SerializerProvider prov,
BeanProperty property) throws JsonMappingException {
- return _delegate.createContextual(prov, property);
+ return withDelegate((ObjectArraySerializer) _delegate.createContextual(prov, property));
}
}
View
1 src/test/java/com/fasterxml/jackson/datatype/hppc/ser/TestContainerSerializers.java
@@ -136,7 +136,6 @@ public void testObjectContainerSerializer() throws Exception
list.add("foo");
list.add(Integer.valueOf(3));
list.add((Object) null);
-
assertEquals("[\"foo\",3,null]", mapper.writeValueAsString(list));
// TODO: polymorphic case (@JsonTypeInfo and/or default typing)

0 comments on commit 758d306

Please sign in to comment.
Something went wrong with that request. Please try again.