MCPcopy
hub / github.com/google/guava / from

Method from

guava/src/com/google/common/net/HostSpecifier.java:113–126  ·  view source on GitHub ↗

Attempts to return a {@code HostSpecifier} for the given string, throwing an exception if parsing fails. Always use this method in preference to {@link #fromValid(String)} for a specifier that is not already known to be valid. @throws ParseException if the specifier is not valid.

(String specifier)

Source from the content-addressed store, hash-verified

111 * @throws ParseException if the specifier is not valid.
112 */
113 @CanIgnoreReturnValue // TODO(b/219820829): consider removing
114 public static HostSpecifier from(String specifier) throws ParseException {
115 try {
116 return fromValid(specifier);
117 } catch (IllegalArgumentException e) {
118 // Since the IAE can originate at several different points inside
119 // fromValid(), we implement this method in terms of that one rather
120 // than the reverse.
121
122 ParseException parseException = new ParseException("Invalid host specifier: " + specifier, 0);
123 parseException.initCause(e);
124 throw parseException;
125 }
126 }
127
128 /**
129 * Determines whether {@code specifier} represents a valid {@link HostSpecifier} as described in

Callers 2

assertGoodMethod · 0.95
assertBadMethod · 0.95

Calls 1

fromValidMethod · 0.95

Tested by 2

assertGoodMethod · 0.76
assertBadMethod · 0.76