Repository: incubator-tamaya-sandbox Updated Branches: refs/heads/configjsr 7dbbbe550 -> f030e1225
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/f030e122/validation/src/main/java/org/apache/tamaya/validation/spi/ValidateSection.java ---------------------------------------------------------------------- diff --git a/validation/src/main/java/org/apache/tamaya/validation/spi/ValidateSection.java b/validation/src/main/java/org/apache/tamaya/validation/spi/ValidateSection.java deleted file mode 100644 index 99e24e7..0000000 --- a/validation/src/main/java/org/apache/tamaya/validation/spi/ValidateSection.java +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tamaya.validation.spi; - -import org.apache.tamaya.validation.ValidationModel; -import org.apache.tamaya.validation.ValidationTarget; -import org.apache.tamaya.validation.Validation; - -import javax.config.Config; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; -import java.util.Objects; - -/** - * Default configuration Model for a configuration section. - */ -public class ValidateSection extends ValidateGroup { - - /** - * Creates a new builder. - * @param owner owner, not null. - * @param name the section name. - * @return a new builder instance. - */ - public static Builder builder(String owner, String name){ - return new Builder(owner, name); - } - - /** - * Creates a section validation for the given section. - * @param owner owner, not null. - * @param name the fully qualified section name - * @param required flag, if the section is required to be present. - * @return the ConfigModel instance - */ - public static ValidationModel of(String owner, String name, boolean required){ - return new Builder(owner, name).setRequired(required).build(); - } - - /** - * Creates a section validation for the given section. - * @param owner owner, not null. - * @param name the fully qualified section name - * @param required flag, if the section is required to be present. - * @param configModels additional configModels - * @return a new builder, never null. - */ - public static ValidationModel of(String owner, String name, boolean required, ValidationModel... configModels){ - return new Builder(owner, name).setRequired(required).addValidations(configModels).build(); - } - - /** - * Internal constructor. - * @param builder the builder, not null. - */ - protected ValidateSection(Builder builder) { - super(builder.owner, builder.name, builder.childConfigModels); - } - - @Override - public ValidationTarget getType(){ - return ValidationTarget.Section; - } - - @Override - public Collection<Validation> validate(Config config) { - Iterable<String> propertyNames = config.getPropertyNames(); - String lookupKey = getName() + '.'; - boolean present = false; - for(String key:propertyNames){ - if(key.startsWith("_")){ - continue; - } - if(key.startsWith(lookupKey)){ - present = true; - break; - } - } - List<Validation> result = new ArrayList<>(1); - if(isRequired() && !present) { - result.add(Validation.checkMissing(this)); - } - result.addAll(super.validate(config)); - return result; - } - - @Override - public String toString() { - StringBuilder b = new StringBuilder(); - b.append(getType()).append(": ").append(getName()); - if(isRequired()) { - b.append(", required: " ).append(isRequired()); - } - for(ValidationModel val:getValidations()){ - b.append(", ").append(val.toString()); - } - return b.toString(); - } - - /** - * Builder for setting up a AreaConfigModel instance. - */ - public static class Builder{ - /** The section owner. */ - private String owner; - /** The section name. */ - private String name; - /** The optional description. */ - private String description; - /** The required flag. */ - private boolean required; - /** The (optional) custom validations.*/ - private final List<ValidationModel> childConfigModels = new ArrayList<>(); - - /** - * Creates a new Builder. - * @param owner owner, not null. - * @param sectionName the section name, not null. - */ - public Builder(String owner, String sectionName){ - this.owner = Objects.requireNonNull(owner); - this.name = Objects.requireNonNull(sectionName); - } - - /** - * Add configModels. - * @param configModels the configModels, not null. - * @return the Builder for chaining. - */ - public Builder addValidations(ValidationModel... configModels){ - this.childConfigModels.addAll(Arrays.asList(configModels)); - return this; - } - - /** - * Add configModels. - * @param configModels the configModels, not null. - * @return the Builder for chaining. - */ - public Builder addValidations(Collection<ValidationModel> configModels){ - this.childConfigModels.addAll(configModels); - return this; - } - - /** - * Sets the required flag. - * @param required zhe flag. - * @return the Builder for chaining. - */ - public Builder setRequired(boolean required){ - this.required = required; - return this; - } - - /** - * Set the )optional) description. - * @param description the description. - * @return the Builder for chaining. - */ - public Builder setDescription(String description){ - this.description = description; - return this; - } - - /** - * Set the section name - * @param name the section name, not null. - * @return the Builder for chaining. - */ - public Builder setName(String name){ - this.name = Objects.requireNonNull(name); - return this; - } - - /** - * Build a new ConfigModel instance. - * @return the new ConfigModel instance, not null. - */ - public ValidationModel build(){ - return new ValidateSection(this); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/f030e122/validation/src/main/java/org/apache/tamaya/validation/spi/ValidatedGroup.java ---------------------------------------------------------------------- diff --git a/validation/src/main/java/org/apache/tamaya/validation/spi/ValidatedGroup.java b/validation/src/main/java/org/apache/tamaya/validation/spi/ValidatedGroup.java new file mode 100644 index 0000000..093771e --- /dev/null +++ b/validation/src/main/java/org/apache/tamaya/validation/spi/ValidatedGroup.java @@ -0,0 +1,110 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tamaya.validation.spi; + +import org.apache.tamaya.validation.ConfigValidation; +import org.apache.tamaya.validation.ConfigArea; +import org.apache.tamaya.validation.ConfigValidationResult; + +import javax.config.Config; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +/** + * Default configuration Model for a configuration area. + */ +public class ValidatedGroup implements ConfigValidation { + + private final String owner; + private final String name; + private boolean required; + private List<ConfigValidation> childModels = new ArrayList<>(); + + public ValidatedGroup(String owner, String name, ConfigValidation... configModels){ + this(owner, name, Arrays.asList(configModels)); + } + + public ValidatedGroup(String owner, String name, Collection<ConfigValidation> configModels){ + this.owner = Objects.requireNonNull(owner); + this.name = Objects.requireNonNull(name); + this.childModels.addAll(configModels); + this.childModels = Collections.unmodifiableList(childModels); + for(ConfigValidation val: configModels) { + if(val.isRequired()){ + this.required = true; + break; + } + } + } + + @Override + public String getOwner() { + return owner; + } + + @Override + public String getName() { + return name; + } + + @Override + public boolean isRequired() { + return required; + } + + @Override + public ConfigArea getArea() { + return ConfigArea.Group; + } + + @Override + public String getDescription() { + if(childModels.isEmpty()){ + return null; + } + StringBuilder b = new StringBuilder(); + for(ConfigValidation val: childModels){ + b.append(" >> ").append(val); + } + return b.toString(); + } + + public Collection<ConfigValidation> getValidations(){ + return childModels; + } + + @Override + public Collection<ConfigValidationResult> validate(Config config) { + List<ConfigValidationResult> result = new ArrayList<>(1); + for(ConfigValidation child: childModels){ + result.addAll(child.validate(config)); + } + return result; + } + + @Override + public String toString(){ + return String.valueOf(getArea()) + ", size: " + childModels.size() + ": " + getDescription(); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/f030e122/validation/src/main/java/org/apache/tamaya/validation/spi/ValidatedParameter.java ---------------------------------------------------------------------- diff --git a/validation/src/main/java/org/apache/tamaya/validation/spi/ValidatedParameter.java b/validation/src/main/java/org/apache/tamaya/validation/spi/ValidatedParameter.java new file mode 100644 index 0000000..4891bd4 --- /dev/null +++ b/validation/src/main/java/org/apache/tamaya/validation/spi/ValidatedParameter.java @@ -0,0 +1,242 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tamaya.validation.spi; + +import org.apache.tamaya.validation.ConfigValidation; +import org.apache.tamaya.validation.ConfigArea; +import org.apache.tamaya.validation.ConfigValidationResult; + +import javax.config.Config; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Objects; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * Default configuration Model for a configuration parameter. + */ +public class ValidatedParameter extends AbstractConfigValidation { + /** Optional regular expression for validating the value. */ + private final String regEx; + /** The target type into which the value must be convertible. */ + private final Class<?> type; + + /** + * Internal constructor. + * @param builder the builder, not null. + */ + protected ValidatedParameter(Builder builder) { + super(builder.owner, builder.name, builder.required, builder.description); + this.regEx = builder.regEx; + this.type = builder.type; + } + + @Override + public ConfigArea getArea() { + return ConfigArea.Parameter; + } + + /** + * Get the required parameter type. + * + * @return the type. + */ + public Class<?> getParameterType() { + return type; + } + + @Override + public Collection<ConfigValidationResult> validate(Config config) { + List<ConfigValidationResult> result = new ArrayList<>(1); + String configValue = config.getValue(getName(), String.class); + if (configValue == null && isRequired()) { + result.add(ConfigValidationResult.checkMissing(this)); + } + if (configValue != null && regEx != null) { + if (!configValue.matches(regEx)) { + result.add(ConfigValidationResult.checkError(this, "Config value not matching expression: " + regEx + ", was " + + configValue)); + } + } + return result; + } + + @Override + public String toString() { + StringBuilder b = new StringBuilder(); + b.append(getArea()).append(": ").append(getName()); + if (isRequired()) { + b.append(", required: ").append(isRequired()); + } + if (regEx != null) { + b.append(", expression: ").append(regEx); + } + return b.toString(); + } + + /** + * Creates a new Builder instance. + * @param owner the owner name, not null. + * @param name the fully qualified parameter name. + * @return a new builder, never null. + */ + public static Builder builder(String owner, String name) { + return new Builder(owner, name); + } + + /** + * Creates a new ConfigModel + * @param owner the owner name, not null. + * @param name the fully qualified parameter name. + * @param required the required flag. + * @param expression an optional regular expression to validate a value. + * @return the new ConfigModel instance. + */ + public static ConfigValidation of(String owner, String name, boolean required, String expression) { + return new Builder(owner, name).setRequired(required).setExpression(expression).build(); + } + + /** + * Creates a new ConfigModel + * @param owner the owner name, not null. + * @param name the fully qualified parameter name. + * @param required the required flag. + * @return the new ConfigModel instance. + */ + public static ConfigValidation of(String owner, String name, boolean required) { + return new Builder(owner, name).setRequired(required).build(); + } + + /** + * Creates a new ConfigModel. The parameter will be defined as optional. + * @param owner the owner name, not null. + * @param name the fully qualified parameter name. + * @return the new ConfigModel instance. + */ + public static ConfigValidation of(String owner, String name) { + return new Builder(owner, name).setRequired(false).build(); + } + + + /** + * A new Builder for creating ParameterModel instances. + */ + public static class Builder { + /** The parameter's target type. */ + private Class<?> type; + /** The owner. */ + private String owner; + /** The fully qualified parameter name. */ + private String name; + /** The optional validation expression. */ + private String regEx; + /** The optional description. */ + private String description; + /** The required flag. */ + private boolean required; + + /** + * Creates a new Builder. + * @param owner owner, not null. + * @param name the fully qualified parameter name, not null. + */ + public Builder(String owner, String name) { + this.owner = Objects.requireNonNull(owner); + this.name = Objects.requireNonNull(name); + } + + /** + * Sets the target type. + * @param type the type, not null. + * @return the Builder for chaining + */ + public Builder setType(String type) { + try { + this.type = Class.forName(type); + } catch (ClassNotFoundException e) { + try { + this.type = Class.forName("java.lang."+type); + } catch (ClassNotFoundException e2) { + Logger.getLogger(getClass().getName()).log(Level.INFO, "Failed to load parameter type: " + type, e2); + } + } + return this; + } + + /** + * Sets the required flag. + * @param required the required flag. + * @return the Builder for chaining + */ + public Builder setRequired(boolean required) { + this.required = required; + return this; + } + + /** + * Sets the optional description + * @param description the description + * @return the Builder for chaining + */ + public Builder setDescription(String description) { + this.description = description; + return this; + } + + /** + * Sets the optional validation expression + * @param expression the validation expression + * @return the Builder for chaining + */ + public Builder setExpression(String expression) { + this.regEx = expression; + return this; + } + + /** + * Sets the owner name. + * @param owner the owner name, not null. + * @return the Builder for chaining + */ + public Builder setOwner(String owner) { + this.owner = Objects.requireNonNull(owner); + return this; + } + + /** + * Sets the fully qualified parameter name. + * @param name the fully qualified parameter name, not null. + * @return the Builder for chaining + */ + public Builder setName(String name) { + this.name = Objects.requireNonNull(name); + return this; + } + + /** + * Creates a new ConfigModel with the given parameters. + * @return a new ConfigModel , never null. + */ + public ConfigValidation build() { + return new ValidatedParameter(this); + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/f030e122/validation/src/main/java/org/apache/tamaya/validation/spi/ValidatedSection.java ---------------------------------------------------------------------- diff --git a/validation/src/main/java/org/apache/tamaya/validation/spi/ValidatedSection.java b/validation/src/main/java/org/apache/tamaya/validation/spi/ValidatedSection.java new file mode 100644 index 0000000..cf944b1 --- /dev/null +++ b/validation/src/main/java/org/apache/tamaya/validation/spi/ValidatedSection.java @@ -0,0 +1,201 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tamaya.validation.spi; + +import org.apache.tamaya.validation.ConfigValidation; +import org.apache.tamaya.validation.ConfigArea; +import org.apache.tamaya.validation.ConfigValidationResult; + +import javax.config.Config; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.Objects; + +/** + * Default configuration Model for a configuration section. + */ +public class ValidatedSection extends ValidatedGroup { + + /** + * Creates a new builder. + * @param owner owner, not null. + * @param name the section name. + * @return a new builder instance. + */ + public static Builder builder(String owner, String name){ + return new Builder(owner, name); + } + + /** + * Creates a section validation for the given section. + * @param owner owner, not null. + * @param name the fully qualified section name + * @param required flag, if the section is required to be present. + * @return the ConfigModel instance + */ + public static ConfigValidation of(String owner, String name, boolean required){ + return new Builder(owner, name).setRequired(required).build(); + } + + /** + * Creates a section validation for the given section. + * @param owner owner, not null. + * @param name the fully qualified section name + * @param required flag, if the section is required to be present. + * @param configModels additional configModels + * @return a new builder, never null. + */ + public static ConfigValidation of(String owner, String name, boolean required, ConfigValidation... configModels){ + return new Builder(owner, name).setRequired(required).addValidations(configModels).build(); + } + + /** + * Internal constructor. + * @param builder the builder, not null. + */ + protected ValidatedSection(Builder builder) { + super(builder.owner, builder.name, builder.childConfigModels); + } + + @Override + public ConfigArea getArea(){ + return ConfigArea.Section; + } + + @Override + public Collection<ConfigValidationResult> validate(Config config) { + Iterable<String> propertyNames = config.getPropertyNames(); + String lookupKey = getName() + '.'; + boolean present = false; + for(String key:propertyNames){ + if(key.startsWith("_")){ + continue; + } + if(key.startsWith(lookupKey)){ + present = true; + break; + } + } + List<ConfigValidationResult> result = new ArrayList<>(1); + if(isRequired() && !present) { + result.add(ConfigValidationResult.checkMissing(this)); + } + result.addAll(super.validate(config)); + return result; + } + + @Override + public String toString() { + StringBuilder b = new StringBuilder(); + b.append(getArea()).append(": ").append(getName()); + if(isRequired()) { + b.append(", required: " ).append(isRequired()); + } + for(ConfigValidation val:getValidations()){ + b.append(", ").append(val.toString()); + } + return b.toString(); + } + + /** + * Builder for setting up a AreaConfigModel instance. + */ + public static class Builder{ + /** The section owner. */ + private String owner; + /** The section name. */ + private String name; + /** The optional description. */ + private String description; + /** The required flag. */ + private boolean required; + /** The (optional) custom validations.*/ + private final List<ConfigValidation> childConfigModels = new ArrayList<>(); + + /** + * Creates a new Builder. + * @param owner owner, not null. + * @param sectionName the section name, not null. + */ + public Builder(String owner, String sectionName){ + this.owner = Objects.requireNonNull(owner); + this.name = Objects.requireNonNull(sectionName); + } + + /** + * Add configModels. + * @param configModels the configModels, not null. + * @return the Builder for chaining. + */ + public Builder addValidations(ConfigValidation... configModels){ + this.childConfigModels.addAll(Arrays.asList(configModels)); + return this; + } + + /** + * Add configModels. + * @param configModels the configModels, not null. + * @return the Builder for chaining. + */ + public Builder addValidations(Collection<ConfigValidation> configModels){ + this.childConfigModels.addAll(configModels); + return this; + } + + /** + * Sets the required flag. + * @param required zhe flag. + * @return the Builder for chaining. + */ + public Builder setRequired(boolean required){ + this.required = required; + return this; + } + + /** + * Set the )optional) description. + * @param description the description. + * @return the Builder for chaining. + */ + public Builder setDescription(String description){ + this.description = description; + return this; + } + + /** + * Set the section name + * @param name the section name, not null. + * @return the Builder for chaining. + */ + public Builder setName(String name){ + this.name = Objects.requireNonNull(name); + return this; + } + + /** + * Build a new ConfigModel instance. + * @return the new ConfigModel instance, not null. + */ + public ConfigValidation build(){ + return new ValidatedSection(this); + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/f030e122/validation/src/main/java/org/apache/tamaya/validation/spi/ValidationModelProviderSpi.java ---------------------------------------------------------------------- diff --git a/validation/src/main/java/org/apache/tamaya/validation/spi/ValidationModelProviderSpi.java b/validation/src/main/java/org/apache/tamaya/validation/spi/ValidationModelProviderSpi.java deleted file mode 100644 index 9e40d22..0000000 --- a/validation/src/main/java/org/apache/tamaya/validation/spi/ValidationModelProviderSpi.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.tamaya.validation.spi; - -import org.apache.tamaya.validation.ValidationModel; - -import java.util.Collection; - -/** - * Model of a configuration state. A model can be a full model, or a partial model, validating only - * a configuration subset. This allows better user feedback because big configurations can be grouped - * and validated by multiple (partial) models. - */ -public interface ValidationModelProviderSpi { - - /** - * Get the validation defined. - * - * @return the sections defined, never null. - */ - Collection<ValidationModel> getConfigModels(); - -} http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/f030e122/validation/src/main/resources/META-INF/services/org.apache.tamaya.validation.spi.ConfigValidationProviderSpi ---------------------------------------------------------------------- diff --git a/validation/src/main/resources/META-INF/services/org.apache.tamaya.validation.spi.ConfigValidationProviderSpi b/validation/src/main/resources/META-INF/services/org.apache.tamaya.validation.spi.ConfigValidationProviderSpi new file mode 100644 index 0000000..2788871 --- /dev/null +++ b/validation/src/main/resources/META-INF/services/org.apache.tamaya.validation.spi.ConfigValidationProviderSpi @@ -0,0 +1,22 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy current the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +org.apache.tamaya.validation.internal.ConfiguredPropertiesModelProviderSpi +org.apache.tamaya.validation.internal.ConfiguredInlineModelProviderSpi +org.apache.tamaya.validation.internal.ConfiguredResourcesModelProviderSpi +org.apache.tamaya.validation.internal.ConfiguredTypeEventsModelProvider \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/f030e122/validation/src/main/resources/META-INF/services/org.apache.tamaya.validation.spi.ValidationModelProviderSpi ---------------------------------------------------------------------- diff --git a/validation/src/main/resources/META-INF/services/org.apache.tamaya.validation.spi.ValidationModelProviderSpi b/validation/src/main/resources/META-INF/services/org.apache.tamaya.validation.spi.ValidationModelProviderSpi deleted file mode 100644 index 2788871..0000000 --- a/validation/src/main/resources/META-INF/services/org.apache.tamaya.validation.spi.ValidationModelProviderSpi +++ /dev/null @@ -1,22 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy current the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -org.apache.tamaya.validation.internal.ConfiguredPropertiesModelProviderSpi -org.apache.tamaya.validation.internal.ConfiguredInlineModelProviderSpi -org.apache.tamaya.validation.internal.ConfiguredResourcesModelProviderSpi -org.apache.tamaya.validation.internal.ConfiguredTypeEventsModelProvider \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/f030e122/validation/src/test/java/org/apache/tamaya/validation/ConfigModelProviderTest.java ---------------------------------------------------------------------- diff --git a/validation/src/test/java/org/apache/tamaya/validation/ConfigModelProviderTest.java b/validation/src/test/java/org/apache/tamaya/validation/ConfigModelProviderTest.java index ea5c375..1e371b6 100644 --- a/validation/src/test/java/org/apache/tamaya/validation/ConfigModelProviderTest.java +++ b/validation/src/test/java/org/apache/tamaya/validation/ConfigModelProviderTest.java @@ -18,10 +18,10 @@ */ package org.apache.tamaya.validation; -import org.apache.tamaya.validation.spi.ValidateSection; -import org.apache.tamaya.validation.spi.ValidateParameter; -import org.apache.tamaya.validation.spi.ValidateGroup; -import org.apache.tamaya.validation.spi.ValidationModelProviderSpi; +import org.apache.tamaya.validation.spi.ValidatedSection; +import org.apache.tamaya.validation.spi.ValidatedParameter; +import org.apache.tamaya.validation.spi.ValidatedGroup; +import org.apache.tamaya.validation.spi.ConfigValidationProviderSpi; import java.util.ArrayList; import java.util.Collection; @@ -32,31 +32,31 @@ import java.util.List; /** * Created by Anatole on 09.08.2015. */ -public class ConfigModelProviderTest implements ValidationModelProviderSpi { +public class ConfigModelProviderTest implements ConfigValidationProviderSpi { - private List<ValidationModel> configModels = new ArrayList<>(1); + private List<ConfigValidation> configModels = new ArrayList<>(1); public ConfigModelProviderTest(){ configModels.add(new TestConfigModel()); configModels = Collections.unmodifiableList(configModels); } - public Collection<ValidationModel> getConfigModels() { + public Collection<ConfigValidation> getConfigValidations() { return configModels; } - private static final class TestConfigModel extends ValidateGroup { + private static final class TestConfigModel extends ValidatedGroup { public TestConfigModel(){ - super("TestConfigModel", "TestConfig", new ValidateSection.Builder("TestConfigModel", + super("TestConfigModel", "TestConfig", new ValidatedSection.Builder("TestConfigModel", "a.test.existing").setRequired(true).build(), - ValidateParameter.of("TestConfigModel", "a.test.existing.aParam", true), - ValidateParameter.of("TestConfigModel", "a.test.existing.optionalParam"), - ValidateParameter.of("TestConfigModel", "a.test.existing.aABCParam", false, "[ABC].*"), - new ValidateSection.Builder("TestConfigModel", "a.test.notexisting").setRequired(true).build(), - ValidateParameter.of("TestConfigModel", "a.test.notexisting.aParam", true), - ValidateParameter.of("TestConfigModel", "a.test.notexisting.optionalParam"), - ValidateParameter.of("TestConfigModel", "a.test.existing.aABCParam2", false, "[ABC].*")); + ValidatedParameter.of("TestConfigModel", "a.test.existing.aParam", true), + ValidatedParameter.of("TestConfigModel", "a.test.existing.optionalParam"), + ValidatedParameter.of("TestConfigModel", "a.test.existing.aABCParam", false, "[ABC].*"), + new ValidatedSection.Builder("TestConfigModel", "a.test.notexisting").setRequired(true).build(), + ValidatedParameter.of("TestConfigModel", "a.test.notexisting.aParam", true), + ValidatedParameter.of("TestConfigModel", "a.test.notexisting.optionalParam"), + ValidatedParameter.of("TestConfigModel", "a.test.existing.aABCParam2", false, "[ABC].*")); } @Override public String getName() { http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/f030e122/validation/src/test/java/org/apache/tamaya/validation/internal/ConfigDocumentationBeanTest.java ---------------------------------------------------------------------- diff --git a/validation/src/test/java/org/apache/tamaya/validation/internal/ConfigDocumentationBeanTest.java b/validation/src/test/java/org/apache/tamaya/validation/internal/ConfigDocumentationBeanTest.java index ba19c7e..0cd6bc4 100644 --- a/validation/src/test/java/org/apache/tamaya/validation/internal/ConfigDocumentationBeanTest.java +++ b/validation/src/test/java/org/apache/tamaya/validation/internal/ConfigDocumentationBeanTest.java @@ -18,7 +18,7 @@ */ package org.apache.tamaya.validation.internal; -import org.apache.tamaya.validation.ValidationTarget; +import org.apache.tamaya.validation.ConfigArea; import org.junit.Test; import static org.junit.Assert.assertFalse; @@ -73,7 +73,7 @@ public class ConfigDocumentationBeanTest { @Test public void testGetConfigurationModel_WithSection() throws Exception { - String results = mbean.getConfigurationModel(ValidationTarget.Parameter); + String results = mbean.getConfigurationModel(ConfigArea.Parameter); assertNotNull(results); assertFalse(results.trim().isEmpty()); assertTrue(results.contains("\"target\":\"Parameter\"")); @@ -92,7 +92,7 @@ public class ConfigDocumentationBeanTest { @Test public void testFindValidationModels() throws Exception { - String results = mbean.findValidationModels("a", ValidationTarget.Section); + String results = mbean.findValidationModels("a", ConfigArea.Section); assertNotNull(results); assertFalse(results.trim().isEmpty()); assertFalse(results.contains("\"target\":\"Parameter\""));
