aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/store/src/main/java/tools/refinery/store/tuple/Tuple0.java
blob: 5f525798c484e8cd4c444a03755f5fb4dcda0c49 (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
35
36
37
38
39
40
/*
 * SPDX-FileCopyrightText: 2021-2023 The Refinery Authors <https://refinery.tools/>
 *
 * SPDX-License-Identifier: EPL-2.0
 */
package tools.refinery.store.tuple;

import static tools.refinery.store.tuple.TupleConstants.TUPLE_BEGIN;
import static tools.refinery.store.tuple.TupleConstants.TUPLE_END;

/**
 * Singleton implementation to ensure only a single empty tuple exists.
 */
@SuppressWarnings("squid:S6548")
public final class Tuple0 implements Tuple {
	public static final Tuple0 INSTANCE = new Tuple0();

	private Tuple0() {
	}

	@Override
	public int getSize() {
		return 0;
	}

	@Override
	public int get(int element) {
		throw new IndexOutOfBoundsException(element);
	}

	@Override
	public Tuple set(int element, int value) {
		throw new IndexOutOfBoundsException(element);
	}

	@Override
	public String toString() {
		return TUPLE_BEGIN + TUPLE_END;
	}
}