The MapFactory is used to create map instances that are compatible with the field type. This performs resolution of the map class by consulting the specified Strategy implementation. If the strategy cannot resolve the map class then this will select a type from the Java Collections framework, if a compatible one exists.
Inheritance: Factory
Beispiel #1
0
 /// <summary>
 /// Constructor for the <c>CompositeMap</c> object. This will
 /// create a converter that is capable of writing map objects to
 /// and from XML. The resulting XML is configured by an annotation
 /// such that key values can attributes and values can be inline.
 /// </summary>
 /// <param name="context">
 /// this is the root context for the serialization
 /// </param>
 /// <param name="entry">
 /// this provides configuration for the resulting XML
 /// </param>
 /// <param name="type">
 /// this is the map type that is to be converted
 /// </param>
 public CompositeMap(Context context, Entry entry, Type type) {
    this.factory = new MapFactory(context, type);
    this.value = entry.GetValue(context);
    this.key = entry.GetKey(context);
    this.style = context.getStyle();
    this.entry = entry;
 }
 /// <summary>
 /// This is used to provide a configured empty value used when the
 /// annotated value is null. This ensures that XML can be created
 /// with required details regardless of whether values are null or
 /// not. It also provides a means for sensible default values.
 /// </summary>
 /// <param name="context">
 /// this is the context object for the serialization
 /// </param>
 /// <returns>
 /// this returns the string to use for default values
 /// </returns>
 public Object GetEmpty(Context context) {
    Type map = new ClassType(type);
    Factory factory = new MapFactory(context, map);
    if(!label.empty()) {
       return factory.getInstance();
    }
    return null;
 }