Skip to content

Commit

Permalink
#28 Adapt Chronograph for Passage Operator
Browse files Browse the repository at this point in the history
Rename knowledge about parent from Brick

Signed-off-by: Alexander Fedorov <[email protected]>
  • Loading branch information
ruspl-afed committed May 16, 2020
1 parent 95d9747 commit c149a83
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@ public interface Brick {
*/
String id();

/**
*
* @return BrickContainer as a parent element
*/
BrickContainer container();

/**
*
* @return original Brick position
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@
*/
public interface BrickAdapter<T, S> {

public List<S> adapt(List<T> inputObjects, Group container);
public List<S> adapt(List<T> inputObjects);

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,15 @@
package org.eclipse.chronograph.internal.base;

import org.eclipse.chronograph.internal.api.Brick;
import org.eclipse.chronograph.internal.api.BrickContainer;
import org.eclipse.chronograph.internal.api.Position;

public class BrickImpl implements Brick {

private final String id;
private final Position position;
private final BrickContainer parent;

public BrickImpl(BrickContainer parent, String id, int start, int end) {
public BrickImpl(String id, int start, int end) {
this.id = id;
this.parent = parent;
this.position = new PositionImpl(start, end);
}

Expand All @@ -34,11 +31,6 @@ public String id() {
return this.id;
}

@Override
public BrickContainer container() {
return parent;
}

@Override
public Position position() {
return position;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@ public BrickContentProviderImpl(BrickBuilder<List<I>, D> brickBuilder, BrickAdap

@Override
public List<Brick> getBricksByGroup(List<I> input, Group group) {
return adapter.adapt(builder.applyGroup(input, group.id()), group);
return adapter.adapt(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()), subGroup);
return adapter.adapt(builder.applySubGroup(input, groupId, subGroup.id()));
}

@Override
public List<Brick> getBricks(List<I> input) {
return adapter.adapt(builder.apply(input), null);
return adapter.adapt(builder.apply(input));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,20 @@

import org.eclipse.chronograph.api.test.TestInputObject;
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.base.BrickImpl;

public class TestBrickAdapter implements BrickAdapter<TestInputObject, Brick> {

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

List<Brick> bricks = inputObjects.stream()
.map(p -> objectsToBricks.computeIfAbsent(p, new Function<TestInputObject, Brick>() {
@Override
public Brick apply(TestInputObject t) {
Brick brick = new BrickImpl(container, t.id, t.start, t.end);
Brick brick = new BrickImpl(t.id, t.start, t.end);
return brick;
}
})).collect(Collectors.toList());
Expand Down

0 comments on commit c149a83

Please sign in to comment.