aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/store-query/src/main/java/tools/refinery/store/query/dnf/FunctionalDependency.java
blob: f4cd109f72215a1c6a801296b5c006078302c21c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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));
		}
	}
}