From 05f4e14a369dc94d0addd45bbc85ba32487d6e60 Mon Sep 17 00:00:00 2001 From: Alexander Fedorov Date: Sat, 16 May 2020 10:26:20 +0300 Subject: [PATCH] #28 Adapt Chronograph for Passage Operator Remove BrickAdapter Signed-off-by: Alexander Fedorov --- .../internal/api/adapters/BrickAdapter.java | 33 ------------------- .../providers/BrickContentProviderImpl.java | 14 ++++---- .../api/brick/test/BrickProvidersTest.java | 4 +-- .../api/brick/test/TestBrickAdapter.java | 5 ++- 4 files changed, 11 insertions(+), 45 deletions(-) delete mode 100644 bundles/org.eclipse.chronograph.api/src/org/eclipse/chronograph/internal/api/adapters/BrickAdapter.java diff --git a/bundles/org.eclipse.chronograph.api/src/org/eclipse/chronograph/internal/api/adapters/BrickAdapter.java b/bundles/org.eclipse.chronograph.api/src/org/eclipse/chronograph/internal/api/adapters/BrickAdapter.java deleted file mode 100644 index 1d70cb1..0000000 --- a/bundles/org.eclipse.chronograph.api/src/org/eclipse/chronograph/internal/api/adapters/BrickAdapter.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * 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 - * http://www.eclipse.org/legal/epl-2.0. - * - * SPDX-License-Identifier: EPL-2.0 - * - * Contributors: - * Sergei Kovalchuk - initial API and implementation - * - *******************************************************************************/ -package org.eclipse.chronograph.internal.api.adapters; - -import java.util.List; - -import org.eclipse.chronograph.internal.api.Brick; -import org.eclipse.chronograph.internal.api.Group; - -/** - * Intended for adapt input objects to {@link Brick} object for defined - * {@link Group} container. - * - * - * @param - type of input objects - * @param - type of adapted objects - */ -public interface BrickAdapter { - - public List adapt(List inputObjects); - -} diff --git a/bundles/org.eclipse.chronograph.base/src/org/eclipse/chronograph/internal/providers/BrickContentProviderImpl.java b/bundles/org.eclipse.chronograph.base/src/org/eclipse/chronograph/internal/providers/BrickContentProviderImpl.java index 37b938d..5503b03 100644 --- a/bundles/org.eclipse.chronograph.base/src/org/eclipse/chronograph/internal/providers/BrickContentProviderImpl.java +++ b/bundles/org.eclipse.chronograph.base/src/org/eclipse/chronograph/internal/providers/BrickContentProviderImpl.java @@ -14,10 +14,10 @@ package org.eclipse.chronograph.internal.providers; import java.util.List; +import java.util.function.Function; import org.eclipse.chronograph.internal.api.Brick; import org.eclipse.chronograph.internal.api.Group; -import org.eclipse.chronograph.internal.api.adapters.BrickAdapter; import org.eclipse.chronograph.internal.api.builders.BrickBuilder; import org.eclipse.chronograph.internal.api.providers.BrickContentProvider; @@ -31,27 +31,27 @@ public class BrickContentProviderImpl implements BrickContentProvider { private final BrickBuilder, D> builder; - private final BrickAdapter adapter; - - public BrickContentProviderImpl(BrickBuilder, D> brickBuilder, BrickAdapter brickAdapter) { + private final Function, List> adapter; + public BrickContentProviderImpl(BrickBuilder, D> brickBuilder, + Function, List> brickAdapter) { this.builder = brickBuilder; this.adapter = brickAdapter; } @Override public List getBricksByGroup(List input, Group group) { - return adapter.adapt(builder.applyGroup(input, group.id())); + return adapter.apply(builder.applyGroup(input, group.id())); } @Override public List getBricksBySubGroup(List input, String groupId, Group subGroup) { - return adapter.adapt(builder.applySubGroup(input, groupId, subGroup.id())); + return adapter.apply(builder.applySubGroup(input, groupId, subGroup.id())); } @Override public List getBricks(List input) { - return adapter.adapt(builder.apply(input)); + return adapter.apply(builder.apply(input)); } } diff --git a/tests/org.eclipse.chronograph.api.tests/src/org/eclipse/chronograph/api/brick/test/BrickProvidersTest.java b/tests/org.eclipse.chronograph.api.tests/src/org/eclipse/chronograph/api/brick/test/BrickProvidersTest.java index 716c94e..235f457 100644 --- a/tests/org.eclipse.chronograph.api.tests/src/org/eclipse/chronograph/api/brick/test/BrickProvidersTest.java +++ b/tests/org.eclipse.chronograph.api.tests/src/org/eclipse/chronograph/api/brick/test/BrickProvidersTest.java @@ -25,13 +25,13 @@ import java.util.ArrayList; import java.util.List; +import java.util.function.Function; import org.eclipse.chronograph.api.test.TestInputObject; import org.eclipse.chronograph.api.test.TestInputObjects; import org.eclipse.chronograph.internal.api.Brick; import org.eclipse.chronograph.internal.api.Group; import org.eclipse.chronograph.internal.api.Section; -import org.eclipse.chronograph.internal.api.adapters.BrickAdapter; import org.eclipse.chronograph.internal.api.builders.BrickBuilder; import org.eclipse.chronograph.internal.base.GroupImpl; import org.eclipse.chronograph.internal.base.SectionImpl; @@ -48,7 +48,7 @@ public class BrickProvidersTest { private List input = new ArrayList<>(); private BrickBuilder, TestInputObject> testBrickBuilder; - private BrickAdapter testBrickAdapter; + private Function, List> testBrickAdapter; private BrickContentProviderImpl testBrickProvider; @Before diff --git a/tests/org.eclipse.chronograph.api.tests/src/org/eclipse/chronograph/api/brick/test/TestBrickAdapter.java b/tests/org.eclipse.chronograph.api.tests/src/org/eclipse/chronograph/api/brick/test/TestBrickAdapter.java index 7cb2e2f..74b435e 100644 --- a/tests/org.eclipse.chronograph.api.tests/src/org/eclipse/chronograph/api/brick/test/TestBrickAdapter.java +++ b/tests/org.eclipse.chronograph.api.tests/src/org/eclipse/chronograph/api/brick/test/TestBrickAdapter.java @@ -28,13 +28,12 @@ import org.eclipse.chronograph.api.test.TestInputObject; import org.eclipse.chronograph.internal.api.Brick; -import org.eclipse.chronograph.internal.api.adapters.BrickAdapter; import org.eclipse.chronograph.internal.base.BrickImpl; -public class TestBrickAdapter implements BrickAdapter { +public class TestBrickAdapter implements Function, List> { @Override - public List adapt(List inputObjects) { + public List apply(List inputObjects) { Map objectsToBricks = new HashMap<>(); List bricks = inputObjects.stream()