Example usage for java.util OptionalDouble orElse

List of usage examples for java.util OptionalDouble orElse

Introduction

In this page you can find the example usage for java.util OptionalDouble orElse.

Prototype

public double orElse(double other) 

Source Link

Document

If a value is present, returns the value, otherwise returns other .

Usage

From source file:com.devnexus.ting.model.CfpSubmission.java

public Double getRating() {
    final List<Integer> ratings = new ArrayList<>();

    for (CfpSubmissionReview review : this.cfpSubmissionReviews) {
        ratings.add(review.getRating());
    }/*  w w w.  ja v a2 s .  com*/

    OptionalDouble averageRating = ratings.stream().mapToDouble(a -> a).average();

    return averageRating.orElse(0d);
}