2 * Copyright (c) 2015 Pantheon Technologies s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yangtools.yang.model.util.type;
10 import com.google.common.base.MoreObjects.ToStringHelper;
11 import com.google.common.base.Optional;
12 import com.google.common.collect.ImmutableList;
13 import java.util.List;
14 import org.opendaylight.yangtools.yang.common.QName;
15 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
16 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
17 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
18 import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint;
19 import org.opendaylight.yangtools.yang.model.util.BaseConstraints;
21 abstract class AbstractRangedBaseType<T extends TypeDefinition<T>> extends AbstractBaseType<T> {
22 private final List<RangeConstraint> rangeConstraints;
24 AbstractRangedBaseType(final QName qname, final Number minValue, final Number maxValue) {
26 this.rangeConstraints = ImmutableList.<RangeConstraint>of(BaseConstraints.newRangeConstraint(
27 minValue, maxValue, Optional.<String>absent(), Optional.<String>absent()));
30 AbstractRangedBaseType(final SchemaPath path, final List<UnknownSchemaNode> unknownSchemaNodes,
31 final List<RangeConstraint> rangeConstraints) {
32 super(path, unknownSchemaNodes);
33 this.rangeConstraints = ImmutableList.copyOf(rangeConstraints);
36 public final List<RangeConstraint> getRangeConstraints() {
37 return rangeConstraints;
41 protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
42 return super.addToStringAttributes(toStringHelper).add("range", rangeConstraints);