I have the following class:

class SimpleFilterItem(@JsonProperty("type") type: String,
                       @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = 
"type", include = JsonTypeInfo.As.EXTERNAL_PROPERTY)
                       @JsonSubTypes(value = [
                           JsonSubTypes.Type(value = StringOperator::class, 
name = "STRING"),
                           JsonSubTypes.Type(value = NumericOperator::class, 
name = "LONG"),
                           JsonSubTypes.Type(value = NumericOperator::class, 
name = "DECIMAL"),
                           JsonSubTypes.Type(value = NumericOperator::class, 
name = "INTEGER"),
                           JsonSubTypes.Type(value = NumericOperator::class, 
name = "DOUBLE"),
                           JsonSubTypes.Type(value = DateOperator::class, name 
= "DATE"),
                           JsonSubTypes.Type(value = BooleanOperator::class, 
name = "BOOLEAN")
                       ])
                       val operator: Operator)



However JsonSubTypes doesn't seem to support case-insensitive values so the 
value `string` fails. I also have the following enum:

enum class FieldType(val operatorClass : Class<*>) {
        STRING(StringOperator::class), INTEGER(NumericOperator::class), 
DECIMAL(NumericOperator::class), DOUBLE(NumericOperator::class), 
LONG(NumericOperator::class)

}


What I want to do to is to map the FieldType with the values instead of 
writing the STRING, LONG etc. by hand. I can also implement @JsonCreator to 
FieldType and solve the case insensitivity problem there. The main benefit 
of this approach is that I won't be duplicating the code.

-- 
You received this message because you are subscribed to the Google Groups 
"jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to