private static Stream<Entity> createEffectsEntitiesForSingleVariant(EntityType effectsEntityType, List<Attribute> effectFieldAttributeList, String descriptionFieldsString, Entity variantEntity) { List<Entity> listOfEffectsEntities = new ArrayList<>(); if (descriptionFieldsString == null) return listOfEffectsEntities.stream(); String[] descriptionFieldValues = descriptionFieldsString.split(","); for (String descriptionFieldValue : descriptionFieldValues) { String[] descriptionFieldPartValues = descriptionFieldValue.split("\\|", -1); DynamicEntity singleEffectsEntity = new DynamicEntity(effectsEntityType); int i = 0; for (Attribute attribute : effectFieldAttributeList) { if (i > descriptionFieldPartValues.length) { throw new RuntimeException( "Description of the attribute contains more values (pipe separated values) than the actual value"); } singleEffectsEntity.set(attribute.getName(), descriptionFieldPartValues[i]); i++; } singleEffectsEntity.set(VARIANT, variantEntity); listOfEffectsEntities.add(singleEffectsEntity); } return listOfEffectsEntities.stream(); } }
private static Stream<Entity> createEffectsEntitiesForSingleVariant(EntityType effectsEntityType, List<Attribute> effectFieldAttributeList, String descriptionFieldsString, Entity variantEntity) { List<Entity> listOfEffectsEntities = new ArrayList<>(); if (descriptionFieldsString == null) return listOfEffectsEntities.stream(); String[] descriptionFieldValues = descriptionFieldsString.split(","); for (String descriptionFieldValue : descriptionFieldValues) { String[] descriptionFieldPartValues = descriptionFieldValue.split("\\|", -1); DynamicEntity singleEffectsEntity = new DynamicEntity(effectsEntityType); int i = 0; for (Attribute attribute : effectFieldAttributeList) { if (i > descriptionFieldPartValues.length) { throw new RuntimeException( "Description of the attribute contains more values (pipe separated values) than the actual value"); } singleEffectsEntity.set(attribute.getName(), descriptionFieldPartValues[i]); i++; } singleEffectsEntity.set(VARIANT, variantEntity); listOfEffectsEntities.add(singleEffectsEntity); } return listOfEffectsEntities.stream(); } }
@Override public Entity next() { Entity entity = iterator.next(); if (isEmpty(entity.getString(ALLOWED_IDENTIFIER))) { DynamicEntity dynamicEntity = new DynamicEntity(getEntityType()); dynamicEntity.set(entity); entity = dynamicEntity; entity.set(ALLOWED_IDENTIFIER, String.valueOf(count.incrementAndGet())); } return entity; } };