Class DuplicateValidator

java.lang.Object
org.kigalisim.lang.validation.DuplicateValidator

public class DuplicateValidator extends Object
Utility class for validating unique names and preventing duplicates.

This class provides static methods for validating that collections of items have unique names and for checking substance+equipment type combinations.

  • Constructor Details

    • DuplicateValidator

      public DuplicateValidator()
      Constructs a new DuplicateValidator.
  • Method Details

    • validateUniqueNames

      public static <T> Map<String,T> validateUniqueNames(Iterable<T> items, Function<T,String> nameExtractor, String itemType, String context)
      Validate that all items in a collection have unique names.
      Type Parameters:
      T - The type of items to validate
      Parameters:
      items - The iterable collection of items to validate
      nameExtractor - Function to extract the name from each item
      itemType - The type of item being validated (for error messages)
      context - The context where validation is occurring (for error messages)
      Returns:
      A map of validated items indexed by their unique names
      Throws:
      DuplicateValidationException - if duplicate names are found
    • validateUniqueSubstanceEquipmentCombinations

      public static void validateUniqueSubstanceEquipmentCombinations(Iterable<ParsedSubstance> substances, String applicationName)
      Validate that substance+equipment type combinations are unique within an application.
      Parameters:
      substances - The substances to validate for unique equipment type combinations
      applicationName - The name of the application (for error messages)
      Throws:
      DuplicateValidationException - if duplicate substance+equipment combinations are found