*/
package org.opendaylight.yangtools.yang.model.util;
-import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import java.util.Objects;
+import java.util.Optional;
import org.opendaylight.yangtools.concepts.Immutable;
import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint;
/**
- * {@link Immutable} implementation of {@link LengthConstraint}.
- *
- * Range constraint based on supplied parameters with additional behaviour:
+ * {@link Immutable} implementation of {@link RangeConstraint}.
*
+ * <p>
+ * Range constraint based on supplied parameters with additional behavior:
* <ul>
* <li>{@link RangeConstraint#getErrorAppTag()} returns
* <code>range-out-of-specified-bounds</code>
- * <li>{@link RangeConstraint#getErrorMessage() returns <code>The argument is
+ * <li>{@link RangeConstraint#getErrorMessage()} returns <code>The argument is
* out of bounds <<i>min</i>, <i>max</i> ></code>
* </ul>
*/
final Optional<String> reference, final String errorAppTag, final String errorMessage) {
this.min = Preconditions.checkNotNull(min, "min must not be null.");
this.max = Preconditions.checkNotNull(max, "max must not be null.");
- this.description = description.orNull();
- this.reference = reference.orNull();
+ this.description = description.orElse(null);
+ this.reference = reference.orElse(null);
this.errorAppTag = errorAppTag != null ? errorAppTag : "range-out-of-specified-bounds";
this.errorMessage = errorMessage != null ? errorMessage : "The argument is out of bounds <" + min + ", " + max
+ ">";
}
@Override
- public String getDescription() {
- return description;
+ public Optional<String> getDescription() {
+ return Optional.ofNullable(description);
}
@Override
- public String getErrorAppTag() {
- return errorAppTag;
+ public Optional<String> getErrorAppTag() {
+ return Optional.ofNullable(errorAppTag);
}
@Override
- public String getErrorMessage() {
- return errorMessage;
+ public Optional<String> getErrorMessage() {
+ return Optional.ofNullable(errorMessage);
}
@Override
- public String getReference() {
- return reference;
+ public Optional<String> getReference() {
+ return Optional.ofNullable(reference);
}
@Override
@Override
public String toString() {
- return "RangeConstraintImpl [min=" +
- min +
- ", max=" +
- max +
- ", description=" +
- description +
- ", reference=" +
- reference +
- ", errorAppTag=" +
- errorAppTag +
- ", errorMessage=" +
- errorMessage +
- "]";
+ return "RangeConstraintImpl [min=" + min + ", max=" + max + ", description=" + description
+ + ", reference=" + reference + ", errorAppTag=" + errorAppTag + ", errorMessage=" + errorMessage + "]";
}
-}
\ No newline at end of file
+}