Package org.apache.juneau.swap
Class AutoMapSwap<T>
java.lang.Object
org.apache.juneau.swap.ObjectSwap<T,Map<?,?>>
  
org.apache.juneau.swap.AutoMapSwap<T>
- Type Parameters:
- T- The normal class type.
A dynamic object swap based on reflection of a Java class that converts Objects to serializable Maps.
 
Looks for methods on the class that can be called to swap-in surrogate Map objects before serialization and swap-out surrogate Map objects after parsing.
Valid surrogate objects
- Any subclass of Map
Valid swap methods (S = Swapped type)
- public S toMap()
- public S toMap(BeanSession)
- public S toJsonMap()
- public S toJsonMap(BeanSession)
Valid unswap methods (N = Normal type, S = Swapped type)
- public static N fromMap(S)
- public static N fromMap(BeanSession, S)
- public static N fromJsonMap(S)
- public static N fromJsonMap(BeanSession, S)
- public static N create(S)
- public static N create(BeanSession, S)
- public static N valueOf(S)
- public static N valueOf(BeanSession, S)
- public N(S)
Classes are ignored if any of the following are true:
- Classes annotated with @BeanIgnore.
- Non-static member classes.
Members/constructors are ignored if any of the following are true:
- Members/constructors annotated with @BeanIgnore.
- Deprecated members/constructors.
See Also:
- 
Field SummaryFields inherited from class org.apache.juneau.swap.ObjectSwapNULL
- 
Method SummaryModifier and TypeMethodDescriptionstatic ObjectSwap<?,?> find(BeanContext bc, ClassInfo ci) Look for constructors and methods on this class and construct a dynamic swap if it's possible to do so.Map<?,?> swap(BeanSession session, Object o) If this transform is to be used to serialize non-serializable objects, it must implement this method.unswap(BeanSession session, Map<?, ?> o, ClassMeta<?> hint) If this transform is to be used to reconstitute objects that aren't true Java beans, it must implement this method.Methods inherited from class org.apache.juneau.swap.ObjectSwapforMediaTypes, forMediaTypes, getNormalClass, getSwapClass, getSwapClassMeta, isNormalObject, isSwappedObject, match, swap, toString, unswap, withTemplate, withTemplate
- 
Method Details- 
findLook for constructors and methods on this class and construct a dynamic swap if it's possible to do so.- Parameters:
- bc- The bean context to use for looking up annotations.
- ci- The class to try to constructor a dynamic swap on.
- Returns:
- An object swap instance, or null if one could not be created.
 
- 
swapDescription copied from class:ObjectSwapIf this transform is to be used to serialize non-serializable objects, it must implement this method.The object must be converted into one of the following serializable types: - 
      String
- 
      Number
- 
      Boolean
- 
      Collectioncontaining anything on this list.
- 
      Mapcontaining anything on this list.
- A java bean with properties of anything on this list.
- An array of anything on this list.
 - Overrides:
- swapin class- ObjectSwap<T,- Map<?, - ?>> 
- Parameters:
- session- The bean session to use to get the class meta. This is always going to be the same bean context that created this swap.
- o- The object to be transformed.
- Returns:
- The transformed object.
- Throws:
- SerializeException
 
- 
      
- 
unswapDescription copied from class:ObjectSwapIf this transform is to be used to reconstitute objects that aren't true Java beans, it must implement this method.- Overrides:
- unswapin class- ObjectSwap<T,- Map<?, - ?>> 
- Parameters:
- session- The bean session to use to get the class meta. This is always going to be the same bean context that created this swap.
- o- The transformed object.
- hint- If possible, the parser will try to tell you the object type being created. For example, on a serialized date, this may tell you that the object being created must be of type- GregorianCalendar.
 This may be- null if the parser cannot make this determination.
- Returns:
- The narrowed object.
- Throws:
- ParseException
 
 
-