2 * Copyright (c) 2017 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 static java.util.Objects.requireNonNull;
12 import com.google.common.collect.ImmutableRangeSet;
13 import com.google.common.collect.RangeSet;
14 import java.util.Optional;
15 import org.opendaylight.yangtools.concepts.Immutable;
16 import org.opendaylight.yangtools.yang.model.api.ConstraintMetaDefinition;
17 import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint;
19 final class ResolvedRangeConstraint<T extends Number & Comparable<T>> implements RangeConstraint<T>, Immutable {
20 private final ConstraintMetaDefinition meta;
21 private final RangeSet<T> ranges;
23 ResolvedRangeConstraint(final ConstraintMetaDefinition meta, final RangeSet<T> ranges) {
24 this.meta = requireNonNull(meta);
25 this.ranges = ImmutableRangeSet.copyOf(ranges);
29 public Optional<String> getDescription() {
30 return meta.getDescription();
34 public Optional<String> getErrorAppTag() {
35 return meta.getErrorAppTag();
39 public Optional<String> getErrorMessage() {
40 return meta.getErrorMessage();
44 public Optional<String> getReference() {
45 return meta.getReference();
49 public RangeSet<? extends T> getAllowedRanges() {