Skip to content

Commit 3830236

Browse files
committed
Make Mediator getter protected
1 parent d7e04ea commit 3830236

File tree

8 files changed

+40
-46
lines changed

8 files changed

+40
-46
lines changed

mvvm4fx-core/src/main/java/com/techsenger/mvvm4fx/core/AbstractChildViewModel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public AbstractChildViewModel() {
2727
}
2828

2929
@Override
30-
public ChildMediator getMediator() {
30+
protected ChildMediator getMediator() {
3131
return (ChildMediator) super.getMediator();
3232
}
3333
}

mvvm4fx-core/src/main/java/com/techsenger/mvvm4fx/core/AbstractComponentViewModel.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ public abstract class AbstractComponentViewModel implements ComponentViewModel {
3333

3434
private ComponentMediator mediator;
3535

36-
@Override
37-
public ComponentMediator getMediator() {
36+
protected ComponentMediator getMediator() {
3837
return this.mediator;
3938
}
4039

mvvm4fx-core/src/main/java/com/techsenger/mvvm4fx/core/AbstractParentComponent.java

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -48,29 +48,6 @@ public Mediator() {
4848
public ObservableList<ChildViewModel> getChildren() {
4949
return children;
5050
}
51-
52-
53-
@Override
54-
public SubtreeIterator<ParentViewModel> depthFirstIterator() {
55-
return new AbstractDepthFirstIterator<ParentViewModel>(getView().getViewModel()) {
56-
57-
@Override
58-
List<ParentViewModel> getChildren(ParentViewModel parent) {
59-
return (List) parent.getMediator().getChildren();
60-
}
61-
};
62-
}
63-
64-
@Override
65-
public SubtreeIterator<ParentViewModel> breadthFirstIterator() {
66-
return new AbstractBreadthFirstIterator<ParentViewModel>(getView().getViewModel()) {
67-
68-
@Override
69-
List<ParentViewModel> getChildren(ParentViewModel parent) {
70-
return (List) parent.getMediator().getChildren();
71-
}
72-
};
73-
}
7451
}
7552

7653
private final ObservableList<ChildComponent<?>> modifiableChildren = FXCollections.observableArrayList();

mvvm4fx-core/src/main/java/com/techsenger/mvvm4fx/core/AbstractParentViewModel.java

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package com.techsenger.mvvm4fx.core;
1818

19+
import java.util.List;
20+
1921
/**
2022
*
2123
* @author Pavel Castornii
@@ -27,7 +29,29 @@ public AbstractParentViewModel() {
2729
}
2830

2931
@Override
30-
public ParentMediator getMediator() {
32+
public SubtreeIterator<ParentViewModel> depthFirstIterator() {
33+
return new AbstractDepthFirstIterator<ParentViewModel>(this) {
34+
35+
@Override
36+
List<ParentViewModel> getChildren(ParentViewModel parent) {
37+
return (List) getMediator().getChildren();
38+
}
39+
};
40+
}
41+
42+
@Override
43+
public SubtreeIterator<ParentViewModel> breadthFirstIterator() {
44+
return new AbstractBreadthFirstIterator<ParentViewModel>(this) {
45+
46+
@Override
47+
List<ParentViewModel> getChildren(ParentViewModel parent) {
48+
return (List) getMediator().getChildren();
49+
}
50+
};
51+
}
52+
53+
@Override
54+
protected ParentMediator getMediator() {
3155
return (ParentMediator) super.getMediator();
3256
}
3357
}

mvvm4fx-core/src/main/java/com/techsenger/mvvm4fx/core/ChildViewModel.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,4 @@
2222
*/
2323
public interface ChildViewModel extends ParentViewModel {
2424

25-
@Override
26-
ChildMediator getMediator();
2725
}

mvvm4fx-core/src/main/java/com/techsenger/mvvm4fx/core/ComponentViewModel.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,4 @@
2222
*/
2323
public interface ComponentViewModel {
2424

25-
ComponentMediator getMediator();
2625
}

mvvm4fx-core/src/main/java/com/techsenger/mvvm4fx/core/ParentMediator.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,4 @@ public interface ParentMediator extends ComponentMediator {
3030
* @return a non-null, unmodifiable observable list of child ViewModels
3131
*/
3232
ObservableList<ChildViewModel> getChildren();
33-
34-
/**
35-
* Returns an iterator that traverses the component subtree starting from this component in depth-first order.
36-
*
37-
* @return an {@link Iterator} that iterates over this component and all of its descendants
38-
*/
39-
SubtreeIterator<ParentViewModel> depthFirstIterator();
40-
41-
/**
42-
* Returns an iterator that traverses the component subtree starting from this component in breadth-first order.
43-
*
44-
* @return an {@link Iterator} that iterates over this component and all of its descendants
45-
*/
46-
SubtreeIterator<ParentViewModel> breadthFirstIterator();
4733
}

mvvm4fx-core/src/main/java/com/techsenger/mvvm4fx/core/ParentViewModel.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@
2222
*/
2323
public interface ParentViewModel extends ComponentViewModel {
2424

25-
@Override
26-
ParentMediator getMediator();
25+
/**
26+
* Returns an iterator that traverses the component subtree starting from this component in depth-first order.
27+
*
28+
* @return an {@link Iterator} that iterates over this component and all of its descendants
29+
*/
30+
SubtreeIterator<ParentViewModel> depthFirstIterator();
31+
32+
/**
33+
* Returns an iterator that traverses the component subtree starting from this component in breadth-first order.
34+
*
35+
* @return an {@link Iterator} that iterates over this component and all of its descendants
36+
*/
37+
SubtreeIterator<ParentViewModel> breadthFirstIterator();
2738
}

0 commit comments

Comments
 (0)