* This interface was modeled according to definition in <a
* href="https://tools.ietf.org/html/rfc6020#section-9.4.4">[RFC-6020] The
* length Statement</a>.
- *
+ *
* @see ConstraintMetaDefinition
*/
public interface LengthConstraint extends ConstraintMetaDefinition {
/**
* Returns the length-restricting lower bound value. <br>
* The value MUST NOT be negative.
- *
+ *
* @return the length-restricting lower bound value.
*/
- Long getMin();
+ Number getMin();
/**
* Returns the length-restricting upper bound value. <br>
* The value MUST NOT be negative.
- *
+ *
* @return length-restricting upper bound value.
*/
- Long getMax();
+ Number getMax();
}
private BaseConstraints() {
}
- public static LengthConstraint lengthConstraint(final long min,
- final long max, final String description, final String reference) {
+ public static LengthConstraint lengthConstraint(final Number min,
+ final Number max, final String description, final String reference) {
return new LengthConstraintImpl(min, max, description, reference);
}
private static final class LengthConstraintImpl implements LengthConstraint {
- private final long min;
- private final long max;
+ private final Number min;
+ private final Number max;
private final String description;
private final String reference;
private final String errorAppTag;
private final String errorMessage;
- public LengthConstraintImpl(long min, long max,
+ public LengthConstraintImpl(Number min, Number max,
final String description, final String reference) {
super();
this.min = min;
}
@Override
- public Long getMin() {
+ public Number getMin() {
return min;
}
@Override
- public Long getMax() {
+ public Number getMax() {
return max;
}
+ ((errorAppTag == null) ? 0 : errorAppTag.hashCode());
result = prime * result
+ ((errorMessage == null) ? 0 : errorMessage.hashCode());
- result = prime * result + (int) (max ^ (max >>> 32));
- result = prime * result + (int) (min ^ (min >>> 32));
+ result = prime * result + ((max == null) ? 0 : max.hashCode());
+ result = prime * result + ((min == null) ? 0 : min.hashCode());
result = prime * result
+ ((reference == null) ? 0 : reference.hashCode());
return result;
final List<LengthConstraint> constraints = new ArrayList<LengthConstraint>();
constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "", ""));
lengthStatements = Collections.unmodifiableList(constraints);
-
+
this.patterns = Collections.emptyList();
}
/**
- *
- *
+ *
+ *
* @param lengthStatements
* @param patterns
*/
final List<PatternConstraint> patterns) {
super();
path = BaseTypes.schemaPath(name);
- this.lengthStatements = Collections.unmodifiableList(lengthStatements);
+ if(lengthStatements == null || lengthStatements.size() == 0) {
+ final List<LengthConstraint> constraints = new ArrayList<LengthConstraint>();
+ constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "", ""));
+ this.lengthStatements = Collections.unmodifiableList(constraints);
+ } else {
+ this.lengthStatements = Collections.unmodifiableList(lengthStatements);
+ }
this.patterns = Collections.unmodifiableList(patterns);
}
/**
- *
- *
+ *
+ *
* @param defaultValue
* @param lengthStatements
* @param patterns
super();
path = BaseTypes.schemaPath(name);
this.defaultValue = defaultValue;
- this.lengthStatements = lengthStatements;
+ if(lengthStatements == null || lengthStatements.size() == 0) {
+ final List<LengthConstraint> constraints = new ArrayList<LengthConstraint>();
+ constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "", ""));
+ this.lengthStatements = Collections.unmodifiableList(constraints);
+ } else {
+ this.lengthStatements = Collections.unmodifiableList(lengthStatements);
+ }
this.patterns = patterns;
this.units = units;
}
/*
* (non-Javadoc)
- *
+ *
* @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
*/
@Override
/*
* (non-Javadoc)
- *
+ *
* @see org.opendaylight.controller.yang.model.api.TypeDefinition#getUnits()
*/
@Override
/*
* (non-Javadoc)
- *
+ *
* @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()
*/
@Override
/*
* (non-Javadoc)
- *
+ *
* @see org.opendaylight.controller.yang.model.api.SchemaNode#getQName()
*/
@Override
/*
* (non-Javadoc)
- *
+ *
* @see org.opendaylight.controller.yang.model.api.SchemaNode#getPath()
*/
@Override
/*
* (non-Javadoc)
- *
+ *
* @see org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()
*/
@Override
/*
* (non-Javadoc)
- *
+ *
* @see org.opendaylight.controller.yang.model.api.SchemaNode#getReference()
*/
@Override
/*
* (non-Javadoc)
- *
+ *
* @see org.opendaylight.controller.yang.model.api.SchemaNode#getStatus()
*/
@Override
/*
* (non-Javadoc)
- *
+ *
* @see
* com.csico.yang.model.base.type.api.StringTypeDefinition#getLengthStatements
* ()
/*
* (non-Javadoc)
- *
+ *
* @see
* com.csico.yang.model.base.type.api.StringTypeDefinition#getPatterns()
*/