AtlasArrayType extends AtlasType { @Override public boolean validateValue(Object obj, String objName, List<String> messages) { boolean ret = true; if (obj != null) { if (obj instanceof List || obj instanceof Set) { Collection objList = (Collection) obj; if (!isValidElementCount(objList.size())) { ret = false; messages.add(objName + ": incorrect number of values. found=" + objList.size() + "; expected: minCount=" + minCount + ", maxCount=" + maxCount); } int idx = 0; for (Object element : objList) { ret = elementType.validateValue(element, objName + "[" + idx + "]", messages) && ret; idx++; } } else if (obj.getClass().isArray()) { int arrayLen = Array.getLength(obj); if (!isValidElementCount(arrayLen)) { ret = false; messages.add(objName + ": incorrect number of values. found=" + arrayLen + "; expected: minCount=" + minCount + ", maxCount=" + maxCount); } for (int i = 0; i < arrayLen; i++) { ret = elementType.validateValue(Array.get(obj, i), objName + "[" + i + "]", messages) && ret; } } else { ret = false; messages.add(objName + "=" + obj + ": invalid value for type " + getTypeName()); } } return ret; } AtlasArrayType(AtlasType elementType);  AtlasArrayType(AtlasType elementType, int minCount, int maxCount);  AtlasArrayType(String elementTypeName);  AtlasArrayType(String elementTypeName, int minCount, int maxCount);  AtlasArrayType(String elementTypeName, AtlasTypeRegistry typeRegistry);  AtlasArrayType(String elementTypeName, int minCount, int maxCount, AtlasTypeRegistry typeRegistry); String getElementTypeName(); void setMinCount(int minCount); int getMinCount(); void setMaxCount(int maxCount); int getMaxCount(); AtlasType getElementType(); @Override void resolveReferences(AtlasTypeRegistry typeRegistry); @Override Collection<?> createDefaultValue(); @Override boolean isValidValue(Object obj); @Override boolean isValidValueForUpdate(Object obj); @Override Collection<?> getNormalizedValue(Object obj); @Override Collection<?> getNormalizedValueForUpdate(Object obj); @Override boolean validateValue(Object obj, String objName, List<String> messages); @Override boolean validateValueForUpdate(Object obj, String objName, List<String> messages); @Override AtlasType getTypeForAttribute();  }
@Test public void testArrayTypeValidateValue() { List<String> messages = new ArrayList<>(); for (Object value : validValues) { assertTrue(intArrayType.validateValue(value, "testObj", messages)); assertEquals(messages.size(), 0, "value=" + value); } for (Object value : invalidValues) { assertFalse(intArrayType.validateValue(value, "testObj", messages)); assertTrue(messages.size() > 0, "value=" + value); messages.clear(); } }