aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/store-query/src/main/java/tools/refinery/store/query/view/ViewImplication.java
blob: fc2db9f2e3f21f3baad104e55420c502b7fc4c91 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/*
 * SPDX-FileCopyrightText: 2021-2023 The Refinery Authors <https://refinery.tools/>
 *
 * SPDX-License-Identifier: EPL-2.0
 */
package tools.refinery.store.query.view;

import java.util.List;

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