Class CoreConfiguration

java.lang.Object
io.beanmapper.config.CoreConfiguration
All Implemented Interfaces:
Configuration

public class CoreConfiguration extends Object implements Configuration
  • Constructor Details

    • CoreConfiguration

      public CoreConfiguration()
  • Method Details

    • getDownsizeTarget

      public List<String> getDownsizeTarget()
      Description copied from interface: Configuration
      When include fields are passed, BeanMapper will assume that the generation (or reuse) of a dynamic class is required. For this, DynamicBeanMapper is used. Note that include fields is a marker field which impact the selection of the mapping strategy. Include fields never refer to the parent configuration.
      Specified by:
      getDownsizeTarget in interface Configuration
      Returns:
      the fields to include in the target
    • getDownsizeSource

      public List<String> getDownsizeSource()
      Description copied from interface: Configuration
      When include fields are passed, BeanMapper will assume that the generation (or reuse) of a dynamic class is required. For this, DynamicBeanMapper is used. Note that include fields is a marker field which impact the selection of the mapping strategy. Include fields never refer to the parent configuration.
      Specified by:
      getDownsizeSource in interface Configuration
      Returns:
      the fields to include in the source
    • getTargetClass

      public Class getTargetClass()
      Description copied from interface: Configuration
      The class that represents the target class. Used to instantiate a target for the mapping. Note that target class is a marker field which impact the selection of the mapping strategy. Target class never refers to the parent configuration.
      Specified by:
      getTargetClass in interface Configuration
      Returns:
      class of the target
    • getTarget

      public Object getTarget()
      Description copied from interface: Configuration
      The target to map to. Note that collection class is a marker field which impact the selection of the mapping strategy. Target never refers to the parent configuration.
      Specified by:
      getTarget in interface Configuration
      Returns:
      class of the collection
    • getParent

      public Object getParent()
      Description copied from interface: Configuration
      The active parent for the field that is currently being mapped. This is always a parent on the target side of BeanMapper. @BeanParent makes us of this variable to assign to a field
      Specified by:
      getParent in interface Configuration
      Returns:
      the parent of the active field
    • getCollectionClass

      public Class getCollectionClass()
      Description copied from interface: Configuration
      The class that represents the collection itself. Used to instantiate a collection. Note that collection class is a marker field which impact the selection of the mapping strategy. Collection class never refers to the parent configuration.
      Specified by:
      getCollectionClass in interface Configuration
      Returns:
      class of the collection
    • getCollectionHandlerForCollectionClass

      public CollectionHandler getCollectionHandlerForCollectionClass()
      Description copied from interface: Configuration
      Finds the collection handler for the collection class, null if not exists
      Specified by:
      getCollectionHandlerForCollectionClass in interface Configuration
      Returns:
      the collection handler for the collection class, null if not exists
    • getCollectionHandlerFor

      public CollectionHandler getCollectionHandlerFor(Class<?> clazz)
      Description copied from interface: Configuration
      Finds the correction handler for the class. Null, if not found.
      Specified by:
      getCollectionHandlerFor in interface Configuration
      Parameters:
      clazz - class to find the correct collection handler for
      Returns:
      collection handler for the class, or null if not found
    • getBeanInitializer

      public BeanInitializer getBeanInitializer()
      Specified by:
      getBeanInitializer in interface Configuration
    • getBeanUnproxy

      public BeanUnproxy getBeanUnproxy()
      Specified by:
      getBeanUnproxy in interface Configuration
    • getBeanMatchStore

      public BeanMatchStore getBeanMatchStore()
      Description copied from interface: Configuration
      Always use the CoreConfiguration beanmatch store
      Specified by:
      getBeanMatchStore in interface Configuration
      Returns:
      the one beanmatch store
    • getClassStore

      public ClassStore getClassStore()
      Description copied from interface: Configuration
      Always use the CoreConfiguration class store
      Specified by:
      getClassStore in interface Configuration
      Returns:
      the one class store
    • getPackagePrefixes

      public List<String> getPackagePrefixes()
      Specified by:
      getPackagePrefixes in interface Configuration
    • getBeanConverters

      public List<BeanConverter> getBeanConverters()
      Specified by:
      getBeanConverters in interface Configuration
    • getLogicSecuredChecks

      public Map<Class<? extends LogicSecuredCheck>,​LogicSecuredCheck> getLogicSecuredChecks()
      Specified by:
      getLogicSecuredChecks in interface Configuration
    • getCollectionHandlers

      public List<CollectionHandler> getCollectionHandlers()
      Description copied from interface: Configuration
      Returns the list of registered collection handlers. The handlers are used to deal with the complexities of mapping between collections. Methods for copying, clearing and construction are supplied.
      Specified by:
      getCollectionHandlers in interface Configuration
      Returns:
      the list of registered collection handlers
    • getBeanPairs

      public List<BeanPair> getBeanPairs()
      Description copied from interface: Configuration
      Returns the entire list of strict bean pairs. The properties on the strict side must have matching properties on the other, non-strict side.
      Specified by:
      getBeanPairs in interface Configuration
      Returns:
      the entire list of strict bean pairs.
    • isConverterChoosable

      public Boolean isConverterChoosable()
      Specified by:
      isConverterChoosable in interface Configuration
    • withoutDefaultConverters

      public void withoutDefaultConverters()
      Specified by:
      withoutDefaultConverters in interface Configuration
    • getStrictSourceSuffix

      public String getStrictSourceSuffix()
      Description copied from interface: Configuration
      Returns the classname suffix that determines a source class is to be treated as strict with regards to mapping. Default is "Form"
      Specified by:
      getStrictSourceSuffix in interface Configuration
      Returns:
      the source classname suffix for a class to be treated as strict
    • getStrictTargetSuffix

      public String getStrictTargetSuffix()
      Description copied from interface: Configuration
      Returns the classname suffix that determines a target class is to be treated as strict with regards to mapping. Default is "Result"
      Specified by:
      getStrictTargetSuffix in interface Configuration
      Returns:
      the target classname suffix for a class to be treated as strict
    • isApplyStrictMappingConvention

      public Boolean isApplyStrictMappingConvention()
      Description copied from interface: Configuration
      Determines if strict mapping convention will be applied. This means that if a source class has the strict source suffix, or a target class has the strict target suffix, the classes will be treated as if they are strict. This implies that all of their properties will require matching properties on the other side. Default is true.
      Specified by:
      isApplyStrictMappingConvention in interface Configuration
      Returns:
      if true, the strict mapping convention will be applied
    • getStrictMappingProperties

      public StrictMappingProperties getStrictMappingProperties()
      Description copied from interface: Configuration
      Returns the collection of strictSourceSuffix, strictTargetSuffix and applyStrictMappingConvention properties.
      Specified by:
      getStrictMappingProperties in interface Configuration
      Returns:
      all properties required for dealing with the strict mapping convention
    • getCollectionUsage

      public BeanCollectionUsage getCollectionUsage()
      Description copied from interface: Configuration
      Returns the type of collection usage for the current collection mapping
      Specified by:
      getCollectionUsage in interface Configuration
      Returns:
      collection usage to apply
    • getPreferredCollectionClass

      public Class<?> getPreferredCollectionClass()
      Description copied from interface: Configuration
      Gets the preferred collection class to be instantiated. If it has this choice, it will use this class over the one provided by the collection handler.
      Specified by:
      getPreferredCollectionClass in interface Configuration
      Returns:
      the collection class to prefer for instantiation
    • getCollectionFlusher

      public CollectionFlusher getCollectionFlusher()
      Description copied from interface: Configuration
      Returns the collection clearer, which takes care of calling the clear method on a collection. If required, it will also call the list of flushers registered to it.
      Specified by:
      getCollectionFlusher in interface Configuration
      Returns:
      the collection clearer
    • isFlushAfterClear

      public Boolean isFlushAfterClear()
      Description copied from interface: Configuration
      Determines if the flush-chain must be called after a clear() operation on a collection has taken place.
      Specified by:
      isFlushAfterClear in interface Configuration
      Returns:
      true if the flush-chain must be called after a clear
    • isFlushEnabled

      public Boolean isFlushEnabled()
      Description copied from interface: Configuration
      Determines if flushing has been enabled. Flushing is the calling of flush() on a collection after it has been cleared. This force an ORM to run its delete queries. Default setting is false, because flushing is tied closely to having a transaction context. If, this is not the case, the flush will throw an exception.
      Specified by:
      isFlushEnabled in interface Configuration
      Returns:
      whether flushing has been enabled
    • mustFlush

      public Boolean mustFlush()
      Description copied from interface: Configuration
      Works on the combination of the global flush setting (flushEnabled) and the specific flush setting (flushAfterClear). If both are true, the flush will trigger.
      Specified by:
      mustFlush in interface Configuration
      Returns:
      true if a flush after clear must take place
    • getUseNullValue

      public Boolean getUseNullValue()
      Description copied from interface: Configuration
      Property that determines if null values for the source must be skipped or not
      Specified by:
      getUseNullValue in interface Configuration
      Returns:
      determines if null values must be skipped or not
    • getRoleSecuredCheck

      public RoleSecuredCheck getRoleSecuredCheck()
      Description copied from interface: Configuration
      The RoleSecuredCheck is responsible for checking if a Principal may access a field or method annotated with @BeanRoleSecured. Returns the RoleSecuredCheck, if it has been configured.
      Specified by:
      getRoleSecuredCheck in interface Configuration
      Returns:
      the active RoleSecuredCheck, if set. Otherwise, null
    • getEnforceSecuredProperties

      public Boolean getEnforceSecuredProperties()
      Description copied from interface: Configuration
      Property that determines if secured properties must be handled. If this is set to true and the RoleSecuredCheck has not been set, an exception will be thrown.
      Specified by:
      getEnforceSecuredProperties in interface Configuration
      Returns:
      whether the handling of secured properties is enforced
    • addConverter

      public void addConverter(BeanConverter converter)
      Description copied from interface: Configuration
      Add a converter class (must inherit from abstract BeanConverter class) to the beanMapper. On mapping, the beanMapper will check for a suitable converter and use its from and to methods to convert the value of the fields to the correct new data type.
      Specified by:
      addConverter in interface Configuration
      Parameters:
      converter - an instance of the class that contains the conversion method implementations and inherits from the abstract BeanConverter class.
    • addLogicSecuredCheck

      public void addLogicSecuredCheck(LogicSecuredCheck logicSecuredCheck)
      Description copied from interface: Configuration
      Add a check instance that takes the source and target instances and on the basis of those two determines whether access must be provided
      Specified by:
      addLogicSecuredCheck in interface Configuration
      Parameters:
      logicSecuredCheck - the check instance to register
    • addCollectionHandler

      public void addCollectionHandler(CollectionHandler collectionHandler)
      Description copied from interface: Configuration
      Registers a collection handler to the configuration. The Collection handlers supply the underlying mechanism for dealing with mapping from and to collections. They supply methods for copying, clearing and construction.
      Specified by:
      addCollectionHandler in interface Configuration
      Parameters:
      collectionHandler - the collection handler to register
    • addBeanPairWithStrictSource

      public void addBeanPairWithStrictSource(Class source, Class target)
      Description copied from interface: Configuration
      Adds a new pair of classes of which the source is strict. The strict side must match for all public fields and getter properties.
      Specified by:
      addBeanPairWithStrictSource in interface Configuration
      Parameters:
      source - the source class that must match, also the strict side of the pair
      target - the target class that must match
    • addBeanPairWithStrictTarget

      public void addBeanPairWithStrictTarget(Class source, Class target)
      Description copied from interface: Configuration
      Adds a new pair of classes of which the target is strict. The strict side must match for all public fields and setter properties.
      Specified by:
      addBeanPairWithStrictTarget in interface Configuration
      Parameters:
      source - the source class that must match
      target - the target class that must match, also the strict side of the pair
    • addProxySkipClass

      public void addProxySkipClass(Class<?> clazz)
      Description copied from interface: Configuration
      Add classes to skip while unproxying to prevent failing of the BeanMapper while mapping proxy classes or classes containing synthetic fields (Like ENUM types).
      Specified by:
      addProxySkipClass in interface Configuration
      Parameters:
      clazz - the class that is added to the list of skipped classes
    • addPackagePrefix

      public void addPackagePrefix(Class<?> clazz)
      Description copied from interface: Configuration
      Adds a package on the basis of a class. All classes in that package and sub-packages are eligible for mapping. The root source and target do not need to be set as such, because the verification is only run against nested classes which should be mapped implicity as well
      Specified by:
      addPackagePrefix in interface Configuration
      Parameters:
      clazz - the class which sets the package prefix for all mappable classes
    • addPackagePrefix

      public void addPackagePrefix(String packagePrefix)
      Description copied from interface: Configuration
      Adds a package on the basis of a class. All classes in that package and sub-packages are eligible for mapping. The root source and target do not need to be set as such, because the verification is only run against nested classes which should be mapped implicity as well
      Specified by:
      addPackagePrefix in interface Configuration
      Parameters:
      packagePrefix - the String which sets the package prefix for all mappable classes
    • addAfterClearFlusher

      public void addAfterClearFlusher(AfterClearFlusher afterClearFlusher)
      Description copied from interface: Configuration
      After BeanMapper calls the clear() method on a collection, it will check for the presence of AfterClearFlusher instances. All instances found will be executed. The use case triggering this functionality is the fact that Hibernate's @OneToMany first executes insert SQL-statements, before the delete SQL statements. With constraints, this is an issue. By forcing the flush after a clear, Hibernate is forced to first execute its delete SQL-statements, before the inserts.
      Specified by:
      addAfterClearFlusher in interface Configuration
      Parameters:
      afterClearFlusher - the flusher to be added to the call stack after a clear call
    • setBeanInitializer

      public void setBeanInitializer(BeanInitializer beanInitializer)
      Specified by:
      setBeanInitializer in interface Configuration
    • setBeanUnproxy

      public void setBeanUnproxy(BeanUnproxy beanUnproxy)
      Specified by:
      setBeanUnproxy in interface Configuration
    • isAddDefaultConverters

      public boolean isAddDefaultConverters()
      Specified by:
      isAddDefaultConverters in interface Configuration
    • setConverterChoosable

      public void setConverterChoosable(boolean converterChoosable)
      Specified by:
      setConverterChoosable in interface Configuration
    • downsizeSource

      public void downsizeSource(List<String> includeFields)
      Description copied from interface: Configuration
      Sets the field to downsize the source class. THe limited source class is mapped over the given target class.
      Specified by:
      downsizeSource in interface Configuration
      Parameters:
      includeFields - The fields to be mapped to the target class.
    • downsizeTarget

      public void downsizeTarget(List<String> includeFields)
      Description copied from interface: Configuration
      Sets the only fields that are allowed in the target class. If the include fields are set, it impacts the usage of the mapping strategy. Note that getting this field never refers to the parent configuration.
      Specified by:
      downsizeTarget in interface Configuration
      Parameters:
      includeFields - The field that are allowed in the target class.
    • setCollectionClass

      public void setCollectionClass(Class collectionClass)
      Description copied from interface: Configuration
      Sets the collection class of the collection. Used to instantiate the collection. If the collection class is set, it impacts the usage of the mapping strategy. Note that getting this field never refers to the parent configuration.
      Specified by:
      setCollectionClass in interface Configuration
      Parameters:
      collectionClass - the class type of the collection
    • setTargetClass

      public void setTargetClass(Class targetClass)
      Description copied from interface: Configuration
      Sets the target class. Used to instantiate the target. If this class is set, it impact the usage of the mapping strategy. Note that getting this field never refers to the parent configuration.
      Specified by:
      setTargetClass in interface Configuration
      Parameters:
      targetClass - the class type of the target
    • setTarget

      public void setTarget(Object target)
      Description copied from interface: Configuration
      Sets the target. If the target is set, it impact the usage of the mapping strategy. Note that getting this field never refers to the parent configuration.
      Specified by:
      setTarget in interface Configuration
      Parameters:
      target - the target instance to map to
    • setParent

      public void setParent(Object parent)
      Description copied from interface: Configuration
      The active parent for the field that is currently being mapped. This is always a parent on the target side of BeanMapper. @BeanParent makes us of this variable to assign to a field
      Specified by:
      setParent in interface Configuration
      Parameters:
      parent - the parent of the active field
    • determineTargetClass

      public Class determineTargetClass()
      Description copied from interface: Configuration
      On the basis of the target, the targetClass will be determined
      Specified by:
      determineTargetClass in interface Configuration
      Returns:
      the class of the target
    • setStrictSourceSuffix

      public void setStrictSourceSuffix(String strictSourceSuffix)
      Description copied from interface: Configuration
      Sets the classname suffix that determines a source class is to be treated as strict with regards to mapping. Default is "Form"
      Specified by:
      setStrictSourceSuffix in interface Configuration
      Parameters:
      strictSourceSuffix - the source classname suffix for a class to be treated as strict
    • setStrictTargetSuffix

      public void setStrictTargetSuffix(String strictTargetSuffix)
      Description copied from interface: Configuration
      Sets the classname suffix that determines a target class is to be treated as strict with regards to mapping. Default is "Result"
      Specified by:
      setStrictTargetSuffix in interface Configuration
      Parameters:
      strictTargetSuffix - the target classname suffix for a class to be treated as strict
    • setApplyStrictMappingConvention

      public void setApplyStrictMappingConvention(Boolean applyStrictMappingConvention)
      Description copied from interface: Configuration
      Determines if strict mapping convention will be applied. This means that if a source class has the strict source suffix, or a target class has the strict target suffix, the classes will be treated as if they are strict. This implies that all of their properties will require matching properties on the other side. Default is true.
      Specified by:
      setApplyStrictMappingConvention in interface Configuration
      Parameters:
      applyStrictMappingConvention - whether the strict mapping convention must be applied
    • setCollectionUsage

      public void setCollectionUsage(BeanCollectionUsage collectionUsage)
      Description copied from interface: Configuration
      Sets the collection usage for the current collection mapping
      Specified by:
      setCollectionUsage in interface Configuration
      Parameters:
      collectionUsage - the collection usage to apply
    • setPreferredCollectionClass

      public void setPreferredCollectionClass(Class<?> preferredCollectionClass)
      Description copied from interface: Configuration
      Sets the preferred collection class to be instantiated. If it has this choice, it will use this class over the one provided by the collection handler.
      Specified by:
      setPreferredCollectionClass in interface Configuration
      Parameters:
      preferredCollectionClass - the collection class to prefer for instantiation
    • setFlushAfterClear

      public void setFlushAfterClear(Boolean flushAfterClear)
      Description copied from interface: Configuration
      Determines whether the flush-chain must be called after a clear has taken place.
      Specified by:
      setFlushAfterClear in interface Configuration
      Parameters:
      flushAfterClear - true if the flush-chain must be called
    • setFlushEnabled

      public void setFlushEnabled(Boolean flushEnabled)
      Description copied from interface: Configuration
      Set whether flushing must be enabled. Flushing is the calling of flush() on a collection after it has been cleared. This force an ORM to run its delete queries. Default setting is false, because flushing is tied closely to having a transaction context. If, this is not the case, the flush will throw an exception.
      Specified by:
      setFlushEnabled in interface Configuration
      Parameters:
      flushEnabled - whether flushing has been enabled
    • setRoleSecuredCheck

      public void setRoleSecuredCheck(RoleSecuredCheck roleSecuredCheck)
      Description copied from interface: Configuration
      The RoleSecuredCheck is responsible for checking if a Principal may access a field or method annotated with @BeanRoleSecured.
      Specified by:
      setRoleSecuredCheck in interface Configuration
      Parameters:
      roleSecuredCheck - the new active RoleSecuredCheck
    • setEnforceSecuredProperties

      public void setEnforceSecuredProperties(Boolean enforceSecuredProperties)
      Description copied from interface: Configuration
      Property that determines if secured properties must be handled. If this is set to true and the RoleSecuredCheck has not been set, an exception will be thrown.
      Specified by:
      setEnforceSecuredProperties in interface Configuration
      Parameters:
      enforceSecuredProperties - whether the handling of secured properties is enforced
    • setUseNullValue

      public void setUseNullValue(Boolean useNullValue)
      Description copied from interface: Configuration
      Property that determines if null values for the source must be skipped or not
      Specified by:
      setUseNullValue in interface Configuration
      Parameters:
      useNullValue - determines if null values must be skipped or not