All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.juneau.svl.VarList Maven / Gradle / Ivy

// ***************************************************************************************************************************
// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *
// * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file        *
// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance            *
// * with the License.  You may obtain a copy of the License at                                                              *
// *                                                                                                                         *
// *  http://www.apache.org/licenses/LICENSE-2.0                                                                             *
// *                                                                                                                         *
// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an  *
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the        *
// * specific language governing permissions and limitations under the License.                                              *
// ***************************************************************************************************************************
package org.apache.juneau.svl;

import static org.apache.juneau.internal.CollectionUtils.*;

import java.util.*;

import org.apache.juneau.svl.vars.*;

/**
 * Simple list of variables that can consist of either variable classes or instances.
 *
 * 
See Also:
* * @serial exclude */ public class VarList extends ArrayList { private static final long serialVersionUID = 1L; /** * Returns an empty list of variables. * * @return A new empty list of variables. */ public static VarList create() { return new VarList(); } /** * Creates a new list of variables. * * @param vars The variables to create. * @return A new list of variables. */ public static VarList of(Var...vars) { return create().append(vars); } /** * Creates a new list of variables. * * @param vars The variables to create. * @return A new list of variables. */ @SafeVarargs public static final VarList of(Class...vars) { return create().append(vars); } /** * Constructor. */ protected VarList() { } /** * Copy constructor. * * @param copyFrom The list to copy. */ protected VarList(VarList copyFrom) { super(copyFrom); } /** * Adds a list of variables to this list. * * @param vars The variables to append to this list. * @return This object. */ public VarList append(Var...vars) { addAll(alist(vars)); return this; } /** * Adds a list of variables to this list. * * @param vars The variables to append to this list. * @return This object. */ public VarList append(VarList vars) { addAll(vars); return this; } /** * Adds a list of variables to this list. * * @param vars The variables to append to this list. * @return This object. */ @SafeVarargs public final VarList append(Class...vars) { addAll(alist(vars)); return this; } /** * Adds the default variables to this list. * *

* The default variables are: *

    *
  • {@link SystemPropertiesVar} *
  • {@link EnvVariablesVar} *
  • {@link ArgsVar} *
  • {@link ManifestFileVar} *
  • {@link SwitchVar} *
  • {@link IfVar} *
  • {@link CoalesceVar} *
  • {@link PatternMatchVar} *
  • {@link PatternReplaceVar} *
  • {@link PatternExtractVar} *
  • {@link UpperCaseVar} *
  • {@link LowerCaseVar} *
  • {@link NotEmptyVar} *
  • {@link LenVar} *
  • {@link SubstringVar} *
* * @return This object. */ public VarList addDefault() { return append( SystemPropertiesVar.class, EnvVariablesVar.class, ManifestFileVar.class, ArgsVar.class, SwitchVar.class, IfVar.class, CoalesceVar.class, PatternMatchVar.class, PatternReplaceVar.class, PatternExtractVar.class, UpperCaseVar.class, LowerCaseVar.class, NotEmptyVar.class, LenVar.class, SubstringVar.class ); } /** * Makes a copy of this list. * * @return A new copy of this list. */ public VarList copy() { return new VarList(this); } }