}
}
// If the user defined a strategy to fill the collection elements,
// we use it
PodamCollection collectionAnnotation = null;
AttributeStrategy<?> elementStrategy = null;
for (Annotation annotation : annotations) {
if (PodamCollection.class.isAssignableFrom(annotation.getClass())) {
collectionAnnotation = (PodamCollection) annotation;
break;
}
}
int nbrElements;
if (null != collectionAnnotation) {
nbrElements = collectionAnnotation.nbrElements();
elementStrategy = collectionAnnotation.collectionElementStrategy()
.newInstance();
} else {
nbrElements = strategy.getNumberOfCollectionElements(attributeType);
}
Object arrayElement = null;
Object array = Array.newInstance(componentType, nbrElements);
for (int i = 0; i < nbrElements; i++) {
// The default
if (null != elementStrategy
&& ObjectStrategy.class
.isAssignableFrom(collectionAnnotation
.collectionElementStrategy())
&& Object.class.equals(componentType)) {
LOG.debug("Element strategy is ObjectStrategy and array element is of type Object: using the ObjectStrategy strategy");
arrayElement = elementStrategy.getValue();
} else if (null != elementStrategy
&& !ObjectStrategy.class
.isAssignableFrom(collectionAnnotation
.collectionElementStrategy())) {
LOG.debug("Array elements will be filled using the following strategy: "
+ elementStrategy);
arrayElement = returnAttributeDataStrategyValue(componentType,
elementStrategy);