5802 } 5803 5804 /** 5805 * This must be the very first initializer. 5806 */ 5807 static final Node accept = new Node(); 5808 5809 static final Node lastAccept = new LastNode(); 5810 5811 /** 5812 * Creates a predicate which can be used to match a string. 5813 * 5814 * @return The predicate which can be used for matching on a string 5815 * @since 1.8 5816 */ 5817 public Predicate<String> asPredicate() { 5818 return s -> matcher(s).find(); 5819 } 5820 5821 /** 5822 * Creates a stream from the given input sequence around matches of this 5823 * pattern. 5824 * 5825 * <p> The stream returned by this method contains each substring of the 5826 * input sequence that is terminated by another subsequence that matches 5827 * this pattern or is terminated by the end of the input sequence. The 5828 * substrings in the stream are in the order in which they occur in the 5829 * input. Trailing empty strings will be discarded and not encountered in 5830 * the stream. 5831 * 5832 * <p> If this pattern does not match any subsequence of the input then 5833 * the resulting stream has just one element, namely the input sequence in 5834 * string form. 5835 * 5836 * <p> When there is a positive-width match at the beginning of the input 5837 * sequence then an empty leading substring is included at the beginning 5838 * of the stream. A zero-width match at the beginning however never produces 5839 * such empty leading substring. 5840 * 5841 * <p> If the input sequence is mutable, it must remain constant during the | 5802 } 5803 5804 /** 5805 * This must be the very first initializer. 5806 */ 5807 static final Node accept = new Node(); 5808 5809 static final Node lastAccept = new LastNode(); 5810 5811 /** 5812 * Creates a predicate which can be used to match a string. 5813 * 5814 * @return The predicate which can be used for matching on a string 5815 * @since 1.8 5816 */ 5817 public Predicate<String> asPredicate() { 5818 return s -> matcher(s).find(); 5819 } 5820 5821 /** 5822 * Creates a predicate that tests if a given input string argument, an input sequence, 5823 * matches this pattern. 5824 * 5825 * @apiNote 5826 * This method creates a predicate that behaves as if it creates a matcher from the 5827 * input sequence and then calls {@code matches}, for example a 5828 * predicate of the form: 5829 * <pre>{@code 5830 * s -> matcher(s).matches(); 5831 * }</pre> 5832 * 5833 * @return The predicate which can be used for finding if an input string matches this pattern. 5834 * @since 11 5835 */ 5836 public Predicate<String> asMatchPredicate() { 5837 return s -> matcher(s).matches(); 5838 } 5839 /** 5840 * Creates a stream from the given input sequence around matches of this 5841 * pattern. 5842 * 5843 * <p> The stream returned by this method contains each substring of the 5844 * input sequence that is terminated by another subsequence that matches 5845 * this pattern or is terminated by the end of the input sequence. The 5846 * substrings in the stream are in the order in which they occur in the 5847 * input. Trailing empty strings will be discarded and not encountered in 5848 * the stream. 5849 * 5850 * <p> If this pattern does not match any subsequence of the input then 5851 * the resulting stream has just one element, namely the input sequence in 5852 * string form. 5853 * 5854 * <p> When there is a positive-width match at the beginning of the input 5855 * sequence then an empty leading substring is included at the beginning 5856 * of the stream. A zero-width match at the beginning however never produces 5857 * such empty leading substring. 5858 * 5859 * <p> If the input sequence is mutable, it must remain constant during the |