Class PlainIpListParser
java.lang.Object
de.gustavblass.nginx.ipguard4j.parser.PlainIpListParser
- All Implemented Interfaces:
IpListParser
A parser that extracts
IPAddresses from plain IP-list entries, without special formatting (other
than comments).-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classFinalBuilder ::= '#addCommentSymbol'* build PlainIpListParserstatic final classStartBuilder ::= ( '#withDefaultCommentSymbols' | '#withoutDefaultCommentSymbols' ) FinalBuilder -
Field Summary
FieldsModifier and TypeFieldDescriptionSymbols that mark the beginning of a comment in a plain IP-list entry.Pre-defined symbols that mark the beginning of a comment in a plain IP-list entry. -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
DEFAULT_COMMENT_CHARACTERS
-
commentCharacters
-
-
Constructor Details
-
PlainIpListParser
public PlainIpListParser()
-
-
Method Details
-
parse
@Contract(pure=true) @NonNull public @NonNull Optional<inet.ipaddr.IPAddress> parse(@NonNull @NonNull String listEntry) throws de.gustavblass.commons.exceptions.IllegalArgumentException Converts the given plain-text entry of an IP-address list into anIPAddressobject.- Specified by:
parsein interfaceIpListParser- Parameters:
listEntry- The string representation of the IP address, in plain format. Comments starting with any of thecommentCharacterswill be ignored.- Returns:
- The IP address represented by the given string. Empty if no entry is blank or contains only a comment.
- Throws:
de.gustavblass.commons.exceptions.IllegalArgumentException- If the non-blank, non-comment part of the given string does not represent a valid IP address.
-
hashCode
@Contract(pure=true) public int hashCode()- Overrides:
hashCodein classObject- Returns:
- The
AbstractSet.hashCode()of thecommentCharacters.
-
builder
@Contract(pure=true, value="-> new") @NonNull public static @NonNull PlainIpListParser.StartBuilder builder()
Builder ::= ( '#withDefaultCommentSymbols' | '#withoutDefaultCommentSymbols' ) '#addCommentSymbol'* '#build'- Returns:
- A new builder for creating a new
PlainIpListParserinstance.
-