Class Cleanup.Builder

java.lang.Object
de.aristaflow.adept2.util.Cleanup.Builder
Enclosing class:
Cleanup<EX extends Exception>

public static class Cleanup.Builder extends Object
A builder for Cleanup that provides some additional options and generally easier usage than complex constructors.
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • cleaner

      public Cleanup.Builder cleaner(Cleaner cleaner)
      Sets a specific cleaner to be used. Otherwise the default cleaner will be used.
      Parameters:
      cleaner - The custom cleaner to be used for clean-up.
      Returns:
      This builder.
    • descriptor

      public Cleanup.Builder descriptor(String descriptor)
      Sets the designated string that meaningfully describes this task when used for logging etc. Otherwise the class name of the registered object will be used.
      Parameters:
      descriptor - The custom descriptor to be used for logging.
      Returns:
      This builder.
    • logger

      public Cleanup.Builder logger(Logger logger)
      Sets the logger for messages and/or problems, e. g. unexpected exceptions. Otherwise the default logger will be used.
      Parameters:
      logger - The custom logger to be used for logging.
      Returns:
      This builder.
    • register

      public Cleanup<RuntimeException> register(Object object)
      Finishes creating a Cleanup for the given object using the other provided information. There will be no transparent pass-through for a checked exception in Cleanup.clean().
      Parameters:
      object - The object for which to register post-mortem clean-up.
      Returns:
      A new Cleanup allowing to perform post-mortem clean-up.
    • register

      public <EX extends Exception> Cleanup<EX> register(Object object, Class<EX> checkedExceptionType)
      Finishes creating a Cleanup for the given object using the other provided information. There will be transparent pass-through for the provided checked exception type in Cleanup.clean().
      Parameters:
      object - The object for which to register post-mortem clean-up.
      checkedExceptionType - The exception that is expected by the clean-up. This will be forwarded when manually triggering clean-up.
      Returns:
      A new Cleanup allowing to perform post-mortem clean-up.