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.ir; 012 013import org.eclipse.golo.compiler.PackageAndClass; 014 015public final class UnionValue extends TypeWithMembers<UnionValue> { 016 017 public UnionValue(String name) { 018 super(name); 019 } 020 021 protected UnionValue self() { return this; } 022 023 /** 024 * {@inheritDoc} 025 */ 026 @Override 027 public PackageAndClass getPackageAndClass() { 028 Union u = ancestorOfType(Union.class); 029 if (u == null) { 030 return PackageAndClass.of(getName()); 031 } 032 return u.getPackageAndClass().createInnerClass(getName()); 033 } 034 035 public Union getUnion() { 036 return ancestorOfType(Union.class); 037 } 038 039 protected String getFactoryDelegateName() { 040 return getUnion().getPackageAndClass().toString() + "." + getName(); 041 } 042 043 /** 044 * {@inheritDoc} 045 */ 046 @Override 047 public void accept(GoloIrVisitor visitor) { 048 visitor.visitUnionValue(this); 049 } 050} 051