Example usage for java.util Optional toString

List of usage examples for java.util Optional toString

Introduction

In this page you can find the example usage for java.util Optional toString.

Prototype

@Override
public String toString() 

Source Link

Document

Returns a non-empty string representation of this Optional suitable for debugging.

Usage

From source file:edu.jhu.hlt.concrete.stanford.ConcreteStanfordRunner.java

public static void prepareInputOutput(Path in, Path out) throws IOException {
    if (!Files.exists(in))
        throw new IOException(in.toString() + " does not exist. Ensure it exists and re-run this program.");

    Optional<Path> outPath = Optional.ofNullable(out.getParent());
    outPath.ifPresent(p -> {//from   ww  w  . j  a v a 2s  .co  m
        if (!Files.exists(p)) {
            LOGGER.debug("Attempting to create output directory: {}", outPath.toString());
            try {
                Files.createDirectories(p);
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
        }
    });
}

From source file:org.jimsey.projects.turbine.furnace.service.ProducerManager.java

@ManagedOperation
public String showProducers() {
    Optional<String> result = producers.stream().map(TickProducer::toString)
            .reduce((p1, p2) -> String.format("%s,%s", p1, p2));
    return result.toString();
}

From source file:ddf.catalog.validation.impl.validator.RelationshipValidator.java

@Override
public void validate(Metacard metacard) throws ValidationException {
    Optional<MetacardValidationReport> report = validateMetacard(metacard);
    if (report.isPresent() && !report.get().getAttributeValidationViolations().isEmpty()) {
        List<String> errors = report.get().getAttributeValidationViolations().stream()
                .filter(v -> v.getSeverity() == ValidationViolation.Severity.ERROR)
                .map(ValidationViolation::getMessage).collect(Collectors.toList());
        errors.addAll(report.get().getMetacardValidationViolations().stream()
                .filter(v -> v.getSeverity() == ValidationViolation.Severity.ERROR)
                .map(ValidationViolation::getMessage).collect(Collectors.toList()));
        List<String> warnings = report.get().getAttributeValidationViolations().stream()
                .filter(v -> v.getSeverity() == ValidationViolation.Severity.WARNING)
                .map(ValidationViolation::getMessage).collect(Collectors.toList());
        errors.addAll(report.get().getMetacardValidationViolations().stream()
                .filter(v -> v.getSeverity() == ValidationViolation.Severity.WARNING)
                .map(ValidationViolation::getMessage).collect(Collectors.toList()));
        throw new ValidationExceptionImpl(report.toString(), errors, warnings);
    }//  w ww.  ja va  2s .c o m
}

From source file:org.onosproject.cpman.impl.MetricsAggregator.java

/**
 * Base method of the constructor of this class.
 *
 * @param metricsService metrics service reference
 * @param type           control metric type
 * @param deviceId       device identification
 * @param resourceName   resource name/*from  w w w.  j av  a 2s .  co m*/
 */
private void init(MetricsService metricsService, ControlMetricType type, Optional<DeviceId> deviceId,
        String resourceName) {
    String primitiveName = type.toString();
    String objName = "all";
    if (deviceId.isPresent()) {
        objName = deviceId.toString();
    }

    if (StringUtils.isNotEmpty(resourceName)) {
        objName = resourceName;
    }

    checkNotNull(primitiveName, "Component name cannot be null");
    checkNotNull(objName, "Feature name cannot be null");

    this.metricsType = type;

    this.metricsService = metricsService;
    this.metricsComponent = metricsService.registerComponent(primitiveName);
    this.metricsFeature = metricsComponent.registerFeature(objName);

    this.rateMeter = metricsService.createMeter(metricsComponent, metricsFeature, RATE_NAME);
    this.countMeter = metricsService.createMeter(metricsComponent, metricsFeature, COUNT_NAME);
}