2 * Copyright (c) 2015 Cisco Systems, Inc. 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.data.util;
10 import com.google.common.collect.ImmutableSet;
11 import java.util.Optional;
13 import org.opendaylight.yangtools.yang.model.api.ConstraintDefinition;
14 import org.opendaylight.yangtools.yang.model.api.MustDefinition;
15 import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath;
18 * Utility holder for constraint definitions which do not really constrain anything.
20 public abstract class EmptyConstraintDefinition implements ConstraintDefinition {
21 private static final EmptyConstraintDefinition MANDATORY = new EmptyConstraintDefinition() {
23 public boolean isMandatory() {
27 private static final EmptyConstraintDefinition OPTIONAL = new EmptyConstraintDefinition() {
29 public boolean isMandatory() {
34 private EmptyConstraintDefinition() {
38 public static EmptyConstraintDefinition create(final boolean mandatory) {
39 return mandatory ? MANDATORY : OPTIONAL;
43 public final Optional<RevisionAwareXPath> getWhenCondition() {
44 return Optional.empty();
48 public final Set<MustDefinition> getMustConstraints() {
49 return ImmutableSet.of();
53 public final Integer getMinElements() {
58 public final Integer getMaxElements() {
63 public final int hashCode() {
64 return ConstraintDefinitions.hashCode(this);
68 public final boolean equals(final Object obj) {
69 return ConstraintDefinitions.equals(this, obj);
73 public final String toString() {
74 return ConstraintDefinitions.toString(this);