1 /*******************************************************************************
2 * Copyright (c) 2019 Association for Decentralized Information Management
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
10 * Semantum Oy - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.db.layer0.variable;
14 import org.simantics.db.Resource;
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.
21 * @author Antti Villberg
24 public interface VariableOrResource {
26 public static VariableOrResource make(Resource value) {
27 return new ResourceX(value);
30 public static VariableOrResource make(Variable value) {
31 return new VariableX(value);
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());