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.Preconditions;
11 import java.util.Collection;
12 import java.util.List;
13 import javax.annotation.Nonnull;
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.type.RangeConstraint;
18 public abstract class RangeRestrictedTypeBuilder<T extends TypeDefinition<T>> extends AbstractRestrictedTypeBuilder<T> {
19 private Collection<RangeConstraint> rangeAlternatives;
21 RangeRestrictedTypeBuilder(final T baseType, final SchemaPath path) {
22 super(Preconditions.checkNotNull(baseType), path);
25 public void setRangeAlternatives(@Nonnull final Collection<RangeConstraint> rangeAlternatives) {
26 Preconditions.checkState(this.rangeAlternatives == null, "Range alternatives already defined as %s",
27 this.rangeAlternatives);
28 this.rangeAlternatives = Preconditions.checkNotNull(rangeAlternatives);
32 final List<RangeConstraint> calculateRangeConstraints(final List<RangeConstraint> baseRangeConstraints) {
33 if (rangeAlternatives == null || rangeAlternatives.isEmpty()) {
34 return baseRangeConstraints;
37 // FIXME: calculate ranges
38 throw new UnsupportedOperationException();