// @Override public JsonSerializer<?> createContextual(SerializerProvider provider, BeanProperty property) throws JsonMappingException { /* 29-Sep-2012, tatu: Actually, we need to do much more contextual * checking here since we finally know for sure the property, * and it may have overrides */ JsonSerializer<?> ser = null; JsonSerializer<?> keySer = null; // First: if we have a property, may have property-annotation overrides if (property != null) { AnnotatedMember m = property.getMember(); if (m != null) { Object serDef; final AnnotationIntrospector intr = provider.getAnnotationIntrospector(); serDef = intr.findKeySerializer(m); if (serDef != null) { keySer = provider.serializerInstance(m, serDef); } serDef = intr.findContentSerializer(m); if (serDef != null) { ser = provider.serializerInstance(m, serDef); } } } if (ser == null) { ser = _valueSerializer; } if (ser == null) { // 30-Sep-2012, tatu: One more thing -- if explicit content type is annotated, // we can consider it a static case as well. if (_valueTypeIsStatic || hasContentTypeAnnotation(provider, property)) { ser = provider.findValueSerializer(_valueType, property); } } else if (ser instanceof ContextualSerializer) { ser = ((ContextualSerializer) ser).createContextual(provider, property); } if (keySer == null) { keySer = _keySerializer; } if (keySer == null) { keySer = provider.findKeySerializer(_keyType, property); } else if (keySer instanceof ContextualSerializer) { keySer = ((ContextualSerializer) keySer).createContextual(provider, property); } HashSet<String> ignored = this._ignoredEntries; AnnotationIntrospector intr = provider.getAnnotationIntrospector(); if (intr != null && property != null) { String[] moreToIgnore = intr.findPropertiesToIgnore(property.getMember()); if (moreToIgnore != null) { ignored = (ignored == null) ? new HashSet<String>() : new HashSet<String>(ignored); for (String str : moreToIgnore) { ignored.add(str); } } } return withResolved(property, keySer, ser, ignored); }
private static HashSet<String> toSet(String[] ignoredEntries) { if (ignoredEntries == null || ignoredEntries.length == 0) { return null; } HashSet<String> result = new HashSet<String>(ignoredEntries.length); for (String prop : ignoredEntries) { result.add(prop); } return result; }