diff options
Diffstat (limited to 'subprojects/viatra-runtime-matchers/src/main/java/tools/refinery/viatra/runtime/matchers/util/SingletonInstanceProvider.java')
-rw-r--r-- | subprojects/viatra-runtime-matchers/src/main/java/tools/refinery/viatra/runtime/matchers/util/SingletonInstanceProvider.java | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/subprojects/viatra-runtime-matchers/src/main/java/tools/refinery/viatra/runtime/matchers/util/SingletonInstanceProvider.java b/subprojects/viatra-runtime-matchers/src/main/java/tools/refinery/viatra/runtime/matchers/util/SingletonInstanceProvider.java new file mode 100644 index 00000000..cc5963f7 --- /dev/null +++ b/subprojects/viatra-runtime-matchers/src/main/java/tools/refinery/viatra/runtime/matchers/util/SingletonInstanceProvider.java | |||
@@ -0,0 +1,29 @@ | |||
1 | /******************************************************************************* | ||
2 | * Copyright (c) 2010-2015, Zoltan Ujhelyi, Istvan Rath and Daniel Varro | ||
3 | * This program and the accompanying materials are made available under the | ||
4 | * terms of the Eclipse Public License v. 2.0 which is available at | ||
5 | * http://www.eclipse.org/legal/epl-v20.html. | ||
6 | * | ||
7 | * SPDX-License-Identifier: EPL-2.0 | ||
8 | *******************************************************************************/ | ||
9 | package tools.refinery.viatra.runtime.matchers.util; | ||
10 | |||
11 | /** | ||
12 | * A provider implementation that always returns the same object instance. | ||
13 | * @author Zoltan Ujhelyi | ||
14 | */ | ||
15 | public class SingletonInstanceProvider<T> implements IProvider<T>{ | ||
16 | |||
17 | private T instance; | ||
18 | |||
19 | public SingletonInstanceProvider(T instance) { | ||
20 | Preconditions.checkArgument(instance != null, "Instance parameter must not be null."); | ||
21 | this.instance = instance; | ||
22 | } | ||
23 | |||
24 | @Override | ||
25 | public T get() { | ||
26 | return instance; | ||
27 | } | ||
28 | |||
29 | } \ No newline at end of file | ||