<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok</artifactId>
+ </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
--- /dev/null
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.common.parameters;
+
+import lombok.Getter;
+import lombok.Setter;
+import org.onap.policy.common.parameters.annotations.NotBlank;
+import org.onap.policy.common.parameters.annotations.NotNull;
+
+/**
+ * Implementation of a parameter group.
+ */
+@NotNull
+@NotBlank
+@Getter
+@Setter
+public class ParameterGroupImpl implements ParameterGroup {
+ /**
+ * Group name. Note: this MUST not be "private" or it will not be validated.
+ */
+ protected String name;
+
+ /**
+ * Constructs the object, with a {@code null} name.
+ */
+ public ParameterGroupImpl() {
+ this.name = null;
+ }
+
+ /**
+ * Constructs the object.
+ *
+ * @param name the group's name
+ */
+ public ParameterGroupImpl(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public GroupValidationResult validate() {
+ return new GroupValidationResult(this);
+ }
+}
this.field = field;
this.parameterValue = parameterValue;
- if (parameterValue == null && getAnyAnnotation(field, NotNull.class) != null) {
- setResult(ValidationStatus.INVALID, "is null");
+ if (parameterValue == null) {
+ if (getAnyAnnotation(field, NotNull.class) != null) {
+ setResult(ValidationStatus.INVALID, "is null");
+ }
- } else if (parameterValue instanceof String && getAnyAnnotation(field, NotBlank.class) != null
- && parameterValue.toString().trim().isEmpty()) {
- setResult(ValidationStatus.INVALID, "must be a non-blank string");
+ } else if (parameterValue instanceof String) {
+ if (getAnyAnnotation(field, NotBlank.class) != null && parameterValue.toString().trim().isEmpty()) {
+ setResult(ValidationStatus.INVALID, "must be a non-blank string");
+ }
} else if (parameterValue instanceof Number) {
Min minAnnot = field.getAnnotation(Min.class);
/**
* Gets an annotation for a field, first checking the field, itself, and then checking
- * at the class level for the current and superclasses.
+ * at the class level. Does not check super classes as class-level annotations should
+ * only apply to the fields within the class.
*
* @param field field of interest
* @param annotClass class of annotation that is desired
return annot;
}
- // check class level
- Class<?> clazz = field.getDeclaringClass();
- while (clazz != Object.class) {
- if ((annot = clazz.getAnnotation(annotClass)) != null) {
- return annot;
- }
-
- clazz = clazz.getSuperclass();
- }
-
- return null;
+ return field.getDeclaringClass().getAnnotation(annotClass);
}
/**
// non-null should be OK
result = new ParameterValidationResult(NotNullSub.class.getDeclaredField(NOT_NULL_STRING_NAME), "");
assertEquals(ValidationStatus.CLEAN, result.getStatus());
+
+ /*
+ * Super class annotation - null should be OK
+ */
+ result = new ParameterValidationResult(NotNullSub2.class.getDeclaredField("anotherString"), null);
+ assertEquals(ValidationStatus.CLEAN, result.getStatus());
}
@Test
// these classes are used to test class-level annotations
- @NotNull
- private static class NotNullBase {
+
+ private static class EmptyBase {
}
- private static class NotNullSub extends NotNullBase {
+ @NotNull
+ private static class NotNullSub extends EmptyBase {
@SuppressWarnings("unused")
private String notNullString;
}
- private static class NotBlankBase {
-
+ private static class NotNullSub2 extends NotNullSub {
+ @SuppressWarnings("unused")
+ private String anotherString;
}
@NotBlank
- private static class NotBlankSub extends NotBlankBase {
+ private static class NotBlankSub extends EmptyBase {
@SuppressWarnings("unused")
private String notBlankString;
}
- private abstract static class SimpleGroup implements ParameterGroup {
- private String name;
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public void setName(String name) {
- this.name = name;
- }
- }
-
- private static class Contained extends SimpleGroup {
+ private static class Contained extends ParameterGroupImpl {
@Min(value = 1)
private int minInt;
- @Override
- public GroupValidationResult validate() {
- return new GroupValidationResult(this);
+ public Contained() {
+ super("Contained");
}
@SuppressWarnings("unused")
}
}
- private static class Container extends SimpleGroup {
+ private static class Container extends ParameterGroupImpl {
@NotNull
private Contained item;
- @Override
- public GroupValidationResult validate() {
- return new GroupValidationResult(this);
+ public Container() {
+ super("Container");
}
@SuppressWarnings("unused")
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 AT&T Intellectual Property.
* ================================================================================
* Licensed 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.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
package org.onap.policy.common.parameters.testclasses;
-import org.onap.policy.common.parameters.GroupValidationResult;
-import org.onap.policy.common.parameters.ParameterGroup;
+import org.onap.policy.common.parameters.ParameterGroupImpl;
-public class EmptyParameterGroup implements ParameterGroup {
- private String name;
+public class EmptyParameterGroup extends ParameterGroupImpl {
- public EmptyParameterGroup(final String name) {
- this.name = name;
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public void setName(final String name) {
- this.name = name;
- }
-
- @Override
- public GroupValidationResult validate() {
- return new GroupValidationResult(this);
+ public EmptyParameterGroup(String name) {
+ super(name);
}
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 AT&T Intellectual Property.
* ================================================================================
* Licensed 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.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
package org.onap.policy.common.parameters.testclasses;
-import org.onap.policy.common.parameters.GroupValidationResult;
-import org.onap.policy.common.parameters.ParameterGroup;
+import org.onap.policy.common.parameters.ParameterGroupImpl;
-public class ParameterGroupMissingGetter implements ParameterGroup {
- private String name;
+public class ParameterGroupMissingGetter extends ParameterGroupImpl {
private String value;
public ParameterGroupMissingGetter(final String name) {
- this.name = name;
+ super(name);
}
-
+
public String getTheValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public void setName(final String name) {
- this.name = name;
- }
-
- @Override
- public GroupValidationResult validate() {
- return new GroupValidationResult(this);
- }
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 AT&T Intellectual Property.
* ================================================================================
* Licensed 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.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
package org.onap.policy.common.parameters.testclasses;
-import org.onap.policy.common.parameters.GroupValidationResult;
-import org.onap.policy.common.parameters.ParameterGroup;
+import org.onap.policy.common.parameters.ParameterGroupImpl;
-public class ParameterGroupPrivateGetter implements ParameterGroup {
- private String name;
+public class ParameterGroupPrivateGetter extends ParameterGroupImpl {
private String value;
public ParameterGroupPrivateGetter(final String name) {
- this.name = name;
+ super(name);
}
-
+
public String getTheValue() {
return getValue();
}
public void setValue(String value) {
this.value = value;
}
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public void setName(final String name) {
- this.name = name;
- }
-
- @Override
- public GroupValidationResult validate() {
- return new GroupValidationResult(this);
- }
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 AT&T Intellectual Property.
* ================================================================================
* Licensed 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.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
package org.onap.policy.common.parameters.testclasses;
-import org.onap.policy.common.parameters.GroupValidationResult;
-import org.onap.policy.common.parameters.ParameterGroup;
+import org.onap.policy.common.parameters.ParameterGroupImpl;
-public class ParameterGroupWithArray implements ParameterGroup {
- private String name;
+public class ParameterGroupWithArray extends ParameterGroupImpl {
private int[] intArray = {1, 2, 3};
public ParameterGroupWithArray(final String name) {
- this.name = name;
+ super(name);
}
public int[] getIntArray() {
return intArray;
}
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public void setName(final String name) {
- this.name = name;
- }
-
- @Override
- public GroupValidationResult validate() {
- return new GroupValidationResult(this);
- }
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 AT&T Intellectual Property.
* ================================================================================
* Licensed 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.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
import java.util.ArrayList;
import java.util.List;
+import org.onap.policy.common.parameters.ParameterGroupImpl;
-import org.onap.policy.common.parameters.GroupValidationResult;
-import org.onap.policy.common.parameters.ParameterGroup;
-
-public class ParameterGroupWithCollection implements ParameterGroup {
- private String name;
+public class ParameterGroupWithCollection extends ParameterGroupImpl {
private List<Integer> intArrayList = new ArrayList<>();
/**
* Create a test parameter group.
- *
+ *
* @param name the parameter group name
*/
public ParameterGroupWithCollection(final String name) {
- this.name = name;
+ super(name);
intArrayList.add(1);
intArrayList.add(2);
public List<Integer> getIntArrayList() {
return intArrayList;
}
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public void setName(final String name) {
- this.name = name;
- }
-
- @Override
- public GroupValidationResult validate() {
- return new GroupValidationResult(this);
- }
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 AT&T Intellectual Property.
* ================================================================================
* Licensed 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.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
import java.util.LinkedHashMap;
import java.util.Map;
-
-import org.onap.policy.common.parameters.GroupValidationResult;
import org.onap.policy.common.parameters.ParameterGroup;
+import org.onap.policy.common.parameters.ParameterGroupImpl;
-public class ParameterGroupWithIllegalMapKey implements ParameterGroup {
- private String name;
+public class ParameterGroupWithIllegalMapKey extends ParameterGroupImpl {
private Map<Integer, ParameterGroup> badMap = new LinkedHashMap<>();
/**
* @param name the parameter group name
*/
public ParameterGroupWithIllegalMapKey(final String name) {
- this.name = name;
-
+ super(name);
+
badMap.put(1, new TestParametersLGeneric("One"));
badMap.put(2, new TestParametersLGeneric("Two"));
badMap.put(3, new TestParametersLGeneric("Three"));
public Map<Integer, ParameterGroup> getBadMap() {
return badMap;
}
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public void setName(final String name) {
- this.name = name;
- }
-
- @Override
- public GroupValidationResult validate() {
- return new GroupValidationResult(this);
- }
-
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 AT&T Intellectual Property.
* ================================================================================
* Licensed 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.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
import java.util.LinkedHashMap;
import java.util.Map;
+import org.onap.policy.common.parameters.ParameterGroupImpl;
-import org.onap.policy.common.parameters.GroupValidationResult;
-import org.onap.policy.common.parameters.ParameterGroup;
-
-public class ParameterGroupWithIllegalMapValue implements ParameterGroup {
- private String name;
+public class ParameterGroupWithIllegalMapValue extends ParameterGroupImpl {
private Map<String, Integer> intMap = new LinkedHashMap<>();
/**
* @param name the parameter group name
*/
public ParameterGroupWithIllegalMapValue(final String name) {
- this.name = name;
-
+ super(name);
+
intMap.put("One", 1);
intMap.put("Two", 2);
intMap.put("Three", 3);
public Map<String, Integer> getIntMap() {
return intMap;
}
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public void setName(final String name) {
- this.name = name;
- }
-
- @Override
- public GroupValidationResult validate() {
- return new GroupValidationResult(this);
- }
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 AT&T Intellectual Property.
* ================================================================================
* Licensed 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.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
package org.onap.policy.common.parameters.testclasses;
import java.util.List;
+import org.onap.policy.common.parameters.ParameterGroupImpl;
-import org.onap.policy.common.parameters.GroupValidationResult;
-import org.onap.policy.common.parameters.ParameterGroup;
-
-public class ParameterGroupWithNullCollection implements ParameterGroup {
- private String name;
+public class ParameterGroupWithNullCollection extends ParameterGroupImpl {
private List<Integer> nullList = null;
/**
* @param name the parameter group name
*/
public ParameterGroupWithNullCollection(final String name) {
- this.name = name;
+ super(name);
}
public List<Integer> getNullList() {
return nullList;
}
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public void setName(final String name) {
- this.name = name;
- }
-
- @Override
- public GroupValidationResult validate() {
- return new GroupValidationResult(this);
- }
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 AT&T Intellectual Property.
* ================================================================================
* Licensed 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.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
package org.onap.policy.common.parameters.testclasses;
import java.util.Map;
+import org.onap.policy.common.parameters.ParameterGroupImpl;
-import org.onap.policy.common.parameters.GroupValidationResult;
-import org.onap.policy.common.parameters.ParameterGroup;
-
-public class ParameterGroupWithNullMapValue implements ParameterGroup {
- private String name;
+public class ParameterGroupWithNullMapValue extends ParameterGroupImpl {
private Map<String, Integer> nullMap = null;
/**
* @param name the parameter group name
*/
public ParameterGroupWithNullMapValue(final String name) {
- this.name = name;
+ super(name);
}
public Map<String, Integer> getNullMap() {
return nullMap;
}
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public void setName(final String name) {
- this.name = name;
- }
-
- @Override
- public GroupValidationResult validate() {
- return new GroupValidationResult(this);
- }
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 AT&T Intellectual Property.
* ================================================================================
* Licensed 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.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
package org.onap.policy.common.parameters.testclasses;
-import org.onap.policy.common.parameters.GroupValidationResult;
import org.onap.policy.common.parameters.ParameterGroup;
+import org.onap.policy.common.parameters.ParameterGroupImpl;
-public class ParameterGroupWithNullSubGroup implements ParameterGroup {
- private String name;
+public class ParameterGroupWithNullSubGroup extends ParameterGroupImpl {
private ParameterGroup subGroup = null;
/**
* @param name the parameter group name
*/
public ParameterGroupWithNullSubGroup(final String name) {
- this.name = name;
+ super(name);
}
public ParameterGroup getSubGroup() {
return subGroup;
}
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public void setName(final String name) {
- this.name = name;
- }
-
- @Override
- public GroupValidationResult validate() {
- return new GroupValidationResult(this);
- }
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 AT&T Intellectual Property.
* ================================================================================
* Licensed 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.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
import java.util.ArrayList;
import java.util.List;
-
-import org.onap.policy.common.parameters.GroupValidationResult;
import org.onap.policy.common.parameters.ParameterGroup;
+import org.onap.policy.common.parameters.ParameterGroupImpl;
-public class ParameterGroupWithParameterGroupCollection implements ParameterGroup {
- private String name;
+public class ParameterGroupWithParameterGroupCollection extends ParameterGroupImpl {
private List<ParameterGroup> parameterGroupArrayList = new ArrayList<>();
/**
* @param name the parameter group name
*/
public ParameterGroupWithParameterGroupCollection(final String name) {
- this.name = name;
-
+ super(name);
+
parameterGroupArrayList.add(new TestParametersLGeneric("Generic0"));
parameterGroupArrayList.add(new TestParametersLGeneric("Generic1"));
parameterGroupArrayList.add(new TestParametersLGeneric("Generic2"));
public List<ParameterGroup> getParameterGroupArrayList() {
return parameterGroupArrayList;
}
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public void setName(final String name) {
- this.name = name;
- }
-
- @Override
- public GroupValidationResult validate() {
- return new GroupValidationResult(this);
- }
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 AT&T Intellectual Property.
* ================================================================================
* Licensed 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.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
-
import org.onap.policy.common.parameters.GroupValidationResult;
import org.onap.policy.common.parameters.ParameterConstants;
-import org.onap.policy.common.parameters.ParameterGroup;
+import org.onap.policy.common.parameters.ParameterGroupImpl;
import org.onap.policy.common.parameters.ValidationStatus;
-public class TestParametersL00 implements ParameterGroup {
+public class TestParametersL00 extends ParameterGroupImpl {
private static final String A_CONSTANT = "A Constant";
-
- private String name = A_CONSTANT;
+
private int l00IntField = 0;
private String l00StringField = "Legal " + this.getClass().getCanonicalName();
private TestParametersL10 l00L10Nested = new TestParametersL10("l00L10Nested");
* Default constructor.
*/
public TestParametersL00() {
- // Default Cnstructor
+ super(A_CONSTANT);
}
/**
* Create a test parameter group.
- *
+ *
* @param name the parameter group name
*/
public TestParametersL00(final String name) {
- this.name = name;
+ super(name);
TestParametersLGeneric l00LGenericNestedMapVal0 = new TestParametersLGeneric("l00LGenericNestedMapVal0");
l00LGenericNestedMap.put(l00LGenericNestedMapVal0.getName(), l00LGenericNestedMapVal0);
this.isSomeFlag = isSomeFlag;
}
- public void setName(String name) {
- this.name = name;
- }
-
public void setL00IntField(int l00IntField) {
this.l00IntField = l00IntField;
}
/**
* Trigger a validation message.
- *
+ *
* @param triggerStatus Validation status to trigger
* @param level Number of levels to recurse before stopping
*/
}
- @Override
- public String getName() {
- return name;
- }
-
@Override
public GroupValidationResult validate() {
- GroupValidationResult validationResult = new GroupValidationResult(this);
+ GroupValidationResult validationResult = super.validate();
- if (name == null || name.trim().length() == 0) {
+ if (getName() == null || getName().trim().length() == 0) {
validationResult.setResult("name", ValidationStatus.INVALID, "name must be a non-blank string");
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2019 AT&T Intellectual Property.
* ================================================================================
* Licensed 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.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
-
import org.onap.policy.common.parameters.GroupValidationResult;
import org.onap.policy.common.parameters.ParameterConstants;
-import org.onap.policy.common.parameters.ParameterGroup;
+import org.onap.policy.common.parameters.ParameterGroupImpl;
import org.onap.policy.common.parameters.ValidationStatus;
-public class TestParametersL10 implements ParameterGroup {
- private String name;
+public class TestParametersL10 extends ParameterGroupImpl {
private int l10IntField = 0;
private String l10StringField = "Legal " + this.getClass().getCanonicalName();
private TestParametersLGeneric l10LGenericNested0 = new TestParametersLGeneric("l10LGenericNested0");
public TestParametersL10() {
// Default Constructor
}
-
+
/**
* Create a test parameter group.
- *
+ *
* @param name the parameter group name
*/
public TestParametersL10(final String name) {
- this.name = name;
+ super(name);
TestParametersLGeneric l10LGenericNestedMapVal0 = new TestParametersLGeneric("l10LGenericNestedMapVal0");
l10LGenericNestedMap.put(l10LGenericNestedMapVal0.getName(), l10LGenericNestedMapVal0);
return l10LGenericNestedMap;
}
- public void setName(String name) {
- this.name = name;
- }
-
public void setL10IntField(int l10IntField) {
this.l10IntField = l10IntField;
}
/**
* Trigger a validation message.
- *
+ *
* @param level Number of levels to recurse before stopping
*/
public void triggerValidationStatus(final ValidationStatus triggerStatus, int level) {
}
}
- @Override
- public String getName() {
- return this.name;
- }
-
@Override
public GroupValidationResult validate() {
- GroupValidationResult validationResult = new GroupValidationResult(this);
+ GroupValidationResult validationResult = super.validate();
if (l10StringField == null || l10StringField.trim().length() == 0) {
validationResult.setResult("l10StringField", ValidationStatus.INVALID,
package org.onap.policy.common.parameters.testclasses;
import org.onap.policy.common.parameters.GroupValidationResult;
-import org.onap.policy.common.parameters.ParameterGroup;
+import org.onap.policy.common.parameters.ParameterGroupImpl;
import org.onap.policy.common.parameters.ValidationStatus;
import org.onap.policy.common.parameters.annotations.NotBlank;
import org.onap.policy.common.parameters.annotations.NotNull;
-public class TestParametersLGeneric implements ParameterGroup {
- private String name;
+public class TestParametersLGeneric extends ParameterGroupImpl {
private int lgenericIntField = 0;
@NotNull @NotBlank
* @param name the parameter group name
*/
public TestParametersLGeneric(final String name) {
- this.name = name;
+ super(name);
}
public int getLgenericIntField() {
return lgenericStringField;
}
- public void setName(String name) {
- this.name = name;
- }
-
public void setLgenericIntField(int lgenericIntField) {
this.lgenericIntField = lgenericIntField;
}
}
- @Override
- public String getName() {
- return this.name;
- }
-
@Override
public GroupValidationResult validate() {
- GroupValidationResult validationResult = new GroupValidationResult(this);
+ GroupValidationResult validationResult = super.validate();
if ("lgenericStringField".equals(lgenericStringField)) {
validationResult.setResult("lgenericStringField", ValidationStatus.WARNING,
parameter group "l00NameFromFile" type "org.onap.policy.common.parameters.testclasses.TestParametersL00" CLEAN, parameter group has status CLEAN
- field "name" type "java.lang.String" value "l00NameFromFile" CLEAN, parameter has status CLEAN
field "l00IntField" type "int" value "1" CLEAN, parameter has status CLEAN
field "l00StringField" type "java.lang.String" value "l00 string field value from file" CLEAN, parameter has status CLEAN
parameter group "l00L10NestedNameFromFile" type "org.onap.policy.common.parameters.testclasses.TestParametersL10" CLEAN, parameter group has status CLEAN
- field "name" type "java.lang.String" value "l00L10NestedNameFromFile" CLEAN, parameter has status CLEAN
field "l10IntField" type "int" value "1" CLEAN, parameter has status CLEAN
field "l10StringField" type "java.lang.String" value "l00 L10 nested string field value from file" CLEAN, parameter has status CLEAN
parameter group "l10LGenericNested0NameFromFile" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" CLEAN, parameter group has status CLEAN
- field "name" type "java.lang.String" value "l10LGenericNested0NameFromFile" CLEAN, parameter has status CLEAN
field "lgenericIntField" type "int" value "1" CLEAN, parameter has status CLEAN
field "lgenericStringField" type "java.lang.String" value "l10 generic nested 0 string field value from file" CLEAN, parameter has status CLEAN
+ field "name" type "java.lang.String" value "l10LGenericNested0NameFromFile" CLEAN, parameter has status CLEAN
parameter group "l10LGenericNested1NameFromFile" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" CLEAN, parameter group has status CLEAN
- field "name" type "java.lang.String" value "l10LGenericNested1NameFromFile" CLEAN, parameter has status CLEAN
field "lgenericIntField" type "int" value "1" CLEAN, parameter has status CLEAN
field "lgenericStringField" type "java.lang.String" value "l10 generic nested 1 string field value from file" CLEAN, parameter has status CLEAN
+ field "name" type "java.lang.String" value "l10LGenericNested1NameFromFile" CLEAN, parameter has status CLEAN
parameter group map "l10LGenericNestedMap" CLEAN, parameter group map has status CLEAN
parameter group "L10Entry0Name" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" CLEAN, parameter group has status CLEAN
- field "name" type "java.lang.String" value "L10Entry0Name" CLEAN, parameter has status CLEAN
field "lgenericIntField" type "int" value "1" CLEAN, parameter has status CLEAN
field "lgenericStringField" type "java.lang.String" value "L10Entry0 value from file" CLEAN, parameter has status CLEAN
+ field "name" type "java.lang.String" value "L10Entry0Name" CLEAN, parameter has status CLEAN
parameter group "L10Entry1Name" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" CLEAN, parameter group has status CLEAN
- field "name" type "java.lang.String" value "L10Entry1Name" CLEAN, parameter has status CLEAN
field "lgenericIntField" type "int" value "1" CLEAN, parameter has status CLEAN
field "lgenericStringField" type "java.lang.String" value "L10Entry1 value from file" CLEAN, parameter has status CLEAN
+ field "name" type "java.lang.String" value "L10Entry1Name" CLEAN, parameter has status CLEAN
+ field "name" type "java.lang.String" value "l00L10NestedNameFromFile" CLEAN, parameter has status CLEAN
parameter group "l00GenericNestedNameFromFile" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" CLEAN, parameter group has status CLEAN
- field "name" type "java.lang.String" value "l00GenericNestedNameFromFile" CLEAN, parameter has status CLEAN
field "lgenericIntField" type "int" value "1" CLEAN, parameter has status CLEAN
field "lgenericStringField" type "java.lang.String" value "l00 generic nested string field value from file" CLEAN, parameter has status CLEAN
+ field "name" type "java.lang.String" value "l00GenericNestedNameFromFile" CLEAN, parameter has status CLEAN
parameter group map "l00LGenericNestedMap" CLEAN, parameter group map has status CLEAN
parameter group "L00Entry0Name" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" CLEAN, parameter group has status CLEAN
- field "name" type "java.lang.String" value "L00Entry0Name" CLEAN, parameter has status CLEAN
field "lgenericIntField" type "int" value "1" CLEAN, parameter has status CLEAN
field "lgenericStringField" type "java.lang.String" value "L00Entry0 value from file" CLEAN, parameter has status CLEAN
+ field "name" type "java.lang.String" value "L00Entry0Name" CLEAN, parameter has status CLEAN
parameter group "L00Entry1Name" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" CLEAN, parameter group has status CLEAN
- field "name" type "java.lang.String" value "L00Entry1Name" CLEAN, parameter has status CLEAN
field "lgenericIntField" type "int" value "1" CLEAN, parameter has status CLEAN
field "lgenericStringField" type "java.lang.String" value "L00Entry1 value from file" CLEAN, parameter has status CLEAN
+ field "name" type "java.lang.String" value "L00Entry1Name" CLEAN, parameter has status CLEAN
field "isSomeFlag" type "boolean" value "false" CLEAN, parameter has status CLEAN
field "someNonIsFlag" type "boolean" value "false" CLEAN, parameter has status CLEAN
+ field "name" type "java.lang.String" value "l00NameFromFile" CLEAN, parameter has status CLEAN
\ No newline at end of file
parameter group "l0Parameters" type "org.onap.policy.common.parameters.testclasses.TestParametersL00" CLEAN, parameter group has status CLEAN
- field "name" type "java.lang.String" value "l0Parameters" CLEAN, parameter has status CLEAN
field "l00IntField" type "int" value "0" CLEAN, parameter has status CLEAN
field "l00StringField" type "java.lang.String" value "Legal org.onap.policy.common.parameters.testclasses.TestParametersL00" CLEAN, parameter has status CLEAN
parameter group "l00L10Nested" type "org.onap.policy.common.parameters.testclasses.TestParametersL10" CLEAN, parameter group has status CLEAN
- field "name" type "java.lang.String" value "l00L10Nested" CLEAN, parameter has status CLEAN
field "l10IntField" type "int" value "0" CLEAN, parameter has status CLEAN
field "l10StringField" type "java.lang.String" value "Legal org.onap.policy.common.parameters.testclasses.TestParametersL10" CLEAN, parameter has status CLEAN
parameter group "l10LGenericNested0" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" CLEAN, parameter group has status CLEAN
- field "name" type "java.lang.String" value "l10LGenericNested0" CLEAN, parameter has status CLEAN
field "lgenericIntField" type "int" value "0" CLEAN, parameter has status CLEAN
field "lgenericStringField" type "java.lang.String" value "Legal org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" CLEAN, parameter has status CLEAN
+ field "name" type "java.lang.String" value "l10LGenericNested0" CLEAN, parameter has status CLEAN
parameter group "l10LGenericNested1" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" CLEAN, parameter group has status CLEAN
- field "name" type "java.lang.String" value "l10LGenericNested1" CLEAN, parameter has status CLEAN
field "lgenericIntField" type "int" value "0" CLEAN, parameter has status CLEAN
field "lgenericStringField" type "java.lang.String" value "Legal org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" CLEAN, parameter has status CLEAN
+ field "name" type "java.lang.String" value "l10LGenericNested1" CLEAN, parameter has status CLEAN
parameter group map "l10LGenericNestedMap" CLEAN, parameter group map has status CLEAN
parameter group "l10LGenericNestedMapVal0" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" CLEAN, parameter group has status CLEAN
- field "name" type "java.lang.String" value "l10LGenericNestedMapVal0" CLEAN, parameter has status CLEAN
field "lgenericIntField" type "int" value "0" CLEAN, parameter has status CLEAN
field "lgenericStringField" type "java.lang.String" value "Legal org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" CLEAN, parameter has status CLEAN
+ field "name" type "java.lang.String" value "l10LGenericNestedMapVal0" CLEAN, parameter has status CLEAN
parameter group "l10LGenericNestedMapVal1" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" CLEAN, parameter group has status CLEAN
- field "name" type "java.lang.String" value "l10LGenericNestedMapVal1" CLEAN, parameter has status CLEAN
field "lgenericIntField" type "int" value "0" CLEAN, parameter has status CLEAN
field "lgenericStringField" type "java.lang.String" value "Legal org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" CLEAN, parameter has status CLEAN
+ field "name" type "java.lang.String" value "l10LGenericNestedMapVal1" CLEAN, parameter has status CLEAN
+ field "name" type "java.lang.String" value "l00L10Nested" CLEAN, parameter has status CLEAN
parameter group "l00LGenericNested" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" CLEAN, parameter group has status CLEAN
- field "name" type "java.lang.String" value "l00LGenericNested" CLEAN, parameter has status CLEAN
field "lgenericIntField" type "int" value "0" CLEAN, parameter has status CLEAN
field "lgenericStringField" type "java.lang.String" value "Legal org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" CLEAN, parameter has status CLEAN
+ field "name" type "java.lang.String" value "l00LGenericNested" CLEAN, parameter has status CLEAN
parameter group map "l00LGenericNestedMap" CLEAN, parameter group map has status CLEAN
parameter group "l00LGenericNestedMapVal0" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" CLEAN, parameter group has status CLEAN
- field "name" type "java.lang.String" value "l00LGenericNestedMapVal0" CLEAN, parameter has status CLEAN
field "lgenericIntField" type "int" value "0" CLEAN, parameter has status CLEAN
field "lgenericStringField" type "java.lang.String" value "Legal org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" CLEAN, parameter has status CLEAN
+ field "name" type "java.lang.String" value "l00LGenericNestedMapVal0" CLEAN, parameter has status CLEAN
parameter group "l00LGenericNestedMapVal1" type "org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" CLEAN, parameter group has status CLEAN
- field "name" type "java.lang.String" value "l00LGenericNestedMapVal1" CLEAN, parameter has status CLEAN
field "lgenericIntField" type "int" value "0" CLEAN, parameter has status CLEAN
field "lgenericStringField" type "java.lang.String" value "Legal org.onap.policy.common.parameters.testclasses.TestParametersLGeneric" CLEAN, parameter has status CLEAN
+ field "name" type "java.lang.String" value "l00LGenericNestedMapVal1" CLEAN, parameter has status CLEAN
field "isSomeFlag" type "boolean" value "false" CLEAN, parameter has status CLEAN
field "someNonIsFlag" type "boolean" value "false" CLEAN, parameter has status CLEAN
+ field "name" type "java.lang.String" value "l0Parameters" CLEAN, parameter has status CLEAN
\ No newline at end of file