com.cisco.oss.foundation.configuration.validation.params.ParamSetFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of configuration-api Show documentation
Show all versions of configuration-api Show documentation
This project is the api library for configuration in the cisco vss foundation runtime
/*
* Copyright 2014 Cisco Systems, Inc.
*
* Licensed 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 com.cisco.oss.foundation.configuration.validation.params;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import static com.cisco.oss.foundation.configuration.validation.params.ParamReaders.*;
import static com.cisco.oss.foundation.configuration.validation.params.ParamValidators.*;
/**
* Created By: kgreen
* Date-Time: 11/6/13 6:00 PM
*/
public class ParamSetFactory extends ParamFactory {
protected ParamSetFactory(ParamType paramType) {
super(paramType);
}
//==================================================================================================================
private Set toSet (T value) {
return toSet(toList(value));
}
private Set toSet (T ... values) {
return toSet(toList(values));
}
private Set toSet (List list) {
if (list == null) {
return null;
}
return new LinkedHashSet(list);
}
//==================================================================================================================
public Param> asString (String name) {
return getParam(stringSetReader, name);
}
public Param> asString (String name, String defValue) {
return getParam(stringSetReader, name, toSet(defValue));
}
public Param> asString (String name, String[] defValue) {
return getParam(stringSetReader, name, toSet(defValue));
}
public Param> asString (String name, String defValue, ParamValidator validator) {
return getParam(stringSetReader, name, toSet(defValue), getListValidator(validator));
}
public Param> asString (String name, String[] defValue, ParamValidator validator) {
return getParam(stringSetReader, name, toSet(defValue), getListValidator(validator));
}
//==================================================================================================================
public Param> asInt (String name) {
return getParam(intSetReader, name);
}
public Param> asInt (String name, Integer defValue) {
return getParam(intSetReader, name, toSet(defValue));
}
public Param> asInt (String name, Integer[] defValue) {
return getParam(intSetReader, name, toSet(defValue));
}
public Param> asInt (String name, Integer defValue, ParamValidator validator) {
return getParam(intSetReader, name, toSet(defValue), getListValidator(validator));
}
public Param> asInt (String name, Integer[] defValue, ParamValidator validator) {
return getParam(intSetReader, name, toSet(defValue), getListValidator(validator));
}
//==================================================================================================================
public Param> asLong (String name) {
return getParam(longSetReader, name);
}
public Param> asLong (String name, Long defValue) {
return getParam(longSetReader, name, toSet(defValue));
}
public Param> asLong (String name, Long[] defValue) {
return getParam(longSetReader, name, toSet(defValue));
}
public Param> asLong (String name, Long defValue, ParamValidator validator) {
return getParam(longSetReader, name, toSet(defValue), getListValidator(validator));
}
public Param> asLong (String name, Long[] defValue, ParamValidator validator) {
return getParam(longSetReader, name, toSet(defValue), getListValidator(validator));
}
//==================================================================================================================
public Param> asBool (String name) {
return getParam(booleanSetReader, name);
}
public Param> asBool (String name, Boolean defValue) {
return getParam(booleanSetReader, name, toSet(defValue));
}
public Param> asBool (String name, Boolean[] defValue) {
return getParam(booleanSetReader, name, toSet(defValue));
}
public Param> asBool (String name, Boolean defValue, ParamValidator validator) {
return getParam(booleanSetReader, name, toSet(defValue), getListValidator(validator));
}
public Param> asBool (String name, Boolean[] defValue, ParamValidator validator) {
return getParam(booleanSetReader, name, toSet(defValue), getListValidator(validator));
}
//==================================================================================================================
public Param> asFloat (String name) {
return getParam(floatSetReader, name);
}
public Param> asFloat (String name, Float defValue) {
return getParam(floatSetReader, name, toSet(defValue));
}
public Param> asFloat (String name, Float[] defValue) {
return getParam(floatSetReader, name, toSet(defValue));
}
public Param> asFloat (String name, Float defValue, ParamValidator validator) {
return getParam(floatSetReader, name, toSet(defValue), getListValidator(validator));
}
public Param> asFloat (String name, Float[] defValue, ParamValidator validator) {
return getParam(floatSetReader, name, toSet(defValue), getListValidator(validator));
}
//==================================================================================================================
public Param> asDouble (String name) {
return getParam(doubleSetReader, name);
}
public Param> asDouble (String name, Double defValue) {
return getParam(doubleSetReader, name, toSet(defValue));
}
public Param> asDouble (String name, Double[] defValue) {
return getParam(doubleSetReader, name, toSet(defValue));
}
public Param> asDouble (String name, Double defValue, ParamValidator validator) {
return getParam(doubleSetReader, name, toSet(defValue), getListValidator(validator));
}
public Param> asDouble (String name, Double[] defValue, ParamValidator validator) {
return getParam(doubleSetReader, name, toSet(defValue), getListValidator(validator));
}
//==================================================================================================================
public Param> asShort (String name) {
return getParam(shortSetReader, name);
}
public Param> asShort (String name, Short defValue) {
return getParam(shortSetReader, name, toSet(defValue));
}
public Param> asShort (String name, Short[] defValue) {
return getParam(shortSetReader, name, toSet(defValue));
}
public Param> asShort (String name, Short defValue, ParamValidator validator) {
return getParam(shortSetReader, name, toSet(defValue), getListValidator(validator));
}
public Param> asShort (String name, Short[] defValue, ParamValidator validator) {
return getParam(shortSetReader, name, toSet(defValue), getListValidator(validator));
}
//==================================================================================================================
public Param> asByte (String name) {
return getParam(byteSetReader, name);
}
public Param> asByte (String name, Byte defValue) {
return getParam(byteSetReader, name, toSet(defValue));
}
public Param> asByte (String name, Byte[] defValue) {
return getParam(byteSetReader, name, toSet(defValue));
}
public Param> asByte (String name, Byte defValue, ParamValidator validator) {
return getParam(byteSetReader, name, toSet(defValue), getListValidator(validator));
}
public Param> asByte (String name, Byte[] defValue, ParamValidator validator) {
return getParam(byteSetReader, name, toSet(defValue), getListValidator(validator));
}
//==================================================================================================================
public Param> asAny (ParamReader> reader, String name) {
return getParam(reader, name);
}
public Param> asAny (ParamReader> reader, String name, T defValue) {
return getParam(reader, name, toSet(defValue));
}
public Param> asAny (ParamReader> reader, String name, T defValue, ParamValidator validator) {
return getParam(reader, name, toSet(defValue), getListValidator(validator));
}
//****************************************************************************************************
}