e9bdd2ce776f6bfe75a885c8c100166377c38d3d
[yangtools.git] / yang / yang-model-util / src / main / java / org / opendaylight / yangtools / yang / model / util / type / RangeRestrictedTypeBuilder.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.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;
17
18 public abstract class RangeRestrictedTypeBuilder<T extends TypeDefinition<T>> extends AbstractRestrictedTypeBuilder<T> {
19     private Collection<RangeConstraint> rangeAlternatives;
20
21     RangeRestrictedTypeBuilder(final T baseType, final SchemaPath path) {
22         super(Preconditions.checkNotNull(baseType), path);
23     }
24
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);
29         touch();
30     }
31
32     final List<RangeConstraint> calculateRangeConstraints(final List<RangeConstraint> baseRangeConstraints) {
33         if (rangeAlternatives == null || rangeAlternatives.isEmpty()) {
34             return baseRangeConstraints;
35         }
36
37         // FIXME: calculate ranges
38         throw new UnsupportedOperationException();
39     }
40 }