Class Configuration
java.lang.Object
de.gustavblass.nginx.ipguard4j.configuration.Configuration
Specifies the behaviour of IPguard4j.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe path to the example YAML configuration file, relative to the application's resources folder (with the package name as folder structure inside).private final @NonNull Set<IpListConfiguration> The input lists from which the IP addresses will be parsed.static final StringThe path to the JSON schema for Configuration files, relative to the application's resources folder (with the package name as folder structure inside).private static final @NonNull org.apache.logging.log4j.LoggerTracks efficiently all target files that have already been configured intargetFiles.private final @NonNull Set<TargetConfiguration> The destination files to which the parsed IP addresses will be written.static final StringThe path to the YAML schema for Configuration files, relative to the application's resources folder (with the package name as folder structure inside). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@NonNull HashSet<IpListConfiguration> @NonNull HashSet<TargetConfiguration> static @NonNull Configurationprivate voidsetIpLists(@NonNull Collection<IpListConfiguration> ipLists) Updates theipListswith the given new ones.private voidsetTargetFiles(@NonNull Collection<TargetConfiguration> targetFiles) Updates thetargetFileswith the given new ones.
-
Field Details
-
LOG
@NonNull private static final @NonNull org.apache.logging.log4j.Logger LOG -
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
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
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
The input lists from which the IP addresses will be parsed. -
targetFiles
The destination files to which the parsed IP addresses will be written. Each target file can only be configured once. -
targetFileCache
Tracks efficiently all target files that have already been configured intargetFiles.
-
-
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 theipListswith 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 thetargetFileswith 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 configurationFileto a newConfiguration. Those fields of the Configuration class will be parsed that are annotated withJsonProperty. (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.
-