aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/store-query/src/main/java/tools/refinery/store/query/view/RelationViewImplication.java
blob: 2ba1fcc4feea9703d3f2bc08416d490610055910 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package tools.refinery.store.query.view;

import java.util.List;

public record RelationViewImplication(AnyRelationView implyingRelationView, AnyRelationView impliedRelationView,
									  List<Integer> impliedIndices) {
	public RelationViewImplication {
		if (impliedIndices.size() != impliedRelationView.arity()) {
			throw new IllegalArgumentException("Expected %d implied indices for %s, but %d are provided"
					.formatted(impliedRelationView.arity(), impliedRelationView, impliedIndices.size()));
		}
		for (var index : impliedIndices) {
			if (impliedRelationView.invalidIndex(index)) {
				throw new IllegalArgumentException("%d is not a valid index for %s".formatted(index,
						implyingRelationView));
			}
		}
	}
}