Util types: implement hashCode()/equals()/toString()
[yangtools.git] / yang / yang-model-util / src / main / java / org / opendaylight / yangtools / yang / model / util / type / AbstractRangedBaseType.java
1 /*
2  * Copyright (c) 2015 Pantheon Technologies s.r.o. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yangtools.yang.model.util.type;
9
10 import com.google.common.base.Optional;
11 import com.google.common.collect.ImmutableList;
12 import java.util.List;
13 import org.opendaylight.yangtools.yang.common.QName;
14 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
15 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
16 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
17 import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint;
18 import org.opendaylight.yangtools.yang.model.util.BaseConstraints;
19
20 abstract class AbstractRangedBaseType<T extends TypeDefinition<T>> extends AbstractBaseType<T> {
21     private final List<RangeConstraint> rangeConstraints;
22
23     AbstractRangedBaseType(final QName qname, final Number minValue, final Number maxValue) {
24         super(qname);
25         this.rangeConstraints = ImmutableList.<RangeConstraint>of(BaseConstraints.newRangeConstraint(
26                 minValue, maxValue, Optional.<String>absent(), Optional.<String>absent()));
27     }
28
29     AbstractRangedBaseType(final SchemaPath path, final List<UnknownSchemaNode> unknownSchemaNodes,
30         final List<RangeConstraint> rangeConstraints) {
31         super(path, unknownSchemaNodes);
32         this.rangeConstraints = ImmutableList.copyOf(rangeConstraints);
33     }
34
35     public final List<RangeConstraint> getRangeConstraints() {
36         return rangeConstraints;
37     }
38 }