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 013/** 014 * A literal reference to a function. 015 * 016 * <p>Used to represent a literal function reference notation, such as 017 * {@code ^my.package::foo} 018 */ 019public final class FunctionRef { 020 021 private final String module; 022 private final String name; 023 private final int arity; 024 private final boolean varargs; 025 026 private FunctionRef(String module, String name, int arity, boolean varargs) { 027 this.module = module; 028 this.name = name; 029 this.arity = arity; 030 this.varargs = varargs; 031 } 032 033 public static FunctionRef of(String module, String name, int arity, boolean varargs) { 034 return new FunctionRef(module, name, arity, varargs); 035 } 036 037 public String module() { return this.module; } 038 public String name() { return this.name; } 039 public int arity() { return this.arity; } 040 public boolean varargs() { return this.varargs; } 041 042 @Override 043 public String toString() { 044 return String.format("FunctionRef{module=%s,name=%s,arity=%s%s}", 045 module, name, arity, (varargs ? ",varargs" : "")); 046 } 047}