Class Parser
- java.lang.Object
-
- org.birchframework.framework.regex.Parser
-
public class Parser extends Object
Parser that works with classes annotated withRegexBinding
and fields annotated withCaptureGroup
. This utility will parse an input against any number of annotated classes, and will create an instance of each of the class types where its defined regular expression matchesone line of that input string.- Author:
- Keivan Khalichi
- See Also:
RegexBinding
,CaptureGroup
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Parser
of(Class<? extends Serializable>... theTypes)
Factory method to create an instance of this utility.List<Serializable>
parse(String theInput)
Parses the input against the class types provided in theof(Class[])
method.Stream<Serializable>
parse(Stream<String> theInput)
Parses the input stream of strings against the class types provided in theof(Class[])
method, in a stream.
-
-
-
Method Detail
-
of
@SafeVarargs public static Parser of(@Nonnull Class<? extends Serializable>... theTypes)
Factory method to create an instance of this utility.- Parameters:
theTypes
- serializable class types annotated withRegexBinding
- Returns:
- a parser instance
-
parse
public List<Serializable> parse(@Nonnull String theInput)
Parses the input against the class types provided in theof(Class[])
method. This method is thread-safe.- Parameters:
theInput
- the input to be parsed 1 line at a time- Returns:
- instances of types provided, with one instance per match within the input
-
parse
public Stream<Serializable> parse(@Nonnull Stream<String> theInput)
Parses the input stream of strings against the class types provided in theof(Class[])
method, in a stream. This method is thread-safe, and the provided parameter stream can be a parrallel stream.- Parameters:
theInput
- the input to be parsed as a stream of strings wherein 1 string is parsed against library of possibleRegexBinding
POJOs- Returns:
- stream of instances of types provided, with one instance per match within the input
- Throws:
ParseException
- if any fields of thetypes
POJOs are not accessible
-
-