Class Configuration

java.lang.Object
de.gustavblass.nginx.ipguard4j.configuration.Configuration

public class Configuration extends Object
Specifies the behaviour of IPguard4j.
  • Field Details

    • LOG

      @NonNull private static final @NonNull org.apache.logging.log4j.Logger LOG
    • YAML_SCHEMA_PATH

      public static final String YAML_SCHEMA_PATH
      The path to the YAML schema for Configuration files, relative to the application's resources folder (with the package name as folder structure inside).
      See Also:
    • JSON_SCHEMA_PATH

      public static final String JSON_SCHEMA_PATH
      The path to the JSON schema for Configuration files, relative to the application's resources folder (with the package name as folder structure inside).
      See Also:
    • EXAMPLE_YAML_CONFIGURATION_PATH

      public static final String EXAMPLE_YAML_CONFIGURATION_PATH
      The path to the example YAML configuration file, relative to the application's resources folder (with the package name as folder structure inside).
      See Also:
    • ipLists

      @NonNull private final @NonNull Set<IpListConfiguration> ipLists
      The input lists from which the IP addresses will be parsed.
    • targetFiles

      @NonNull private final @NonNull Set<TargetConfiguration> targetFiles
      The destination files to which the parsed IP addresses will be written. Each target file can only be configured once.
    • targetFileCache

      @NonNull private final @NonNull Set<File> targetFileCache
      Tracks efficiently all target files that have already been configured in targetFiles.
  • Constructor Details

    • Configuration

      public Configuration()
  • Method Details

    • getIpLists

      @Contract(pure=true, value="-> new") @NonNull public @NonNull HashSet<IpListConfiguration> getIpLists()
      Returns:
      A shallow copy of the ipLists.
    • getTargetFiles

      @Contract(pure=true, value="-> new") @NonNull public @NonNull HashSet<TargetConfiguration> getTargetFiles()
      Returns:
      A shallow copy of the targetFiles.
    • setIpLists

      @Contract(mutates="this") private void setIpLists(@NonNull @NonNull Collection<IpListConfiguration> ipLists)
      Updates the ipLists with the given new ones.
      Parameters:
      ipLists - The new input lists.
    • setTargetFiles

      @Contract(mutates="this") private void setTargetFiles(@NonNull @NonNull Collection<TargetConfiguration> targetFiles) throws de.gustavblass.commons.exceptions.IllegalArgumentException
      Updates the targetFiles with the given new ones.
      Parameters:
      targetFiles - The new output files. Must not contain any duplicates.
      Throws:
      de.gustavblass.commons.exceptions.IllegalArgumentException - If the given collection contains duplicate target files.
    • parseYAML

      @Contract(pure=true, value="_, -> new") @NonNull public static @NonNull Configuration parseYAML(@NonNull @NonNull File file) throws IOException, de.gustavblass.commons.exceptions.IllegalArgumentException
      Converts the given YAML-formatted configuration File to a new Configuration. Those fields of the Configuration class will be parsed that are annotated with JsonProperty. (This applies recursively to those classes' fields as well.)
      Parameters:
      file - The file in the file system that contains the YAML representation of the Configuration to be created.
      Returns:
      The new Configuration created from the given YAML file.
      Throws:
      IOException - If an I/O error happened while reading the given file.
      de.gustavblass.commons.exceptions.IllegalArgumentException - If the content of the given file is not valid YAML or does not match the expected format.