diff options
author | 2021-08-16 04:18:33 +0200 | |
---|---|---|
committer | 2021-08-16 04:18:33 +0200 | |
commit | 621d95c1ba61dc9714b30a79e6bc1b4f52c8b108 (patch) | |
tree | 6096cf1e405388f21523c74ecceeb264236e111d /model-data | |
parent | :lipstick: (diff) | |
download | refinery-621d95c1ba61dc9714b30a79e6bc1b4f52c8b108.tar.gz refinery-621d95c1ba61dc9714b30a79e6bc1b4f52c8b108.tar.zst refinery-621d95c1ba61dc9714b30a79e6bc1b4f52c8b108.zip |
Update on relationalViews constructor visibility
Diffstat (limited to 'model-data')
3 files changed, 13 insertions, 4 deletions
diff --git a/model-data/src/main/java/org/eclipse/viatra/solver/data/query/view/FilteredRelationView.java b/model-data/src/main/java/org/eclipse/viatra/solver/data/query/view/FilteredRelationView.java index 9f71f8cf..4602af21 100644 --- a/model-data/src/main/java/org/eclipse/viatra/solver/data/query/view/FilteredRelationView.java +++ b/model-data/src/main/java/org/eclipse/viatra/solver/data/query/view/FilteredRelationView.java | |||
@@ -1,14 +1,18 @@ | |||
1 | package org.eclipse.viatra.solver.data.query.view; | 1 | package org.eclipse.viatra.solver.data.query.view; |
2 | 2 | ||
3 | import java.util.function.BiPredicate; | ||
4 | |||
3 | import org.eclipse.viatra.solver.data.model.Model; | 5 | import org.eclipse.viatra.solver.data.model.Model; |
4 | import org.eclipse.viatra.solver.data.model.Tuple; | 6 | import org.eclipse.viatra.solver.data.model.Tuple; |
5 | import org.eclipse.viatra.solver.data.model.Tuple.Tuple1; | 7 | import org.eclipse.viatra.solver.data.model.Tuple.Tuple1; |
6 | import org.eclipse.viatra.solver.data.model.representation.Relation; | 8 | import org.eclipse.viatra.solver.data.model.representation.Relation; |
7 | 9 | ||
8 | public abstract class FilteredRelationView<D> extends RelationView<D>{ | 10 | public class FilteredRelationView<D> extends RelationView<D>{ |
11 | private final BiPredicate<Tuple,D> predicate; | ||
9 | 12 | ||
10 | protected FilteredRelationView(Model model, Relation<D> representation) { | 13 | public FilteredRelationView(Model model, Relation<D> representation, BiPredicate<Tuple,D> predicate) { |
11 | super(model, representation); | 14 | super(model, representation); |
15 | this.predicate = predicate; | ||
12 | } | 16 | } |
13 | @Override | 17 | @Override |
14 | protected Object[] forwardMap(Tuple key, D value) { | 18 | protected Object[] forwardMap(Tuple key, D value) { |
@@ -37,4 +41,8 @@ public abstract class FilteredRelationView<D> extends RelationView<D>{ | |||
37 | public int getArity() { | 41 | public int getArity() { |
38 | return this.representation.getArity(); | 42 | return this.representation.getArity(); |
39 | } | 43 | } |
44 | @Override | ||
45 | protected boolean filter(Tuple key, D value) { | ||
46 | return this.predicate.test(key, value); | ||
47 | } | ||
40 | } | 48 | } |
diff --git a/model-data/src/main/java/org/eclipse/viatra/solver/data/query/view/FunctionalRelationView.java b/model-data/src/main/java/org/eclipse/viatra/solver/data/query/view/FunctionalRelationView.java index ee52972c..b8d0ef72 100644 --- a/model-data/src/main/java/org/eclipse/viatra/solver/data/query/view/FunctionalRelationView.java +++ b/model-data/src/main/java/org/eclipse/viatra/solver/data/query/view/FunctionalRelationView.java | |||
@@ -7,7 +7,7 @@ import org.eclipse.viatra.solver.data.model.representation.Relation; | |||
7 | 7 | ||
8 | public class FunctionalRelationView<D> extends RelationView<D> { | 8 | public class FunctionalRelationView<D> extends RelationView<D> { |
9 | 9 | ||
10 | protected FunctionalRelationView(Model model, Relation<D> representation) { | 10 | public FunctionalRelationView(Model model, Relation<D> representation) { |
11 | super(model, representation); | 11 | super(model, representation); |
12 | } | 12 | } |
13 | 13 | ||
diff --git a/model-data/src/main/java/org/eclipse/viatra/solver/data/query/view/RelationView.java b/model-data/src/main/java/org/eclipse/viatra/solver/data/query/view/RelationView.java index efd8e990..18d2692d 100644 --- a/model-data/src/main/java/org/eclipse/viatra/solver/data/query/view/RelationView.java +++ b/model-data/src/main/java/org/eclipse/viatra/solver/data/query/view/RelationView.java | |||
@@ -15,11 +15,12 @@ import org.eclipse.viatra.solver.data.query.internal.RelationViewKey; | |||
15 | public abstract class RelationView<D>{ | 15 | public abstract class RelationView<D>{ |
16 | protected final Model model; | 16 | protected final Model model; |
17 | protected final Relation<D> representation; | 17 | protected final Relation<D> representation; |
18 | RelationViewKey<D> key = new RelationViewKey<>(this, getArity()); | 18 | private final RelationViewKey<D> key; |
19 | 19 | ||
20 | protected RelationView(Model model, Relation<D> representation) { | 20 | protected RelationView(Model model, Relation<D> representation) { |
21 | this.model = model; | 21 | this.model = model; |
22 | this.representation = representation; | 22 | this.representation = representation; |
23 | key = new RelationViewKey<>(this, getArity()); | ||
23 | } | 24 | } |
24 | 25 | ||
25 | public Model getModel() { | 26 | public Model getModel() { |