Module de.carne
Package de.carne.text

Class IntegerParser

  • All Implemented Interfaces:
    Parser<java.lang.Integer>, java.util.function.Function<java.lang.String,​java.lang.Integer>

    public class IntegerParser
    extends java.lang.Object
    implements Parser<java.lang.Integer>
    Integer parser.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static IntegerParser ANY
      Standard parser for any integer value.
      static IntegerParser POSITIVE
      Standard parser for any positive integer value.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Integer parse​(java.lang.String s)
      Parses the submitted string.
      int parseInt​(java.lang.String s)
      Parses the submitted string.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.function.Function

        andThen, compose
      • Methods inherited from interface de.carne.text.Parser

        apply
    • Field Detail

      • ANY

        public static final IntegerParser ANY
        Standard parser for any integer value.
      • POSITIVE

        public static final IntegerParser POSITIVE
        Standard parser for any positive integer value.
    • Constructor Detail

      • IntegerParser

        public IntegerParser()
        Constructs a new IntegerParser accepting any integer value.
      • IntegerParser

        public IntegerParser​(int min,
                             int max)
        Constructs a new IntegerParser accepting integer values of the given range.
        Parameters:
        min - the minimum integer value to accept.
        max - the maximum integer value to accept.
    • Method Detail

      • parse

        public java.lang.Integer parse​(java.lang.String s)
        Description copied from interface: Parser
        Parses the submitted string.
        Specified by:
        parse in interface Parser<java.lang.Integer>
        Parameters:
        s - the String to parse.
        Returns:
        the parse result.
      • parseInt

        public int parseInt​(java.lang.String s)
        Parses the submitted string.
        Parameters:
        s - the String to parse.
        Returns:
        the parse result.
        Throws:
        java.lang.RuntimeException - if the parse operation fails.