1 package com.fasterxml.jackson.databind.introspect; 2 3 import com.fasterxml.jackson.databind.BeanDescription; 4 import com.fasterxml.jackson.databind.DeserializationConfig; 5 import com.fasterxml.jackson.databind.JavaType; 6 import com.fasterxml.jackson.databind.SerializationConfig; 7 import com.fasterxml.jackson.databind.cfg.MapperConfig; 8 9 /** 10 * Helper class used to introspect features of POJO value classes 11 * used with Jackson. The main use is for finding out 12 * POJO construction (creator) and value access (getters, setters) 13 * methods and annotations that define configuration of using 14 * those methods. 15 */ 16 public abstract class ClassIntrospector 17 { 18 /* 19 /********************************************************** 20 /* Helper interfaces 21 /********************************************************** 22 */ 23 24 /** 25 * Interface used for decoupling details of how mix-in annotation 26 * definitions are accessed (via this interface), and how 27 * they are stored (defined by classes that implement the interface) 28 */ 29 public interface MixInResolver 30 { 31 /** 32 * Method that will check if there are "mix-in" classes (with mix-in 33 * annotations) for given class 34 */ findMixInClassFor(Class<?> cls)35 public Class<?> findMixInClassFor(Class<?> cls); 36 37 /** 38 * Method called to create a new, non-shared copy, to be used by different 39 * <code>ObjectMapper</code> instance, and one that should not be connected 40 * to this instance, if resolver has mutable state. 41 * If resolver is immutable may simply return `this`. 42 * 43 * @since 2.6 44 */ copy()45 public MixInResolver copy(); 46 } 47 ClassIntrospector()48 protected ClassIntrospector() { } 49 50 /** 51 * Method that may be needed when `copy()`ing `ObjectMapper` instances. 52 * 53 * @since 2.9.6 54 */ copy()55 public abstract ClassIntrospector copy(); 56 57 /* 58 /********************************************************** 59 /* Public API: factory methods 60 /********************************************************** 61 */ 62 63 /** 64 * Factory method that constructs an introspector that has all 65 * information needed for serialization purposes. 66 */ forSerialization(SerializationConfig cfg, JavaType type, MixInResolver r)67 public abstract BeanDescription forSerialization(SerializationConfig cfg, 68 JavaType type, MixInResolver r); 69 70 /** 71 * Factory method that constructs an introspector that has all 72 * information needed for deserialization purposes. 73 */ forDeserialization(DeserializationConfig cfg, JavaType type, MixInResolver r)74 public abstract BeanDescription forDeserialization(DeserializationConfig cfg, 75 JavaType type, MixInResolver r); 76 77 /** 78 * Factory method that constructs an introspector that has all 79 * information needed for constructing deserializers that use 80 * intermediate Builder objects. 81 */ forDeserializationWithBuilder(DeserializationConfig cfg, JavaType type, MixInResolver r)82 public abstract BeanDescription forDeserializationWithBuilder(DeserializationConfig cfg, 83 JavaType type, MixInResolver r); 84 85 /** 86 * Factory method that constructs an introspector that has 87 * information necessary for creating instances of given 88 * class ("creator"), as well as class annotations, but 89 * no information on member methods 90 */ forCreation(DeserializationConfig cfg, JavaType type, MixInResolver r)91 public abstract BeanDescription forCreation(DeserializationConfig cfg, JavaType type, 92 MixInResolver r); 93 94 /** 95 * Factory method that constructs an introspector that only has 96 * information regarding annotations class itself (or its supertypes) has, 97 * but nothing on methods or constructors. 98 */ forClassAnnotations(MapperConfig<?> cfg, JavaType type, MixInResolver r)99 public abstract BeanDescription forClassAnnotations(MapperConfig<?> cfg, JavaType type, 100 MixInResolver r); 101 102 /** 103 * Factory method that constructs an introspector that only has 104 * information regarding annotations class itself has (but NOT including 105 * its supertypes), but nothing on methods or constructors. 106 */ forDirectClassAnnotations(MapperConfig<?> cfg, JavaType type, MixInResolver r)107 public abstract BeanDescription forDirectClassAnnotations(MapperConfig<?> cfg, JavaType type, 108 MixInResolver r); 109 } 110