001 /*
002 * Created on Jul 14, 2008
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
005 * the License. You may obtain a copy of the License at
006 *
007 * http://www.apache.org/licenses/LICENSE-2.0
008 *
009 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
010 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
011 * specific language governing permissions and limitations under the License.
012 *
013 * Copyright @2008-2010 the original author or authors.
014 */
015 package org.fest.swing.launcher;
016
017 /**
018 * Understands a fluent interface for creation of applet parameters.
019 * <p>
020 * For example, the following code listing:
021 *
022 * <pre>
023 * // import static org.fest.swing.launcher.AppletParameter.name;
024 *
025 * AppletParameter = {@link #name(String) name}("bgcolor").{@link AppletParameterBuilder#value(String) value}("blue");
026 * </pre>
027 *
028 * will create an applet parameter with name "bgcolor" and value "blue."
029 * </p>
030 *
031 * @author Yvonne Wang
032 */
033 public class AppletParameter {
034
035 public final String name;
036 public final String value;
037
038 AppletParameter(String name, String value) {
039 this.name = name;
040 this.value = value;
041 }
042
043 /**
044 * Starting point of the fluent interface for creation of <code>{@link AppletParameter}</code>s.
045 * @param name the name of the applet parameter.
046 * @return a builder of <code>AppletParameter</code>s.
047 */
048 public static AppletParameterBuilder name(String name) {
049 return new AppletParameterBuilder(name);
050 }
051
052 /**
053 * Understands creation of <code>{@link AppletParameter}</code>s.
054 *
055 * @author Yvonne Wang
056 */
057 public static class AppletParameterBuilder {
058
059 private final String name;
060
061 AppletParameterBuilder(String name) {
062 this.name = name;
063 }
064
065 /**
066 * Creates a new <code>{@link AppletParameter}</code> with the given name and value.
067 * @param value the value for the <code>AppletParameter</code>.
068 * @return the created <code>AppletParameter</code>.
069 */
070 public AppletParameter value(String value) {
071 return new AppletParameter(name, value);
072 }
073 }
074 }