Populate model/ hierarchy
[yangtools.git] / model / yang-model-ri / src / main / java / org / opendaylight / yangtools / yang / model / ri / type / JavaLengthConstraints.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.ri.type;
9
10 import com.google.common.collect.ImmutableRangeSet;
11 import com.google.common.collect.Range;
12 import com.google.common.collect.RangeSet;
13 import java.util.Optional;
14 import org.opendaylight.yangtools.yang.model.api.type.LengthConstraint;
15
16 final class JavaLengthConstraints {
17     private JavaLengthConstraints() {
18         // Hidden on purpose
19     }
20
21     private static final RangeSet<Integer> INTEGER_ALLOWED_RANGES =
22             ImmutableRangeSet.of(Range.closed(0, Integer.MAX_VALUE));
23
24     static final LengthConstraint INTEGER_SIZE_CONSTRAINTS = new LengthConstraint() {
25         @Override
26         public Optional<String> getReference() {
27             return Optional.empty();
28         }
29
30         @Override
31         public Optional<String> getErrorMessage() {
32             return Optional.empty();
33         }
34
35         @Override
36         public Optional<String> getErrorAppTag() {
37             return Optional.empty();
38         }
39
40         @Override
41         public Optional<String> getDescription() {
42             return Optional.empty();
43         }
44
45         @Override
46         public RangeSet<Integer> getAllowedRanges() {
47             return INTEGER_ALLOWED_RANGES;
48         }
49     };
50 }