001/* 002 * Copyright (c) 2012-2021 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 013public abstract class GoloStatement<T extends GoloStatement<T>> extends GoloElement<T> { 014 015 /** 016 * Statement coercion. 017 * 018 * <p>If the given value is an statement, cast it. If it's {@code null} returns a {@code Noop}. 019 */ 020 public static GoloStatement<?> of(Object statement) { 021 if (statement == null) { return Noop.of("null statement"); } 022 if (statement instanceof GoloStatement) { 023 return (GoloStatement) statement; 024 } 025 throw cantConvert("GoloStatement", statement); 026 } 027}