Option.java revision 953:221a84ef44c0
12116Sjkh/* 22116Sjkh * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 32116Sjkh * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 42116Sjkh * 52116Sjkh * This code is free software; you can redistribute it and/or modify it 62116Sjkh * under the terms of the GNU General Public License version 2 only, as 72116Sjkh * published by the Free Software Foundation. Oracle designates this 82116Sjkh * particular file as subject to the "Classpath" exception as provided 92116Sjkh * by Oracle in the LICENSE file that accompanied this code. 102116Sjkh * 118870Srgrimes * This code is distributed in the hope that it will be useful, but WITHOUT 122116Sjkh * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 132116Sjkh * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 142116Sjkh * version 2 for more details (a copy is included in the LICENSE file that 152116Sjkh * accompanied this code). 16176451Sdas * 17176451Sdas * You should have received a copy of the GNU General Public License version 182116Sjkh * 2 along with this work; if not, write to the Free Software Foundation, 192116Sjkh * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 202116Sjkh * 212116Sjkh * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 228870Srgrimes * or visit www.oracle.com if you need additional information or have any 232116Sjkh * questions. 242116Sjkh */ 252116Sjkh 26181100Sdaspackage jdk.nashorn.internal.runtime.options; 27181100Sdas 28181100Sdas/** 29181100Sdas * This is an option class that at its most primitive level just wraps a 302116Sjkh * boolean or String. However, it is conceivable that the option, when set 31181100Sdas * should run some initializations (for example, the logger system) or carry 32181100Sdas * some other kind of payload, arrays, Collections, etc. In that case, this 33181100Sdas * should be subclassed 3497407Salfred * 3597407Salfred * @param <T> option value type, for example a boolean or something more complex 362116Sjkh */ 37181100Sdaspublic class Option<T> { 38181405Sdas /** the option value */ 392116Sjkh protected T value; 402116Sjkh 412116Sjkh Option(final T value) { 42181257Sdas this.value = value; 43181257Sdas } 44181257Sdas 458870Srgrimes /** 462116Sjkh * Return the value of an option 47181257Sdas * @return the option value 482116Sjkh */ 49181257Sdas public T getValue() { 50181257Sdas return value; 51181257Sdas } 52181257Sdas 53181257Sdas @Override 54181257Sdas public String toString() { 552116Sjkh return getValue() + " [" + getValue().getClass() + "]"; 562116Sjkh } 572116Sjkh} 582116Sjkh