001package org.clafer.ontology; 002 003import java.util.HashMap; 004import java.util.Map; 005import org.clafer.domain.Domain; 006import org.clafer.domain.Domains; 007 008/** 009 * 010 * @author jimmy 011 */ 012public class ConstraintDatabase { 013 014 protected final Map<Path, Domain> assignments = new HashMap<>(); 015 protected final Relation<Path> equalities = new Relation<>(); 016 protected final Relation<Path> localEqualities = new Relation<>(); 017 018 public void newAssignment(Path path, int value) { 019 newAssignment(path, Domains.constantDomain(value)); 020 } 021 022 public ConstraintDatabase newAssignment(Path path, Domain value) { 023 assignments.merge(path, value, Domain::intersection); 024 return this; 025 } 026 027 public ConstraintDatabase newEquality(Path path1, Path path2) { 028 equalities.add(path1, path2); 029 equalities.add(path2, path1); 030 return this; 031 } 032 033 public ConstraintDatabase newLocalEquality(Path path1, Path path2) { 034 localEqualities.add(path1, path2); 035 localEqualities.add(path2, path1); 036 return this; 037 } 038}