Class ISBNValidator

java.lang.Object
de.creativecouple.validation.isbn.ISBNValidator
All Implemented Interfaces:
Predicate<String>

public final class ISBNValidator extends Object implements Predicate<String>
The ISBNValidator class represents a combination of rules for the desired ISBN length (10 or 13) and hyphenation style (any, none, correct, correct-or-none), for checking input strings.
E.g. myValidator = ISBNValidator.isbn13().hyphenation(NONE) to validate compact ISBN-13 string only.
Author:
Peter Liske (CreativeCouple)
See Also:
  • Method Details

    • test

      public boolean test(String isbnString)
      Checks whether a given string passes this validator's criteria.
      Specified by:
      test in interface Predicate<String>
      Returns:
      whether ot not the input string is valid
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • parse

      public ISBN parse(String input)
      Parses a given string input and returns an ISBN object, if it matches this validator's criteria.
      Returns:
      the ISBN object
      Throws:
      IllegalArgumentException - if the input is invalid according to this validator
    • anyIsbn

      public static ISBNValidatorBuilder anyIsbn()
      Returns:
      a builder object for validating both ISBN-10 and ISBN-13 strings
    • isbn10

      public static ISBNValidatorBuilder isbn10()
      Returns:
      a builder object for validating ISBN-10 strings only
    • isbn13

      public static ISBNValidatorBuilder isbn13()
      Returns:
      a builder object for validating ISBN-13 strings only