001/* 002 * Copyright (c) 2012-2017 Institut National des Sciences Appliquées de Lyon (INSA-Lyon) 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the Eclipse Public License v1.0 006 * which accompanies this distribution, and is available at 007 * http://www.eclipse.org/legal/epl-v10.html 008 */ 009 010package org.eclipse.golo.runtime; 011 012import java.util.Arrays; 013 014import static gololang.Messages.warning; 015import static gololang.Messages.message; 016import static org.eclipse.golo.cli.command.Metadata.GUIDE_BASE; 017 018/** 019 * A static class to deal with several kinds of warnings. 020 * <p> 021 */ 022public final class Warnings { 023 private Warnings() { 024 // utility class 025 } 026 027 private static final boolean NO_PARAMETER_NAMES = load("golo.warnings.no-parameter-names", "true"); 028 private static final boolean UNAVAILABLE_CLASS = load("golo.warnings.unavailable-class", "false"); 029 030 private static boolean load(String property, String def) { 031 return Boolean.valueOf(System.getProperty(property, def)); 032 } 033 034 public static void noParameterNames(String methodName, String[] argumentNames) { 035 if (NO_PARAMETER_NAMES) { 036 warning(message("no_parameter_names", methodName, Arrays.toString(argumentNames), GUIDE_BASE)); 037 } 038 } 039 040 public static void unavailableClass(String className, String callerModule) { 041 if (UNAVAILABLE_CLASS && !className.startsWith("java.lang") && !className.startsWith("gololang")) { 042 warning(message("unavailable_class", className, callerModule, GUIDE_BASE)); 043 } 044 } 045}