diff options
Diffstat (limited to 'subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/extensibility/PQueryExtensionFactory.java')
-rw-r--r-- | subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/extensibility/PQueryExtensionFactory.java | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/extensibility/PQueryExtensionFactory.java b/subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/extensibility/PQueryExtensionFactory.java new file mode 100644 index 00000000..91e087d7 --- /dev/null +++ b/subprojects/viatra-runtime/src/main/java/tools/refinery/viatra/runtime/extensibility/PQueryExtensionFactory.java | |||
@@ -0,0 +1,33 @@ | |||
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.extensibility; | ||
10 | |||
11 | import org.eclipse.core.runtime.CoreException; | ||
12 | import org.eclipse.core.runtime.IStatus; | ||
13 | import org.eclipse.core.runtime.Status; | ||
14 | import tools.refinery.viatra.runtime.api.IQuerySpecification; | ||
15 | |||
16 | /** | ||
17 | * An extension factory to access PQuery instances from Query Specifications. | ||
18 | * | ||
19 | * @author Zoltan Ujhelyi | ||
20 | * | ||
21 | */ | ||
22 | public class PQueryExtensionFactory extends SingletonExtensionFactory { | ||
23 | |||
24 | @Override | ||
25 | public Object create() throws CoreException { | ||
26 | final Object _spec = super.create(); | ||
27 | if (_spec instanceof IQuerySpecification<?>) { | ||
28 | return ((IQuerySpecification<?>) _spec).getInternalQueryRepresentation(); | ||
29 | } | ||
30 | throw new CoreException(new Status(IStatus.ERROR, getBundle().getSymbolicName(), "Cannot instantiate PQuery instance.")); | ||
31 | } | ||
32 | |||
33 | } | ||