/** * Determines whether {@code specifier} represents a valid {@link HostSpecifier} as described in * the documentation for {@link #fromValid(String)}. */ public static boolean isValid(String specifier) { try { fromValid(specifier); return true; } catch (IllegalArgumentException e) { return false; } }
/** * Determines whether {@code specifier} represents a valid {@link HostSpecifier} as described in * the documentation for {@link #fromValid(String)}. */ public static boolean isValid(String specifier) { try { fromValid(specifier); return true; } catch (IllegalArgumentException e) { return false; } }
/** * Determines whether {@code specifier} represents a valid {@link HostSpecifier} as described in * the documentation for {@link #fromValid(String)}. */ public static boolean isValid(String specifier) { try { fromValid(specifier); return true; } catch (IllegalArgumentException e) { return false; } }
private static HostSpecifier spec(String specifier) { return HostSpecifier.fromValid(specifier); }
/** * 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. */ public static HostSpecifier from(String specifier) throws ParseException { try { return fromValid(specifier); } catch (IllegalArgumentException e) { // Since the IAE can originate at several different points inside // fromValid(), we implement this method in terms of that one rather // than the reverse. ParseException parseException = new ParseException("Invalid host specifier: " + specifier, 0); parseException.initCause(e); throw parseException; } }
/** * 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. */ public static HostSpecifier from(String specifier) throws ParseException { try { return fromValid(specifier); } catch (IllegalArgumentException e) { // Since the IAE can originate at several different points inside // fromValid(), we implement this method in terms of that one rather // than the reverse. ParseException parseException = new ParseException("Invalid host specifier: " + specifier, 0); parseException.initCause(e); throw parseException; } }
/** * 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. */ public static HostSpecifier from(String specifier) throws ParseException { try { return fromValid(specifier); } catch (IllegalArgumentException e) { // Since the IAE can originate at several different points inside // fromValid(), we implement this method in terms of that one rather // than the reverse. ParseException parseException = new ParseException("Invalid host specifier: " + specifier, 0); parseException.initCause(e); throw parseException; } }
public void testNulls() { final NullPointerTester tester = new NullPointerTester(); tester.testAllPublicStaticMethods(HostSpecifier.class); tester.testAllPublicInstanceMethods(HostSpecifier.fromValid("google.com")); }
private void assertGood(String spec) throws ParseException { HostSpecifier.fromValid(spec); // Throws exception if not working correctly HostSpecifier.from(spec); assertTrue(HostSpecifier.isValid(spec)); }
private void assertBad(String spec) { try { HostSpecifier.fromValid(spec); fail("Should have thrown IllegalArgumentException: " + spec); } catch (IllegalArgumentException expected) { } try { HostSpecifier.from(spec); fail("Should have thrown ParseException: " + spec); } catch (ParseException expected) { assertThat(expected).hasCauseThat().isInstanceOf(IllegalArgumentException.class); } assertFalse(HostSpecifier.isValid(spec)); } }
/** * Determines whether {@code specifier} represents a valid {@link HostSpecifier} as described in * the documentation for {@link #fromValid(String)}. */ public static boolean isValid(String specifier) { try { fromValid(specifier); return true; } catch (IllegalArgumentException e) { return false; } }
/** * Determines whether {@code specifier} represents a valid {@link HostSpecifier} as described in * the documentation for {@link #fromValid(String)}. */ public static boolean isValid(String specifier) { try { fromValid(specifier); return true; } catch (IllegalArgumentException e) { return false; } }
/** * Determines whether {@code specifier} represents a valid * {@link HostSpecifier} as described in the documentation for * {@link #fromValid(String)}. */ public static boolean isValid(String specifier) { try { fromValid(specifier); return true; } catch (IllegalArgumentException e) { return false; } }
/** * Determines whether {@code specifier} represents a valid * {@link HostSpecifier} as described in the documentation for * {@link #fromValid(String)}. */ public static boolean isValid(String specifier) { try { fromValid(specifier); return true; } catch (IllegalArgumentException e) { return false; } }
/** * Determines whether {@code specifier} represents a valid * {@link HostSpecifier} as described in the documentation for * {@link #fromValid(String)}. */ public static boolean isValid(String specifier) { try { fromValid(specifier); return true; } catch (IllegalArgumentException e) { return false; } }
/** * Determines whether {@code specifier} represents a valid * {@link HostSpecifier} as described in the documentation for * {@link #fromValid(String)}. */ public static boolean isValid(String specifier) { try { fromValid(specifier); return true; } catch (IllegalArgumentException e) { return false; } }
/** * Determines whether {@code specifier} represents a valid * {@link HostSpecifier} as described in the documentation for * {@link #fromValid(String)}. */ public static boolean isValid(String specifier) { try { fromValid(specifier); return true; } catch (IllegalArgumentException e) { return false; } }
/** * Determines whether {@code specifier} represents a valid * {@link HostSpecifier} as described in the documentation for * {@link #fromValid(String)}. */ public static boolean isValid(String specifier) { try { fromValid(specifier); return true; } catch (IllegalArgumentException e) { return false; } }
public void testNulls() { final NullPointerTester tester = new NullPointerTester(); tester.testAllPublicStaticMethods(HostSpecifier.class); tester.testAllPublicInstanceMethods(HostSpecifier.fromValid("google.com")); }
private void assertGood(String spec) throws ParseException { HostSpecifier.fromValid(spec); // Throws exception if not working correctly HostSpecifier.from(spec); assertTrue(HostSpecifier.isValid(spec)); }