Class M2Mapper

java.lang.Object
org.modelmapper.ModelMapper
overit.geocall.model.M2Mapper

@Service public class M2Mapper extends ModelMapper
M2Mapper extends ModelMapper that have an intelligent object mapping. M2Mapper is a class you instantiate to perform object mapping, load mapping definitions and register mappers.
  • Constructor Details

    • M2Mapper

      public M2Mapper()
      Main constructor for M2Mapper
    • M2Mapper

      public M2Mapper(Configuration.AccessLevel accessLevel)
      Constructor for M2Mapper with specified access level configuration. Creates a new M2Mapper instance with the given access level for field mapping, using default providers for factory, date time ranges, and validation.
      Parameters:
      accessLevel - The access level to use for field mapping (PUBLIC, PRIVATE, PROTECTED, PACKAGE_PRIVATE)
  • Method Details

    • map

      public <D> D map(Object source, Type destinationType)
      Overrides:
      map in class ModelMapper
    • map

      public <D> D map(Object source, Class<D> destinationType)
      Overrides:
      map in class ModelMapper
    • map

      public <D> D map(Object source, Type destinationType, String typeMapName)
      Overrides:
      map in class ModelMapper
    • map

      public <D> D map(Object source, Class<D> destinationType, String typeMapName)
      Overrides:
      map in class ModelMapper
    • map

      public void map(Object source, Object destination)
      Overrides:
      map in class ModelMapper
    • map

      public void map(Object source, Object destination, String typeMapName)
      Overrides:
      map in class ModelMapper
    • validateObject

      protected void validateObject(Object obj)
    • withFieldsCondition

      public M2Mapper withFieldsCondition(Collection<String> fields)
      Gets a Mapper with the filter conditions defined by the Collection fields.
      Parameters:
      fields - The Collection of fields form which define the filter conditions for the mapper
      Returns:
      Mapper with the filter conditions defined by the Collection fields.
    • withFieldsCondition

      public M2Mapper withFieldsCondition(Collection<String> fields, Configuration.AccessLevel accessLevel)
      Creates a new M2Mapper instance with field filtering conditions and specified access level. This method returns a copy of the current mapper configured to only map fields that are included in the provided collection. If the fields collection is null or empty, returns the current mapper instance unchanged.

      The returned mapper will: - Only map properties whose names or JSON aliases are contained in the fields collection - Use the specified access level for field mapping - Include properties annotated with @JsonInclude regardless of the fields filter

      Parameters:
      fields - The collection of field names to include in the mapping. Field names can be property names or JSON property aliases (@JsonProperty, @JsonAlias)
      accessLevel - The access level to use for field mapping (PUBLIC, PRIVATE, PROTECTED, PACKAGE_PRIVATE)
      Returns:
      A new M2Mapper instance with field filtering applied, or the current instance if fields is null or empty