/**
  * Returns a {@code char} matcher functionally equivalent to this one, but which may be faster to
  * query than the original; your mileage may vary. Precomputation takes time and is likely to be
  * worthwhile only if the precomputed matcher is queried many thousands of times.
  *
  * <p>This method has no effect (returns {@code this}) when called in GWT: it's unclear whether a
  * precomputed matcher is faster, but it certainly consumes more memory, which doesn't seem like a
  * worthwhile tradeoff in a browser.
  */
 public CharMatcher precomputed() {
   return Platform.precomputeCharMatcher(this);
 }
Ejemplo n.º 2
0
 /**
  * Returns an optional enum constant for the given type, using {@link Enum#valueOf}. If the
  * constant does not exist, {@link Optional#absent} is returned. A common use case is for parsing
  * user input or falling back to a default enum constant. For example, {@code
  * Enums.getIfPresent(Country.class, countryInput).or(Country.DEFAULT);}
  *
  * @since 12.0
  */
 public static <T extends Enum<T>> Optional<T> getIfPresent(Class<T> enumClass, String value) {
   checkNotNull(enumClass);
   checkNotNull(value);
   return Platform.getEnumIfPresent(enumClass, value);
 }