Skip to content

Commit

Permalink
Simplified strategy application
Browse files Browse the repository at this point in the history
  • Loading branch information
daivanov committed Dec 22, 2016
1 parent 77c6713 commit 8f3d720
Showing 1 changed file with 15 additions and 29 deletions.
44 changes: 15 additions & 29 deletions src/main/java/uk/co/jemos/podam/api/PodamFactoryImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -1142,15 +1142,12 @@ private void fillCollection(ManufacturingContext manufacturingCtx,

// The default
Object element;
if (null != elementStrategy
&& (elementStrategy instanceof ObjectStrategy)
&& Object.class.equals(collectionElementType)) {
LOG.debug("Element strategy is ObjectStrategy and collection element is of type Object: using the ObjectStrategy strategy");
element = elementStrategy.getValue();
} else if (null != elementStrategy
&& !(elementStrategy instanceof ObjectStrategy)) {
if (null != elementStrategy &&
(!(elementStrategy instanceof ObjectStrategy)
|| collectionElementType.isAssignableFrom(Object.class))) {

element = TypeManufacturerUtil.returnAttributeDataStrategyValue(
collectionElementType, elementStrategy);
collectionElementType, elementStrategy);
} else {
element = manufactureAttributeValue(collection, manufacturingCtx,
collectionElementType, collectionElementType,
Expand Down Expand Up @@ -1473,21 +1470,14 @@ private Object getMapKeyOrElementValue(

Object retValue = null;

if (null != keyOrElementsArguments.getElementStrategy()
&& ObjectStrategy.class.isAssignableFrom(keyOrElementsArguments
.getElementStrategy().getClass())
&& Object.class.equals(keyOrElementsArguments
.getKeyOrValueType())) {
LOG.debug("Element strategy is ObjectStrategy and Map key or value type is of type Object: using the ObjectStrategy strategy");
retValue = keyOrElementsArguments.getElementStrategy().getValue();
} else if (null != keyOrElementsArguments.getElementStrategy()
&& !ObjectStrategy.class
.isAssignableFrom(keyOrElementsArguments
.getElementStrategy().getClass())) {
retValue = TypeManufacturerUtil.returnAttributeDataStrategyValue(
keyOrElementsArguments.getKeyOrValueType(),
keyOrElementsArguments.getElementStrategy());
AttributeStrategy<?> strategy = keyOrElementsArguments.getElementStrategy();
if (null != strategy &&
(!(strategy instanceof ObjectStrategy)
|| keyOrElementsArguments.getKeyOrValueType().isAssignableFrom(Object.class))) {

retValue = TypeManufacturerUtil.returnAttributeDataStrategyValue(
keyOrElementsArguments.getKeyOrValueType(),
strategy);
} else {

retValue = manufactureAttributeValue(
Expand Down Expand Up @@ -1577,15 +1567,11 @@ private Object resolveArrayElementValue(Object pojo,

// The default
if (null != elementStrategy
&& (elementStrategy instanceof ObjectStrategy)
&& 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
&& !(elementStrategy instanceof ObjectStrategy)) {
&& (!(elementStrategy instanceof ObjectStrategy)
|| componentType.isAssignableFrom(Object.class))) {

arrayElement = TypeManufacturerUtil.returnAttributeDataStrategyValue(componentType,
elementStrategy);

} else {

arrayElement = manufactureAttributeValue(array, manufacturingCtx,
Expand Down

0 comments on commit 8f3d720

Please sign in to comment.