Pattern

info.fingo.spata.text.StringParser.Pattern
final class Pattern[A]

Intermediary to delegate parsing to in order to infer type of formatter used by parser.

When adding parsing function to an entity, instead of providing

def parse[A, B](input: String, format: B)(using parser: FormattedStringParser[A, B]): ParseResult[A]

which requires then to use it as

entity.parse[Double, NumberFormat]("123,45", numberFormat)

one can provide function to get this Pattern

def parse[A]: Pattern[A]

and use it with nicer syntax

entity.parse[Double]("123,45", numberFormat)

Type parameters

A

target type for parsing

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def apply[B](str: String, fmt: B)(using parser: FormattedStringParser[A, B]): ParseResult[A]

Parses string to desired type based on provided format.

Parses string to desired type based on provided format.

Type parameters

B

type of formatter

Value parameters

fmt

formatter specific for particular result type, e.g. DateTimeFormatter for dates and times

parser

the parser for specific target type

str

the input string to parse

Attributes

Returns

either parsed value or an exception