コード例 #1
0
 protected boolean _useStatic(
     SerializerProvider provider, BeanProperty property, JavaType referredType) {
   // First: no serializer for `Object.class`, must be dynamic
   if (referredType.isJavaLangObject()) {
     return false;
   }
   // but if type is final, might as well fetch
   if (referredType.isFinal()) { // or should we allow annotation override? (only if requested...)
     return true;
   }
   // also: if indicated by typing, should be considered static
   if (referredType.useStaticType()) {
     return true;
   }
   // if neither, maybe explicit annotation?
   AnnotationIntrospector intr = provider.getAnnotationIntrospector();
   if ((intr != null) && (property != null)) {
     Annotated ann = property.getMember();
     if (ann != null) {
       JsonSerialize.Typing t = intr.findSerializationTyping(property.getMember());
       if (t == JsonSerialize.Typing.STATIC) {
         return true;
       }
       if (t == JsonSerialize.Typing.DYNAMIC) {
         return false;
       }
     }
   }
   // and finally, may be forced by global static typing (unlikely...)
   return provider.isEnabled(MapperFeature.USE_STATIC_TYPING);
 }