/** * 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; } }
return new HostSpecifier(InetAddresses.toUriString(addr)); return new HostSpecifier(domain.toString());
private void conditionallyCheckSSH() { if (vm.getPassword() != null && !loginCredentials.getOptionalPassword().isPresent()) loginCredentials = loginCredentials.toBuilder().password(vm.getPassword()).build(); assert HostSpecifier.isValid(vm.getIPAddress()); if (!InetAddresses2.isPrivateIPAddress(vm.getIPAddress())) { // not sure if the network is public or not, so we have to test HostAndPort socket = HostAndPort.fromParts(vm.getIPAddress(), 22); System.err.printf("testing socket %s%n", socket); System.err.printf("testing ssh %s%n", socket); checkSSH(socket); } else { System.err.printf("skipping ssh %s, as private%n", vm.getIPAddress()); } }
/** * Returns a {@link HostSpecifier} instance representing the specified {@link String} {@literal value}. * * @param value The configuration parameter's {@link String} value * @return An {@link HostSpecifier} instance representing the configuration parameter's value */ @Override public HostSpecifier convertFrom(String value) { final HostSpecifier result; try { result = HostSpecifier.from(value); } catch (Exception ex) { throw new ParameterException("Couldn't convert value \"" + value + "\" to HostSpecifier.", ex); } return result; }
private void conditionallyCheckSSH() { if (vm.getPassword() != null && loginCredentials.getOptionalPassword() == null) loginCredentials = loginCredentials.toBuilder().password(vm.getPassword()).build(); assert HostSpecifier.isValid(vm.getIPAddress()); if (!InetAddresses2.isPrivateIPAddress(vm.getIPAddress())) { // not sure if the network is public or not, so we have to test HostAndPort socket = HostAndPort.fromParts(vm.getIPAddress(), 22); System.err.printf("testing socket %s%n", socket); System.err.printf("testing ssh %s%n", socket); checkSSH(socket); } else { System.err.printf("skipping ssh %s, as private%n", vm.getIPAddress()); } }
/** * 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; } }
return new HostSpecifier(InetAddresses.toUriString(addr)); return new HostSpecifier(domain.toString());
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; } }
return new HostSpecifier(InetAddresses.toUriString(addr)); return new HostSpecifier(domain.toString());
private static HostSpecifier spec(String specifier) { return HostSpecifier.fromValid(specifier); }
return new HostSpecifier(InetAddresses.toUriString(addr)); return new HostSpecifier(domain.name());
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.getCause()).isInstanceOf(IllegalArgumentException.class); } assertFalse(HostSpecifier.isValid(spec)); }
/** * 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; } }
return new HostSpecifier(InetAddresses.toUriString(addr)); return new HostSpecifier(domain.name());
/** * 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; } }
return new HostSpecifier(InetAddresses.toUriString(addr)); return new HostSpecifier(domain.toString());
/** * 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; } }