Skip to content

Commit 8c028c3

Browse files
christophstroblodrotbohm
authored andcommitted
DATACMNS-1059 - Alter QuerydslPredicateExecutor.findOne(…) to return Optional<T>.
We now return Optional<T> for QuerydslPredicateExecutor.findOne(Predicate) aligning the return type to the ones used in CrudRepository. Original pull request: #215.
1 parent 0e36b43 commit 8c028c3

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/main/java/org/springframework/data/querydsl/QuerydslPredicateExecutor.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2011-2015 the original author or authors.
2+
* Copyright 2011-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,6 +15,8 @@
1515
*/
1616
package org.springframework.data.querydsl;
1717

18+
import java.util.Optional;
19+
1820
import org.springframework.data.domain.Page;
1921
import org.springframework.data.domain.Pageable;
2022
import org.springframework.data.domain.Sort;
@@ -27,18 +29,19 @@
2729
*
2830
* @author Oliver Gierke
2931
* @author Thomas Darimont
32+
* @author Christoph Strobl
3033
*/
3134
public interface QuerydslPredicateExecutor<T> {
3235

3336
/**
34-
* Returns a single entity matching the given {@link Predicate} or {@literal null} if none was found.
35-
*
37+
* Returns a single entity matching the given {@link Predicate} or {@link Optional#empty()} if none was found.
38+
*
3639
* @param predicate can be {@literal null}.
37-
* @return a single entity matching the given {@link Predicate} or {@literal null} if none was found.
40+
* @return a single entity matching the given {@link Predicate} or {@link Optional#empty()} if none was found.
3841
* @throws org.springframework.dao.IncorrectResultSizeDataAccessException if the predicate yields more than one
3942
* result.
4043
*/
41-
T findOne(Predicate predicate);
44+
Optional<T> findOne(Predicate predicate);
4245

4346
/**
4447
* Returns all entities matching the given {@link Predicate}. In case no match could be found an empty

0 commit comments

Comments
 (0)