mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 15:35:49 +01:00
Use optionals for get by name and namespace
This commit is contained in:
@@ -41,6 +41,7 @@ import sonia.scm.TypeManager;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Optional;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
@@ -148,11 +149,10 @@ public interface RepositoryManager
|
||||
@Override
|
||||
public RepositoryHandler getHandler(String type);
|
||||
|
||||
default Repository getByNamespace(String namespace, String name) {
|
||||
default Optional<Repository> getByNamespace(String namespace, String name) {
|
||||
return getAll()
|
||||
.stream()
|
||||
.filter(r -> r.getName().equals(name) && r.getNamespace().equals(namespace))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
.findFirst();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user