/** * Gets the version of the object at the time of the failed command. * * {@include.example io.sphere.sdk.errors.SphereExceptionIntegrationTest#concurrentModification()} * * @return version or null */ @Nullable public Long getCurrentVersion() { final List<? extends SphereError> errors = getErrors(); return ObjectUtils.defaultIfNull(errors, Collections.emptyList()).stream() .map(errror -> (SphereError) errror) .filter(error -> ConcurrentModificationError.CODE.equals(error.getCode())) .map(error -> error.as(ConcurrentModificationError.class).getCurrentVersion()) .findFirst() .orElse(null); } }