blob: 7295cf48e73b3fa0830aa3929c00c3123712ef25 [file] [log] [blame]
/*
* Copyright 2016-present Open Networking Foundation
*
* 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 org.onosproject.nemo.model.operation.condition.parameter.definitions;
import static com.google.common.collect.ImmutableMap.builder;
import java.util.Map;
import org.onosproject.nemo.model.common.ParameterName;
import org.onosproject.nemo.model.operation.condition.parameter.definitions.condition.parameter.definition.ParameterMatchPatterns;
import com.google.common.collect.ImmutableMap.Builder;
/**
* The definition of a condition parameter.
*/
public interface ConditionParameterDefinition {
/**
* Returns the name of an parameter definition.
*
* @return the parameter name
*/
ParameterName getParameterName();
/**
* Returns the type of a parameter value.
*
* @return the type
*/
ParameterValueType getParameterValueType();
/**
* Returns the parameter match patterns.
*
* @return the patterns
*/
ParameterMatchPatterns getParameterMatchPatterns();
/**
* Returns the primary key of YANG type list.
*
* @return the action definition key
*/
ConditionParameterDefinitionKey getKey();
/**
* Types of parameter value.
*/
enum ParameterValueType {
/** A string-valued parameter. */
STRING(0),
/** An integer-valued parameter. */
INT(1),
/** An integer-range parameter. */
RANGE(2);
private static final Map<Integer, ParameterValueType> VALUE_MAP;
int value;
ParameterValueType(int value) {
this.value = value;
}
/**
* Returns the value of this definition.
*
* @return the value
*/
public int getIntValue() {
return value;
}
static {
Builder<Integer, ParameterValueType> b = builder();
for (ParameterValueType enumItem : ParameterValueType.values()) {
b.put(enumItem.value, enumItem);
}
VALUE_MAP = b.build();
}
/**
* Returns the type from the given value.
*
* @param value the given value
* @return corresponding type constant
* @throws IllegalArgumentException if there is no mapping
*/
public static ParameterValueType forValue(int value) {
ParameterValueType type = VALUE_MAP.get(value);
if (type == null) {
throw new IllegalArgumentException();
}
return type;
}
}
}