Permalink
Browse files

Merge pull request #9496 from rhusar/WFLY-7811

WFLY-7811 Use proper validator for DistributedCacheResourceDefinition.Attribute#L1_LIFESPAN
  • Loading branch information...
2 parents 0a7f9e3 + 0171e2c commit 7ba5599e32c9ec292047e8406f6a47624429739f @kabir kabir committed on GitHub Dec 19, 2016
@@ -38,7 +38,7 @@
/**
* Sets an inclusive lower bound of this validator.
- * @param lowerBound the lower bound
+ * @param value the lower bound
*/
public DoubleRangeValidatorBuilder lowerBound(double value) {
this.lowerBound = new Bound(value, false);
@@ -47,7 +47,7 @@ public DoubleRangeValidatorBuilder lowerBound(double value) {
/**
* Sets an exclusive lower bound of this validator.
- * @param lowerBound the lower bound
+ * @param value the lower bound
*/
public DoubleRangeValidatorBuilder lowerBoundExclusive(double value) {
this.lowerBound = new Bound(value, true);
@@ -56,7 +56,7 @@ public DoubleRangeValidatorBuilder lowerBoundExclusive(double value) {
/**
* Sets the inclusive upper bound of this validator.
- * @param upperBound the upper bound
+ * @param value the upper bound
*/
public DoubleRangeValidatorBuilder upperBound(double value) {
this.upperBound = new Bound(value, false);
@@ -65,16 +65,13 @@ public DoubleRangeValidatorBuilder upperBound(double value) {
/**
* Sets the exclusive upper bound of this validator.
- * @param upperBound the upper bound
+ * @param value the upper bound
*/
public DoubleRangeValidatorBuilder upperBoundExclusive(double value) {
this.upperBound = new Bound(value, true);
return this;
}
- /**
- * {@inheritDoc}
- */
@Override
public ParameterValidator build() {
return new DoubleRangeValidator(this.lowerBound, this.upperBound, this.allowsUndefined, this.allowsExpressions);
@@ -105,7 +102,7 @@ boolean isExclusive() {
/**
* Creates an upper- and lower-bounded validator.
* @param lowerBound the lower bound
- * @param lowerBound the upper bound
+ * @param upperBound the upper bound
* @param nullable indicates whether {@link ModelType#UNDEFINED} is allowed
* @param allowExpressions whether {@link ModelType#EXPRESSION} is allowed
*/
@@ -115,9 +112,6 @@ boolean isExclusive() {
this.upperBound = upperBound;
}
- /**
- * {@inheritDoc}
- */
@Override
public void validateParameter(String parameterName, ModelNode parameterValue) throws OperationFailedException {
super.validateParameter(parameterName, parameterValue);
@@ -28,6 +28,7 @@
import org.jboss.as.clustering.controller.validation.DoubleRangeValidatorBuilder;
import org.jboss.as.clustering.controller.validation.EnumValidatorBuilder;
import org.jboss.as.clustering.controller.validation.IntRangeValidatorBuilder;
+import org.jboss.as.clustering.controller.validation.LongRangeValidatorBuilder;
import org.jboss.as.clustering.controller.validation.ParameterValidatorBuilder;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.ModelVersion;
@@ -60,16 +61,12 @@ static PathElement pathElement(String name) {
enum Attribute implements org.jboss.as.clustering.controller.Attribute {
CAPACITY_FACTOR("capacity-factor", ModelType.DOUBLE, new ModelNode(1.0f), new DoubleRangeValidatorBuilder().lowerBound(0).upperBound(Float.MAX_VALUE)),
CONSISTENT_HASH_STRATEGY("consistent-hash-strategy", ModelType.STRING, new ModelNode(ConsistentHashStrategy.INTER_CACHE.name()), new EnumValidatorBuilder<>(ConsistentHashStrategy.class)),
- L1_LIFESPAN("l1-lifespan", ModelType.LONG, new ModelNode(600000L), new DoubleRangeValidatorBuilder().lowerBound(0)),
+ L1_LIFESPAN("l1-lifespan", ModelType.LONG, new ModelNode(600000L), new LongRangeValidatorBuilder().min(0)),
OWNERS("owners", ModelType.INT, new ModelNode(2), new IntRangeValidatorBuilder().min(1)),
SEGMENTS("segments", ModelType.INT, new ModelNode(256), new IntRangeValidatorBuilder().min(1)),
;
private final AttributeDefinition definition;
- Attribute(String name, ModelType type, ModelNode defaultValue) {
- this.definition = createBuilder(name, type, defaultValue).build();
- }
-
Attribute(String name, ModelType type, ModelNode defaultValue, ParameterValidatorBuilder validator) {
SimpleAttributeDefinitionBuilder builder = createBuilder(name, type, defaultValue);
this.definition = builder.setValidator(validator.configure(builder).build()).build();

0 comments on commit 7ba5599

Please sign in to comment.