Parameter of orElse() is evaluated, even when having a non-empty Optional.

Supplier method of orElseGet passed as an argument is only executed when an Optional value isn’t present.

Therefore, using orElseGet() will save computing time.

Noncompliant Code Example

Optional.of("ecoCode").orElse(getUnpredictedMethod());

Compliant Code Example

Optional.of("ecoCode").orElseGet(() -> getUnpredictedMethod());
randomClass.orElse(getUnpredictedMethod());