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

import java.util.HashSet;
import java.util.Set;

public record FunctionalDependency<T>(Set<T> forEach, Set<T> unique) {
	public FunctionalDependency {
		var uniqueForEach = new HashSet<>(unique);
		uniqueForEach.retainAll(forEach);
		if (!uniqueForEach.isEmpty()) {
			throw new IllegalArgumentException("Variables %s appear on both sides of the functional dependency"
					.formatted(uniqueForEach));
		}
	}
}