Class CustomIpAddressFormatter
java.lang.Object
de.gustavblass.nginx.ipguard4j.CustomIpAddressFormatter
- All Implemented Interfaces:
IpAddressFormatter
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCustomIpAddressFormatter(String format) Creates a newCustomIpAddressFormatterthat turnsIPAddresss into the string representation defined by givenformat. -
Method Summary
Modifier and TypeMethodDescription@NonNull Stringformat(@NonNull inet.ipaddr.IPAddress ipAddress) Converts the givenIPAddressto a string representation according to theformatpreviously defined.Converts the given string format to list ofFunctions that can be used to format anIPAddressaccording to the given format, when executed in the correct order.
-
Field Details
-
format
-
-
Constructor Details
-
CustomIpAddressFormatter
public CustomIpAddressFormatter(String format) throws de.gustavblass.commons.exceptions.IllegalArgumentException Creates a newCustomIpAddressFormatterthat turnsIPAddresss into the string representation defined by givenformat.
-
-
Method Details
-
format
@Contract(pure=true) @NonNull public @NonNull String format(@NonNull @NonNull inet.ipaddr.IPAddress ipAddress) Converts the givenIPAddressto a string representation according to theformatpreviously defined.- Specified by:
formatin interfaceIpAddressFormatter- Parameters:
ipAddress- TheIPAddressto format.- Returns:
- The formatted string representation of the given
IPAddress.
-
parse
@Contract(pure=true, value="_ -> new") @NonNull public static @NonNull List<Function<inet.ipaddr.IPAddress, String>> parse(@NonNull @NonNull String format) throws de.gustavblass.commons.exceptions.IllegalArgumentException Converts the given string format to list ofFunctions that can be used to format anIPAddressaccording to the given format, when executed in the correct order.- Parameters:
format- Defines how anIPAddressshall be formatted. Must contain the$ipsubstring at least once, as a placeholder for theIPAddressto be filled in.- Returns:
- Functions that must be executed in order to format any
IPAddress. The functions are pure and can be executed arbitrarily many times. - Throws:
de.gustavblass.commons.exceptions.IllegalArgumentException- If the given format string contains no$ipkeyword.
-