Interface Configuration

All Known Implementing Classes:
CoreConfiguration, OverrideConfiguration

public interface Configuration
  • Method Details

    • getDownsizeTarget

      List<String> getDownsizeTarget()
      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.
      Returns:
      the fields to include in the target
    • getDownsizeSource

      List<String> getDownsizeSource()
      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.
      Returns:
      the fields to include in the source
    • getCollectionClass

      Class getCollectionClass()
      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.
      Returns:
      class of the collection
    • setCollectionClass

      void setCollectionClass(Class collectionClass)
      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.
      Parameters:
      collectionClass - the class type of the collection
    • getTargetClass

      Class getTargetClass()
      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.
      Returns:
      class of the target
    • setTargetClass

      void setTargetClass(Class targetClass)
      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.
      Parameters:
      targetClass - the class type of the target
    • getTarget

      Object getTarget()
      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.
      Returns:
      class of the collection
    • setTarget

      void setTarget(Object target)
      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.
      Parameters:
      target - the target instance to map to
    • getParent

      Object getParent()
      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
      Returns:
      the parent of the active field
    • setParent

      void setParent(Object parent)
      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
      Parameters:
      parent - the parent of the active field
    • getBeanInitializer

      BeanInitializer getBeanInitializer()
    • setBeanInitializer

      void setBeanInitializer(BeanInitializer beanInitializer)
    • getBeanUnproxy

      BeanUnproxy getBeanUnproxy()
    • setBeanUnproxy

      void setBeanUnproxy(BeanUnproxy beanUnproxy)
    • getBeanMatchStore

      BeanMatchStore getBeanMatchStore()
      Always use the CoreConfiguration beanmatch store
      Returns:
      the one beanmatch store
    • getClassStore

      ClassStore getClassStore()
      Always use the CoreConfiguration class store
      Returns:
      the one class store
    • getPackagePrefixes

      List<String> getPackagePrefixes()
    • getBeanConverters

      List<BeanConverter> getBeanConverters()
    • getLogicSecuredChecks

      Map<Class<? extends LogicSecuredCheck>,LogicSecuredCheck> getLogicSecuredChecks()
    • getCollectionHandlers

      List<CollectionHandler> getCollectionHandlers()
      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.
      Returns:
      the list of registered collection handlers
    • getCollectionHandlerFor

      CollectionHandler getCollectionHandlerFor(Class<?> clazz)
      Finds the correction handler for the class. Null, if not found.
      Parameters:
      clazz - class to find the correct collection handler for
      Returns:
      collection handler for the class, or null if not found
    • getCollectionHandlerForCollectionClass

      CollectionHandler getCollectionHandlerForCollectionClass()
      Finds the collection handler for the collection class, null if not exists
      Returns:
      the collection handler for the collection class, null if not exists
    • getBeanPairs

      List<BeanPair> getBeanPairs()
      Returns the entire list of strict bean pairs. The properties on the strict side must have matching properties on the other, non-strict side.
      Returns:
      the entire list of strict bean pairs.
    • isConverterChoosable

      boolean isConverterChoosable()
    • setConverterChoosable

      void setConverterChoosable(boolean converterChoosable)
    • withoutDefaultConverters

      void withoutDefaultConverters()
    • getStrictSourceSuffix

      String getStrictSourceSuffix()
      Returns the classname suffix that determines a source class is to be treated as strict with regards to mapping. Default is "Form"
      Returns:
      the source classname suffix for a class to be treated as strict
    • setStrictSourceSuffix

      void setStrictSourceSuffix(String strictSourceSuffix)
      Sets the classname suffix that determines a source class is to be treated as strict with regards to mapping. Default is "Form"
      Parameters:
      strictSourceSuffix - the source classname suffix for a class to be treated as strict
    • getStrictTargetSuffix

      String getStrictTargetSuffix()
      Returns the classname suffix that determines a target class is to be treated as strict with regards to mapping. Default is "Result"
      Returns:
      the target classname suffix for a class to be treated as strict
    • setStrictTargetSuffix

      void setStrictTargetSuffix(String strictTargetSuffix)
      Sets the classname suffix that determines a target class is to be treated as strict with regards to mapping. Default is "Result"
      Parameters:
      strictTargetSuffix - the target classname suffix for a class to be treated as strict
    • isApplyStrictMappingConvention

      boolean isApplyStrictMappingConvention()
      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.
      Returns:
      if true, the strict mapping convention will be applied
    • setApplyStrictMappingConvention

      void setApplyStrictMappingConvention(boolean applyStrictMappingConvention)
      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.
      Parameters:
      applyStrictMappingConvention - whether the strict mapping convention must be applied
    • getStrictMappingProperties

      StrictMappingProperties getStrictMappingProperties()
      Returns the collection of strictSourceSuffix, strictTargetSuffix and applyStrictMappingConvention properties.
      Returns:
      all properties required for dealing with the strict mapping convention
    • getCollectionUsage

      BeanCollectionUsage getCollectionUsage()
      Returns the type of collection usage for the current collection mapping
      Returns:
      collection usage to apply
    • setCollectionUsage

      void setCollectionUsage(BeanCollectionUsage collectionUsage)
      Sets the collection usage for the current collection mapping
      Parameters:
      collectionUsage - the collection usage to apply
    • getPreferredCollectionClass

      <T> Class<T> getPreferredCollectionClass()
      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.
      Returns:
      the collection class to prefer for instantiation
    • setPreferredCollectionClass

      void setPreferredCollectionClass(Class<?> preferredCollectionClass)
      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.
      Parameters:
      preferredCollectionClass - the collection class to prefer for instantiation
    • getCollectionFlusher

      CollectionFlusher getCollectionFlusher()
      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.
      Returns:
      the collection clearer
    • isFlushAfterClear

      Trinary isFlushAfterClear()
      Determines if the flush-chain must be called after a clear() operation on a collection has taken place.
      Returns:
      true if the flush-chain must be called after a clear
    • isFlushEnabled

      boolean isFlushEnabled()
      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.
      Returns:
      whether flushing has been enabled
    • setFlushEnabled

      void setFlushEnabled(boolean flushEnabled)
      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.
      Parameters:
      flushEnabled - whether flushing has been enabled
    • mustFlush

      boolean mustFlush()
      Works on the combination of the global flush setting (flushEnabled) and the specific flush setting (flushAfterClear). If both are true, the flush will trigger.
      Returns:
      true if a flush after clear must take place
    • getUseNullValue

      boolean getUseNullValue()
      Property that determines if null values for the source must be skipped or not
      Returns:
      determines if null values must be skipped or not
    • setUseNullValue

      void setUseNullValue(boolean useNullValue)
      Property that determines if null values for the source must be skipped or not
      Parameters:
      useNullValue - determines if null values must be skipped or not
    • getRoleSecuredCheck

      RoleSecuredCheck getRoleSecuredCheck()
      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.
      Returns:
      the active RoleSecuredCheck, if set. Otherwise, null
    • setRoleSecuredCheck

      void setRoleSecuredCheck(RoleSecuredCheck roleSecuredCheck)
      The RoleSecuredCheck is responsible for checking if a Principal may access a field or method annotated with @BeanRoleSecured.
      Parameters:
      roleSecuredCheck - the new active RoleSecuredCheck
    • getEnforceSecuredProperties

      boolean getEnforceSecuredProperties()
      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.
      Returns:
      whether the handling of secured properties is enforced
    • setEnforceSecuredProperties

      void setEnforceSecuredProperties(boolean enforceSecuredProperties)
      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.
      Parameters:
      enforceSecuredProperties - whether the handling of secured properties is enforced
    • addConverter

      void addConverter(BeanConverter converter)
      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.
      Parameters:
      converter - an instance of the class that contains the conversion method implementations and inherits from the abstract BeanConverter class.
    • addLogicSecuredCheck

      void addLogicSecuredCheck(LogicSecuredCheck logicSecuredCheck)
      Add a check instance that takes the source and target instances and on the basis of those two determines whether access must be provided
      Parameters:
      logicSecuredCheck - the check instance to register
    • addCollectionHandler

      void addCollectionHandler(CollectionHandler collectionHandler)
      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.
      Parameters:
      collectionHandler - the collection handler to register
    • addBeanPairWithStrictSource

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

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

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

      void addPackagePrefix(Class<?> clazz)
      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
      Parameters:
      clazz - the class which sets the package prefix for all mappable classes
    • addPackagePrefix

      void addPackagePrefix(String packagePrefix)
      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
      Parameters:
      packagePrefix - the String which sets the package prefix for all mappable classes
    • addAfterClearFlusher

      void addAfterClearFlusher(AfterClearFlusher afterClearFlusher)
      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.
      Parameters:
      afterClearFlusher - the flusher to be added to the call stack after a clear call
    • isAddDefaultConverters

      boolean isAddDefaultConverters()
    • downsizeSource

      void downsizeSource(List<String> includeFields)
      Sets the field to downsize the source class. THe limited source class is mapped over the given target class.
      Parameters:
      includeFields - The fields to be mapped to the target class.
    • downsizeTarget

      void downsizeTarget(List<String> includeFields)
      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.
      Parameters:
      includeFields - The field that are allowed in the target class.
    • determineTargetClass

      Class determineTargetClass()
      On the basis of the target, the targetClass will be determined
      Returns:
      the class of the target
    • setFlushAfterClear

      void setFlushAfterClear(Trinary flushAfterClear)
      Determines whether the flush-chain must be called after a clear has taken place.
      Parameters:
      flushAfterClear - true if the flush-chain must be called
    • addCustomDefaultValueForClass

      <T, V> void addCustomDefaultValueForClass(Class<T> target, V value)
      Allows the user to set a default value for a given type.

      While the standard implementation of BeanMapper contains a utility-class DefaultValues, the map within is far from exhaustive. Furthermore, custom default values can serve as a useful compatibility feature for projects that would prefer different defaults.

      Type Parameters:
      T - The type of the target.
      V - The type of the value.
      Parameters:
      target - The target class.
      value - The default value for the given target class.
    • getDefaultValueForClass

      <T, V> V getDefaultValueForClass(Class<T> targetClass)
      Gets the default for the given target class.

      Any implementation of this method must first check the registered custom default values for a suitable value, if a container for custom defaults exists. Afterwards, the method may check a parent-configuration's custom defaults, or simply refer to the defaults in DefaultValues.

      Type Parameters:
      T - The type of the target-class.
      V - The type of the associated value.
      Parameters:
      targetClass - The target class
      Returns:
      The value associated with the given target class, based off of the values set in the custom default values container, or the DefaultValues-class.