]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/VariableOrResource.java
Merge "Fixed ProfileObserver.update race with multiple query threads"
[simantics/platform.git] / bundles / org.simantics.db.layer0 / src / org / simantics / db / layer0 / variable / VariableOrResource.java
1 /*******************************************************************************
2  * Copyright (c) 2019 Association for Decentralized Information Management
3  * in Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     Semantum Oy - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.db.layer0.variable;
13
14 import org.simantics.db.Resource;
15
16 /**
17  * An interface to match the VariableOrResource SCL data type
18  * which represents either a Resource or a Variable. Allows
19  * defining SCL classes with either of the two as a input.
20  *
21  * @author Antti Villberg
22  * @since 1.40.0
23  */
24 public interface VariableOrResource {
25
26     public static VariableOrResource make(Resource value) {
27         return new ResourceX(value);
28     }
29     
30     public static VariableOrResource make(Variable value) {
31         return new VariableX(value);
32     }
33
34     public static VariableOrResource make(Object value) {
35         if(value instanceof Resource)
36             return make((Resource)value);
37         if(value instanceof Variable)
38             return make((Variable)value);
39         throw new IllegalArgumentException("VariableOrResource acccepts only Variable or Resource, got " + value + " with class " + value.getClass().getName());
40     }
41
42 }