001/* 002 * Copyright (c) 2012-2018 Institut National des Sciences Appliquées de Lyon (INSA Lyon) and others 003 * 004 * This program and the accompanying materials are made available under the 005 * terms of the Eclipse Public License 2.0 which is available at 006 * http://www.eclipse.org/legal/epl-2.0. 007 * 008 * SPDX-License-Identifier: EPL-2.0 009 */ 010 011package gololang; 012 013/** 014 * Base class for Golo union objects. 015 * <p> 016 * This class defines common behavior. 017 */ 018public abstract class Union { 019 /** 020 * Array conversion. 021 * 022 * @return an array containing the values (in member orders) 023 */ 024 public Object[] toArray() { 025 return new Object[]{}; 026 } 027 028 /** 029 * Destructuration helper. 030 * 031 * @return a tuple with the current values. 032 */ 033 public Tuple destruct() { 034 return Tuple.fromArray(toArray()); 035 } 036}