diff --git a/bundles/org.eclipse.chronograph.api/src/org/eclipse/chronograph/internal/api/Data.java b/bundles/org.eclipse.chronograph.api/src/org/eclipse/chronograph/internal/api/Data.java new file mode 100644 index 0000000..e7d8c64 --- /dev/null +++ b/bundles/org.eclipse.chronograph.api/src/org/eclipse/chronograph/internal/api/Data.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2020 ArSysOp + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * https://www.eclipse.org/legal/epl-2.0/. + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * ArSysOp - initial API and implementation + *******************************************************************************/ +package org.eclipse.chronograph.internal.api; + +import java.util.List; +import java.util.function.Predicate; + +/** + * + * Encapsulates the storage of objects to be displayed + * + */ +public interface Data { + + /** + * + * @param predicate the predicate to filter the bricks + * @return + */ + List query(Predicate predicate); + +} diff --git a/bundles/org.eclipse.chronograph.base/src/org/eclipse/chronograph/internal/base/DataRegistry.java b/bundles/org.eclipse.chronograph.base/src/org/eclipse/chronograph/internal/base/PlainData.java similarity index 92% rename from bundles/org.eclipse.chronograph.base/src/org/eclipse/chronograph/internal/base/DataRegistry.java rename to bundles/org.eclipse.chronograph.base/src/org/eclipse/chronograph/internal/base/PlainData.java index 20dc0b1..f8e821a 100644 --- a/bundles/org.eclipse.chronograph.base/src/org/eclipse/chronograph/internal/base/DataRegistry.java +++ b/bundles/org.eclipse.chronograph.base/src/org/eclipse/chronograph/internal/base/PlainData.java @@ -19,9 +19,11 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.function.Predicate; import java.util.stream.Collectors; import org.eclipse.chronograph.internal.api.Brick; +import org.eclipse.chronograph.internal.api.Data; import org.eclipse.chronograph.internal.api.Group; import org.eclipse.chronograph.internal.api.Section; import org.eclipse.chronograph.internal.api.providers.BrickContentProvider; @@ -34,8 +36,7 @@ * Class intended to aggregate data * */ -//FIXME extract interface -public class DataRegistry { +public class PlainData implements Data { private final ContainerProvider provider; private final Map sectionsById = new HashMap<>(); @@ -43,7 +44,7 @@ public class DataRegistry { private final Map> subGroupsBygroup = new HashMap<>(); private final Map> bricksBySubgroup = new HashMap<>(); - public DataRegistry(ContainerProvider provider) { + public PlainData(ContainerProvider provider) { this.provider = provider; } @@ -133,4 +134,12 @@ public List getBricks() { .flatMap(List::stream) // .collect(Collectors.toList()); } + + @Override + public List query(Predicate predicate) { + return bricksBySubgroup.values().stream() // + .flatMap(List::stream) // + .filter(predicate) // + .collect(Collectors.toList()); + } }