Class PermutedCopyCreator<T extends AnchorBean<T>>

Object
PermutedCopyCreator<T>
Type Parameters:
T - the type of bean which will be copied and permuted.

public class PermutedCopyCreator<T extends AnchorBean<T>> extends Object
Applies a PermuteProperty to a bean to create new duplicated beans each with different permuted values.
Author:
Owen Feehan
  • Constructor Details

    • PermutedCopyCreator

      public PermutedCopyCreator(Function<T,String> nameGetter, BiConsumer<T,String> nameSetter)
      Creates a new PermutedCopyCreator instance.
      Parameters:
      nameGetter - Gets a name from object of type T.
      nameSetter - sets a name on an object of type T.
  • Method Details

    • createPermutedCopies

      public <S> List<T> createPermutedCopies(List<T> beans, PermuteProperty<S> propertyToPermute, PermutationAssigner setter) throws CreateException
      Applies a permutation to a copy of each element in a list of beans, updating the custom name of each bean to reflect the permutation.

      Specifically, .XXX is appended to each name, where XXX describes the permutation.

      Type Parameters:
      S - permutation-type
      Parameters:
      beans - list of beans on which a permutation is applied.
      propertyToPermute - the property to permute, and all the values for the permutation.
      setter - for setting the permutation onto the property.
      Returns:
      a list containing the permuted beans.
      Throws:
      CreateException - if something goes wrong.