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.LengthConstraint;
18 public abstract class LengthRestrictedTypeBuilder<T extends TypeDefinition<T>> extends AbstractRestrictedTypeBuilder<T> {
19 private Collection<LengthConstraint> lengthAlternatives;
21 LengthRestrictedTypeBuilder(final T baseType, final SchemaPath path) {
22 super(Preconditions.checkNotNull(baseType), path);
25 public final void setLengthAlternatives(@Nonnull final Collection<LengthConstraint> lengthAlternatives) {
26 Preconditions.checkState(this.lengthAlternatives == null, "Range alternatives already defined as %s",
28 this.lengthAlternatives = Preconditions.checkNotNull(lengthAlternatives);
32 final List<LengthConstraint> calculateLenghtConstraints(final List<LengthConstraint> baseLengthConstraints) {
33 if (lengthAlternatives == null || lengthAlternatives.isEmpty()) {
34 return baseLengthConstraints;
37 // FIXME: calculate lengths
38 throw new UnsupportedOperationException();