Skip to content

Commit

Permalink
#28 Adapt Chronograph for Passage Operator
Browse files Browse the repository at this point in the history
Remove BrickAdapter

Signed-off-by: Alexander Fedorov <[email protected]>
  • Loading branch information
ruspl-afed committed May 16, 2020
1 parent c149a83 commit 05f4e14
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 45 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -31,27 +31,27 @@
public class BrickContentProviderImpl<I, D> implements BrickContentProvider<I> {

private final BrickBuilder<List<I>, D> builder;
private final BrickAdapter<D, Brick> adapter;

public BrickContentProviderImpl(BrickBuilder<List<I>, D> brickBuilder, BrickAdapter<D, Brick> brickAdapter) {
private final Function<List<D>, List<Brick>> adapter;

public BrickContentProviderImpl(BrickBuilder<List<I>, D> brickBuilder,
Function<List<D>, List<Brick>> brickAdapter) {
this.builder = brickBuilder;
this.adapter = brickAdapter;
}

@Override
public List<Brick> getBricksByGroup(List<I> input, Group group) {
return adapter.adapt(builder.applyGroup(input, group.id()));
return adapter.apply(builder.applyGroup(input, group.id()));
}

@Override
public List<Brick> getBricksBySubGroup(List<I> 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<Brick> getBricks(List<I> input) {
return adapter.adapt(builder.apply(input));
return adapter.apply(builder.apply(input));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -48,7 +48,7 @@
public class BrickProvidersTest {
private List<TestInputObject> input = new ArrayList<>();
private BrickBuilder<List<TestInputObject>, TestInputObject> testBrickBuilder;
private BrickAdapter<TestInputObject, Brick> testBrickAdapter;
private Function<List<TestInputObject>, List<Brick>> testBrickAdapter;
private BrickContentProviderImpl<TestInputObject, TestInputObject> testBrickProvider;

@Before
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<TestInputObject, Brick> {
public class TestBrickAdapter implements Function<List<TestInputObject>, List<Brick>> {

@Override
public List<Brick> adapt(List<TestInputObject> inputObjects) {
public List<Brick> apply(List<TestInputObject> inputObjects) {
Map<TestInputObject, Brick> objectsToBricks = new HashMap<>();

List<Brick> bricks = inputObjects.stream()
Expand Down

0 comments on commit 05f4e14

Please sign in to comment.