aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/logic/src/main/java/tools/refinery/logic/literal/AbstractLiteral.java
blob: 79100e406476db23dfc2ae196952fe545142219d (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
24
25
26
27
28
29
30
31
32
33
34
/*
 * SPDX-FileCopyrightText: 2023 The Refinery Authors <https://refinery.tools/>
 *
 * SPDX-License-Identifier: EPL-2.0
 */
package tools.refinery.logic.literal;

import tools.refinery.logic.equality.LiteralEqualityHelper;
import tools.refinery.logic.equality.LiteralHashCodeHelper;

public abstract class AbstractLiteral implements Literal {
	@Override
	public boolean equalsWithSubstitution(LiteralEqualityHelper helper, Literal other) {
		return other != null && getClass() == other.getClass();
	}

	@Override
	public int hashCodeWithSubstitution(LiteralHashCodeHelper helper) {
		return getClass().hashCode();
	}

	@Override
	public boolean equals(Object o) {
		if (this == o) return true;
		if (o == null || getClass() != o.getClass()) return false;
		AbstractLiteral that = (AbstractLiteral) o;
		return equalsWithSubstitution(LiteralEqualityHelper.DEFAULT, that);
	}

	@Override
	public int hashCode() {
		return hashCodeWithSubstitution(LiteralHashCodeHelper.DEFAULT);
	}
}