Class CheckerURI

java.lang.Object
util.AbstractChecker<URI,CheckerURI>
specialized_checkers.io.CheckerURI
All Implemented Interfaces:
InterfaceChecker<AbstractChecker<URI,CheckerURI>,URI>

public class CheckerURI extends AbstractChecker<URI,CheckerURI>
A specialized checker for URI objects, providing fluent validation methods for various URI components such as scheme, host, port, authority, fragment, path, and query.

This class extends AbstractChecker to enable chainable assertions on URI instances. It supports both default and custom naming for checkers, and provides static factory methods for convenient instantiation from URI or String representations.

Usage Example:


 CheckerURI.check("https://example.com", "ExampleURI")
     .isAbsolute()
     .hasHost("example.com")
     .hasPath("/index.html");
 

Each validation method returns this for fluent chaining.

  • Constructor Details

    • CheckerURI

      protected CheckerURI(URI uri, String name)
      Constructs a new CheckerURI with the specified URI and name.
      Parameters:
      uri - the URI associated with this checker
      name - the name of the checker
  • Method Details

    • check

      public static CheckerURI check(URI uri, String name)
      Creates a CheckerURI for the given URI and assigns a custom name.
      Parameters:
      uri - the URI to check
      name - the name to assign to this checker
      Returns:
      a CheckerURI instance for the given URI
    • check

      public static CheckerURI check(String path, String name)
      Creates a CheckerURI from a string path and assigns a custom name.
      Parameters:
      path - the string representation of the URI
      name - the name to assign to this checker
      Returns:
      a CheckerURI instance for the given path
    • check

      public static CheckerURI check(URI uri)
      Creates a CheckerURI for the given URI with a default name.
      Parameters:
      uri - the URI to check
      Returns:
      a CheckerURI instance for the given URI
    • check

      public static CheckerURI check(String path)
      Creates a CheckerURI from a string path with a default name.
      Parameters:
      path - the string representation of the URI
      Returns:
      a CheckerURI instance for the given path
    • self

      protected CheckerURI self()
      Returns this instance (for fluent API).
      Specified by:
      self in class AbstractChecker<URI,CheckerURI>
      Returns:
      this CheckerURI instance
    • isAbsolute

      public CheckerURI isAbsolute()
      Checks if the URI is absolute (has a scheme).
      Returns:
      this CheckerURI instance
    • isRelative

      public CheckerURI isRelative()
      Checks if the URI is relative (does not have a scheme).
      Returns:
      this CheckerURI instance
    • hasSqueme

      public CheckerURI hasSqueme()
      Checks if the URI has a scheme component.
      Returns:
      this CheckerURI instance
    • hasSqueme

      public CheckerURI hasSqueme(String... squemes)
      Checks if the URI's scheme matches any of the specified schemes.
      Parameters:
      squemes - the schemes to check for
      Returns:
      this CheckerURI instance
    • hasHost

      public CheckerURI hasHost()
      Checks if the URI has a host component.
      Returns:
      this CheckerURI instance
    • hasHost

      public CheckerURI hasHost(String... hosts)
      Checks if the URI's host matches any of the specified hosts.
      Parameters:
      hosts - the hosts to check for
      Returns:
      this CheckerURI instance
    • hasPort

      public CheckerURI hasPort()
      Checks if the URI has a port component.
      Returns:
      this CheckerURI instance
    • hasPort

      public CheckerURI hasPort(int... ports)
      Checks if the URI's port matches any of the specified ports.
      Parameters:
      ports - the ports to check for
      Returns:
      this CheckerURI instance
    • hasAuthority

      public CheckerURI hasAuthority()
      Checks if the URI has an authority component.
      Returns:
      this CheckerURI instance
    • hasAuthority

      public CheckerURI hasAuthority(String... authorities)
      Checks if the URI's authority matches any of the specified authorities.
      Parameters:
      authorities - the authorities to check for
      Returns:
      this CheckerURI instance
    • hasFrament

      public CheckerURI hasFrament()
      Checks if the URI has a fragment component.
      Returns:
      this CheckerURI instance
    • hasFrament

      public CheckerURI hasFrament(String... fragments)
      Checks if the URI's fragment matches any of the specified fragments.
      Parameters:
      fragments - the fragments to check for
      Returns:
      this CheckerURI instance
    • hasPath

      public CheckerURI hasPath()
      Checks if the URI has a path component.
      Returns:
      this CheckerURI instance
    • hasPath

      public CheckerURI hasPath(String... paths)
      Checks if the URI's path matches any of the specified paths.
      Parameters:
      paths - the paths to check for
      Returns:
      this CheckerURI instance
    • hasQuery

      public CheckerURI hasQuery()
      Checks if the URI has a query component.
      Returns:
      this CheckerURI instance
    • hasQuery

      public CheckerURI hasQuery(String... queries)
      Checks if the URI's query matches any of the specified queries.
      Parameters:
      queries - the queries to check for
      Returns:
      this CheckerURI instance