public final String stringValue() { if (!hasDefinedValue()) { throw new IllegalArgumentException(); } return value().asString(); }
public final String stringValue(String defaultValue) { if (!hasDefinedValue()) { return defaultValue; } return value().asString(); }
public final List<Boolean> booleanListValue(List<Boolean> defaultValue) { return hasDefinedValue() ? booleanListValue() : defaultValue; }
public final List<String> stringListValue(List<String> defaultValue) { return hasDefinedValue() ? stringListValue() : defaultValue; }
public final List<Double> doubleListValue(List<Double> defaultValue) { return hasDefinedValue() ? doubleListValue() : defaultValue; }
public final List<Integer> intListValue(List<Integer> defaultValue) { return hasDefinedValue() ? intListValue() : defaultValue; }
public final List<Long> longListValue(List<Long> defaultValue) { return hasDefinedValue() ? longListValue() : defaultValue; }
public final double doubleValue() { if (!hasDefinedValue()) { throw new IllegalArgumentException(); } return value().asDouble(); }
public final double doubleValue(double defaultValue) { if (!hasDefinedValue()) { return defaultValue; } return value().asDouble(); }
public final void assertDefinedValue(String message) { assertSuccess(message); message = adjustAssertMessage(message); if (!hasDefinedValue()) { throw new AssertionError(message + "Expected defined 'result', but it's missing: " + this.asString()); } }
private boolean areServersRunning(String host, List<String> servers) throws IOException { Address hostAddress = Address.host(host); if (servers == null || servers.isEmpty()) { ModelNodeResult result = ops.readAttribute(Address.host(host), Constants.HOST_STATE); result.assertDefinedValue(); return ServerState.isRunning(result.stringValue()); } else { for (String server : servers) { Address serverAddress = hostAddress.and(Constants.SERVER, server); ModelNodeResult result = ops.readAttribute(serverAddress, Constants.SERVER_STATE); if (!result.hasDefinedValue() || !ServerState.isRunning(result.stringValue())) { return false; } } return true; } } }
/** * @return {@code true} if the resource specified by {@code address} exists, {@code false} otherwise * @throws OperationException if the underlying {@code read-resource} operation fails */ public boolean exists(Address address) throws IOException, OperationException { FailuresAllowedBlock expectedFailures = client.allowFailures(); try { ModelNodeResult result = readResource(address); if (result.isSuccess()) { return result.hasDefinedValue(); // should always be true } if (isResultUnknownOrNotFound(result)) { return false; } throw new OperationException("exists failed: " + result.asString()); } finally { expectedFailures.close(); } }