Class ProductSwitch

java.lang.Object
org.faktorips.runtime.productswitch.ProductSwitch

public class ProductSwitch extends Object
The ProductSwitch class is used to generically and recursively switch the IProductComponent of an IConfigurableModelObject and its children.

By default, it uses the only replacement that is configured in the product configuration. If more than one replacement is found, it uses the IProductComponent.getKindId() to determine the correct replacement.

The default behavior can be changed by providing a BiPredicate that provides a more specific way than the kindId to find a replacement, or by providing a different implementation of the MatchingProductFinder or the AdvancedProductFinder interface.

Since:
23.6
  • Field Details

    • BY_KIND_ID

      public static final BiPredicate<IProductComponent,IProductComponent> BY_KIND_ID
      This BiPredicate uses the IProductComponent.getKindId() to find a suitable replacement for a product switch. It can be used as a fallback for the from(IConfigurableModelObject) method.

      Example usage:

       
           // fallback after a BiPredicate for a special case
           ProductSwitch.from(modelObject).with(mySpecialBiPredicate.or(ProductSwitch.BY_KIND_ID)).to(otherProductComponent);
      
           // using only
           ProductSwitch.from(modelObject).with(ProductSwitch.BY_KIND_ID).to(otherProductComponent);
      
           // is the same as the default behavior of
           ProductSwitch.from(modelObject).to(otherProductComponent);
       
       
  • Method Details