mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Streams friendly API
This commit is contained in:
@@ -6,6 +6,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public interface ExtensionPoint<T> {
|
||||
@NotNull
|
||||
@@ -26,6 +27,9 @@ public interface ExtensionPoint<T> {
|
||||
@NotNull
|
||||
List<T> getExtensionList();
|
||||
|
||||
@NotNull
|
||||
Stream<T> extensions();
|
||||
|
||||
boolean hasAnyExtensions();
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public final class ExtensionPointName<T> extends BaseExtensionPointName {
|
||||
public ExtensionPointName(@NotNull String name) {
|
||||
@@ -31,6 +32,11 @@ public final class ExtensionPointName<T> extends BaseExtensionPointName {
|
||||
return getExtensionList(null);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Stream<T> extensions() {
|
||||
return extensions(null);
|
||||
}
|
||||
|
||||
public boolean hasAnyExtensions() {
|
||||
return getPoint(null).hasAnyExtensions();
|
||||
}
|
||||
@@ -45,6 +51,11 @@ public final class ExtensionPointName<T> extends BaseExtensionPointName {
|
||||
return getPoint(areaInstance).getExtensions();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Stream<T> extensions(@Nullable AreaInstance areaInstance) {
|
||||
return getPoint(areaInstance).extensions();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ExtensionPoint<T> getPoint(@Nullable AreaInstance areaInstance) {
|
||||
return Extensions.getArea(areaInstance).getExtensionPoint(getName());
|
||||
|
||||
@@ -17,6 +17,7 @@ import org.jetbrains.annotations.TestOnly;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.*;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* @author AKireyev
|
||||
@@ -203,6 +204,12 @@ public final class ExtensionPointImpl<T> implements ExtensionPoint<T> {
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Stream<T> extensions() {
|
||||
return getExtensionList().stream();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAnyExtensions() {
|
||||
final List<T> cache = myExtensionsCache;
|
||||
|
||||
Reference in New Issue
Block a user