public EnumMapSerializer(JavaType paramJavaType, boolean paramBoolean, EnumValues paramEnumValues, TypeSerializer paramTypeSerializer, BeanProperty paramBeanProperty, JsonSerializer<Object> paramJsonSerializer) { super(EnumMap.class, false); boolean bool1; if (!paramBoolean) { bool1 = false; if (paramJavaType != null) { boolean bool2 = paramJavaType.isFinal(); bool1 = false; if (!bool2); } } else { bool1 = true; } this._staticTyping = bool1; this._valueType = paramJavaType; this._keyEnums = paramEnumValues; this._valueTypeSerializer = paramTypeSerializer; this._property = paramBeanProperty; this._valueSerializer = paramJsonSerializer; }
protected void serializeContentsUsing(EnumMap<? extends Enum<?>,?> value, JsonGenerator jgen, SerializerProvider provider, JsonSerializer<Object> valueSer) throws IOException, JsonGenerationException { EnumValues keyEnums = _keyEnums; for (Map.Entry<? extends Enum<?>,?> entry : value.entrySet()) { Enum<?> key = entry.getKey(); if (keyEnums == null) { // clumsy, but has to do for now: SerializerBase<?> ser = (SerializerBase<?>) provider.findValueSerializer(key.getDeclaringClass()); keyEnums = ((EnumSerializer) ser).getEnumValues(); } jgen.writeFieldName(keyEnums.valueFor(key)); Object valueElem = entry.getValue(); if (valueElem == null) { provider.getNullValueSerializer().serialize(null, jgen, provider); } else { try { valueSer.serialize(valueElem, jgen, provider); } catch (Exception e) { wrapAndThrow(e, value, entry.getKey().name()); } } } }
protected JsonSerializer<?> buildEnumMapSerializer(JavaType type, SerializationConfig config, BasicBeanDescription beanDesc) { JavaType keyType = type.getKeyType(); JavaType valueType = type.getContentType(); // Need to find key enum values... EnumValues enums = null; if (keyType.isEnumType()) { // non-enum if we got it as type erased class (from instance) @SuppressWarnings("unchecked") Class<Enum<?>> enumClass = (Class<Enum<?>>) keyType.getRawClass(); enums = EnumValues.construct(enumClass, config.getAnnotationIntrospector()); } TypeSerializer typeSer = createTypeSerializer(valueType, config); return new EnumMapSerializer(valueType, usesStaticTyping(config, beanDesc), enums, typeSer); }
protected void serializeContentsUsing(EnumMap<? extends Enum<?>, ?> paramEnumMap, JsonGenerator paramJsonGenerator, SerializerProvider paramSerializerProvider, JsonSerializer<Object> paramJsonSerializer) { EnumValues localEnumValues1 = this._keyEnums; Iterator localIterator = paramEnumMap.entrySet().iterator(); EnumValues localEnumValues2 = localEnumValues1; while (localIterator.hasNext()) { Map.Entry localEntry = (Map.Entry)localIterator.next(); Enum localEnum = (Enum)localEntry.getKey(); if (localEnumValues2 == null) localEnumValues2 = ((EnumSerializer)paramSerializerProvider.findValueSerializer(localEnum.getDeclaringClass(), this._property)).getEnumValues(); paramJsonGenerator.writeFieldName(localEnumValues2.serializedValueFor(localEnum)); Object localObject = localEntry.getValue(); if (localObject == null) paramSerializerProvider.defaultSerializeNull(paramJsonGenerator); else try { paramJsonSerializer.serialize(localObject, paramJsonGenerator, paramSerializerProvider); } catch (Exception localException) { wrapAndThrow(paramSerializerProvider, localException, paramEnumMap, ((Enum)localEntry.getKey()).name()); } } }
public static EnumSerializer construct(Class<Enum<?>> paramClass, SerializationConfig paramSerializationConfig, BasicBeanDescription paramBasicBeanDescription) { AnnotationIntrospector localAnnotationIntrospector = paramSerializationConfig.getAnnotationIntrospector(); if (paramSerializationConfig.isEnabled(SerializationConfig.Feature.WRITE_ENUMS_USING_TO_STRING)); for (EnumValues localEnumValues = EnumValues.constructFromToString(paramClass, localAnnotationIntrospector); ; localEnumValues = EnumValues.constructFromName(paramClass, localAnnotationIntrospector)) return new EnumSerializer(localEnumValues); }
protected void serializeContentsUsing(EnumMap<? extends Enum<?>, ?> paramEnumMap, JsonGenerator paramJsonGenerator, SerializerProvider paramSerializerProvider, JsonSerializer<Object> paramJsonSerializer) throws IOException, JsonGenerationException { EnumValues localEnumValues = this._keyEnums; Iterator localIterator = paramEnumMap.entrySet().iterator(); while (localIterator.hasNext()) { Map.Entry localEntry = (Map.Entry)localIterator.next(); Enum localEnum = (Enum)localEntry.getKey(); if (localEnumValues == null) localEnumValues = ((EnumSerializer)(SerializerBase)paramSerializerProvider.findValueSerializer(localEnum.getDeclaringClass(), this._property)).getEnumValues(); paramJsonGenerator.writeFieldName(localEnumValues.serializedValueFor(localEnum)); Object localObject = localEntry.getValue(); if (localObject == null) { paramSerializerProvider.defaultSerializeNull(paramJsonGenerator); continue; } try { paramJsonSerializer.serialize(localObject, paramJsonGenerator, paramSerializerProvider); } catch (Exception localException) { wrapAndThrow(paramSerializerProvider, localException, paramEnumMap, ((Enum)localEntry.getKey()).name()); } } }
protected JsonSerializer<?> buildEnumMapSerializer(SerializationConfig paramSerializationConfig, JavaType paramJavaType, BasicBeanDescription paramBasicBeanDescription, BeanProperty paramBeanProperty, boolean paramBoolean, TypeSerializer paramTypeSerializer, JsonSerializer<Object> paramJsonSerializer) { JavaType localJavaType = paramJavaType.getKeyType(); boolean bool = localJavaType.isEnumType(); EnumValues localEnumValues = null; if (bool) localEnumValues = EnumValues.construct(localJavaType.getRawClass(), paramSerializationConfig.getAnnotationIntrospector()); return new EnumMapSerializer(paramJavaType.getContentType(), paramBoolean, localEnumValues, paramTypeSerializer, paramBeanProperty, paramJsonSerializer); }
public EnumMapSerializer(JavaType valueType, boolean staticTyping, EnumValues keyEnums, TypeSerializer vts) { super(EnumMap.class, false); _staticTyping = staticTyping || (valueType != null && valueType.isFinal()); _valueType = valueType; _keyEnums = keyEnums; _valueTypeSerializer = vts; }
public EnumSerializer(EnumValues paramEnumValues) { super(Enum.class, false); this._values = paramEnumValues; }
public EnumValues getEnumValues() { return this._values; }
@Deprecated public EnumMapSerializer(JavaType paramJavaType, boolean paramBoolean, EnumValues paramEnumValues, TypeSerializer paramTypeSerializer, BeanProperty paramBeanProperty) { this(paramJavaType, paramBoolean, paramEnumValues, paramTypeSerializer, paramBeanProperty, null); }
public EnumSerializer(EnumValues v) { super(Enum.class, false); _values = v; }
public static EnumSerializer construct(Class<Enum<?>> enumClass, AnnotationIntrospector intr) { return new EnumSerializer(EnumValues.construct(enumClass, intr)); }
protected void serializeContents(EnumMap<? extends Enum<?>,?> value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException { if (_valueSerializer != null) { serializeContentsUsing(value, jgen, provider, _valueSerializer); return; } JsonSerializer<Object> prevSerializer = null; Class<?> prevClass = null; EnumValues keyEnums = _keyEnums; for (Map.Entry<? extends Enum<?>,?> entry : value.entrySet()) { // First, serialize key Enum<?> key = entry.getKey(); if (keyEnums == null) { /* 15-Oct-2009, tatu: This is clumsy, but still the simplest efficient * way to do it currently, as Serializers get cached. (it does assume we'll always use * default serializer tho -- so ideally code should be rewritten) */ // ... and lovely two-step casting process too... SerializerBase<?> ser = (SerializerBase<?>) provider.findValueSerializer(key.getDeclaringClass()); keyEnums = ((EnumSerializer) ser).getEnumValues(); } jgen.writeFieldName(keyEnums.valueFor(key)); // And then value Object valueElem = entry.getValue(); if (valueElem == null) { provider.getNullValueSerializer().serialize(null, jgen, provider); } else { Class<?> cc = valueElem.getClass(); JsonSerializer<Object> currSerializer; if (cc == prevClass) { currSerializer = prevSerializer; } else { currSerializer = provider.findValueSerializer(cc); prevSerializer = currSerializer; prevClass = cc; } try { currSerializer.serialize(valueElem, jgen, provider); } catch (Exception e) { // [JACKSON-55] Need to add reference information wrapAndThrow(e, value, entry.getKey().name()); } } } }
protected void serializeContents(EnumMap<? extends Enum<?>, ?> paramEnumMap, JsonGenerator paramJsonGenerator, SerializerProvider paramSerializerProvider) { if (this._valueSerializer != null) serializeContentsUsing(paramEnumMap, paramJsonGenerator, paramSerializerProvider, this._valueSerializer); while (true) { return; EnumValues localEnumValues1 = this._keyEnums; Iterator localIterator = paramEnumMap.entrySet().iterator(); EnumValues localEnumValues2 = localEnumValues1; Object localObject1 = null; Object localObject2 = null; while (localIterator.hasNext()) { Map.Entry localEntry = (Map.Entry)localIterator.next(); Enum localEnum = (Enum)localEntry.getKey(); if (localEnumValues2 == null) localEnumValues2 = ((EnumSerializer)paramSerializerProvider.findValueSerializer(localEnum.getDeclaringClass(), this._property)).getEnumValues(); paramJsonGenerator.writeFieldName(localEnumValues2.serializedValueFor(localEnum)); Object localObject3 = localEntry.getValue(); if (localObject3 == null) { paramSerializerProvider.defaultSerializeNull(paramJsonGenerator); } else { Object localObject4 = localObject3.getClass(); Object localObject5; if (localObject4 == localObject1) { localObject4 = localObject1; localObject5 = localObject2; } try { while (true) { ((JsonSerializer)localObject2).serialize(localObject3, paramJsonGenerator, paramSerializerProvider); localObject2 = localObject5; localObject1 = localObject4; break; localObject2 = paramSerializerProvider.findValueSerializer((Class)localObject4, this._property); localObject5 = localObject2; } } catch (Exception localException) { wrapAndThrow(paramSerializerProvider, localException, paramEnumMap, ((Enum)localEntry.getKey()).name()); localObject2 = localObject5; localObject1 = localObject4; } } } } }
public EnumValues getEnumValues() { return _values; }