Remove useless UnsupportedOperationException throws
[yangtools.git] / yang / yang-model-util / src / main / java / org / opendaylight / yangtools / yang / model / util / BaseConstraints.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. 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;
9
10 import java.util.Optional;
11 import org.opendaylight.yangtools.yang.model.api.type.ModifierKind;
12 import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint;
13
14 /**
15  * Utility class which provides factory methods to construct Constraints.
16  *
17  * <p>
18  * Provides static factory methods which constructs instances of
19  * <ul>
20  * <li>{@link PatternConstraint} - {@link #newPatternConstraint(String, Optional, Optional)}
21  * </ul>
22  */
23 public final class BaseConstraints {
24     private BaseConstraints() {
25         // Hidden on purpose
26     }
27
28     /**
29      * Creates a {@link PatternConstraint}.
30      *
31      * <p>
32      * Creates an instance of Pattern constraint based on supplied parameters
33      * with additional behaviour:
34      * <ul>
35      * <li>{@link PatternConstraint#getErrorAppTag()} returns
36      * <code>invalid-regular-expression</code>
37      * </ul>
38      *
39      * @see PatternConstraint
40      *
41      * @param pattern
42      *            Regular expression, MUST NOT BE null.
43      * @param description
44      *            Description associated with constraint.
45      * @param reference
46      *            Reference associated with constraint.
47      * @return Instance of {@link PatternConstraint}
48      */
49     public static PatternConstraint newPatternConstraint(final String pattern, final Optional<String> description,
50             final Optional<String> reference) {
51         return new PatternConstraintImpl(pattern, description, reference);
52     }
53
54     /**
55      * Creates a {@link PatternConstraint}.
56      *
57      * <p>
58      * Creates an instance of Pattern constraint based on supplied parameters
59      * with additional behaviour:
60      * <ul>
61      * <li>{@link PatternConstraint#getErrorAppTag()} returns
62      * <code>invalid-regular-expression</code>
63      * </ul>
64      *
65      * @see PatternConstraint
66      *
67      * @param pattern
68      *            Regular expression, MUST NOT BE null.
69      * @param description
70      *            Description associated with constraint.
71      * @param reference
72      *            Reference associated with constraint.
73      * @param errorAppTag
74      *            error-app-tag associated with constraint.
75      * @param errorMessage
76      *            error message associated with constraint.
77      * @param modifier
78      *            Modifier of pattern constraint.
79      * @return Instance of {@link PatternConstraint}
80      */
81     public static PatternConstraint newPatternConstraint(final String pattern, final Optional<String> description,
82             final Optional<String> reference, final String errorAppTag, final String errorMessage,
83             final Optional<ModifierKind> modifier) {
84         return new PatternConstraintImpl(pattern, description, reference, errorAppTag, errorMessage, modifier);
85     }
86 }