private Collection<T> createInvalidCollectionOfSize(long size, ObjectCreator<T> itemCreator) { Collection<T> collection = new ArrayList<>((int) size); for (int i = 0; i < size; i++) { collection.add(itemCreator.getInvalidItem()); itemCreator.incrementInvalidNext(); } return collection; } }
private Collection<T> createValidCollectionOfSize(long size, ObjectCreator<T> itemCreator) { Collection<T> collection = new ArrayList<>((int) size); for (int i = 0; i < size; i++) { collection.add(itemCreator.getValidItem()); itemCreator.incrementValidNext(); } return collection; }
private void advanceToNextCreator() { creators[creatorIndex].setReturnOnlyValidItems(true); creatorIndex++; if (creators[creatorIndex].hasInvalidNext()) { creators[creatorIndex].setReturnOnlyValidItems(false); } else { advanceToNextCreator(); } } }
/** * Increment one of the invalid creators to the next valid item. This is different from the valid incrementor method * because for invalid items you want to get only one invalid object at a time to ensure that you test each invalid * item independently. This method also sets all other creators in the list to return valid items even if the * {@link ObjectCreator#getInvalidItem()} is called. */ public void incrementInvalidCreators() { if (creatorIndex >= creators.length) { return; } creators[creatorIndex].setReturnOnlyValidItems(false); if (creators[creatorIndex].hasInvalidNext()) { creators[creatorIndex].incrementInvalidNext(); } else { advanceToNextCreator(); } }
/** * Checks to see if any {@link ObjectCreator} has and additional invalid permutations that can be outputed. * * @return true if more invalid items are available from any creator, false otherwise. */ public boolean hasInvalidPermutations() { for (ObjectCreator<?> creator : creators) { if (creator.hasInvalidNext()) { return true; } } return false; }
/** * Increment all the valid creators to the next valid item. */ public void incrementValidCreators() { for (ObjectCreator<?> creator : creators) { creator.incrementValidNext(); } }
/** * @param creators the creators this incrementor should handle. */ public ObjectCreatorIncrementer(ObjectCreator<?>... creators) { this.creators = creators; for (ObjectCreator<?> creator : creators) { creator.setReturnOnlyValidItems(true); } this.creators[creatorIndex].setReturnOnlyValidItems(false); }
/** * Checks to see if any {@link ObjectCreator} has and additional valid permutations that can be outputed. * * @return true if more valid items are available from any creator, false otherwise. */ public boolean hasValidPermutations() { for (ObjectCreator<?> creator : creators) { if (creator.hasValidNext()) { return true; } } return false; }
/** * @return get the next invalid item. Note if this creator is in valid only mode than this method will return * a valid item instead. See {@link ObjectCreator#setReturnOnlyValidItems(boolean)} method. */ @Nullable public final T getInvalidItem() { if (returnOnlyValid) { return getValidItem(); } if (invalidTypes.isEmpty()) { return null; } return invalidTypes.get(invalidIndex % invalidTypes.size()); }
/** * Increment one of the invalid creators to the next valid item. This is different from the valid incrementor method * because for invalid items you want to get only one invalid object at a time to ensure that you test each invalid * item independently. This method also sets all other creators in the list to return valid items even if the * {@link ObjectCreator#getInvalidItem()} is called. */ public void incrementInvalidCreators() { if (creatorIndex >= creators.length) { return; } creators[creatorIndex].setReturnOnlyValidItems(false); if (creators[creatorIndex].hasInvalidNext()) { creators[creatorIndex].incrementInvalidNext(); } else { advanceToNextCreator(); } }
/** * Checks to see if any {@link ObjectCreator} has and additional invalid permutations that can be outputed. * * @return true if more invalid items are available from any creator, false otherwise. */ public boolean hasInvalidPermutations() { for (ObjectCreator<?> creator : creators) { if (creator.hasInvalidNext()) { return true; } } return false; }
/** * Increment all the valid creators to the next valid item. */ public void incrementValidCreators() { for (ObjectCreator<?> creator : creators) { creator.incrementValidNext(); } }
/** * @param creators the creators this incrementor should handle. */ public ObjectCreatorIncrementer(ObjectCreator<?>... creators) { this.creators = creators; for (ObjectCreator<?> creator : creators) { creator.setReturnOnlyValidItems(true); } this.creators[creatorIndex].setReturnOnlyValidItems(false); }
/** * Checks to see if any {@link ObjectCreator} has and additional valid permutations that can be outputed. * * @return true if more valid items are available from any creator, false otherwise. */ public boolean hasValidPermutations() { for (ObjectCreator<?> creator : creators) { if (creator.hasValidNext()) { return true; } } return false; }
/** * @return get the next invalid item. Note if this creator is in valid only mode than this method will return * a valid item instead. See {@link ObjectCreator#setReturnOnlyValidItems(boolean)} method. */ @Nullable public final T getInvalidItem() { if (returnOnlyValid) { return getValidItem(); } if (invalidTypes.isEmpty()) { return null; } return invalidTypes.get(invalidIndex % invalidTypes.size()); }
private Collection<T> createInvalidCollectionOfSize(long size, ObjectCreator<T> itemCreator) { Collection<T> collection = new ArrayList<>((int) size); for (int i = 0; i < size; i++) { collection.add(itemCreator.getInvalidItem()); itemCreator.incrementInvalidNext(); } return collection; } }
private Collection<T> createValidCollectionOfSize(long size, ObjectCreator<T> itemCreator) { Collection<T> collection = new ArrayList<>((int) size); for (int i = 0; i < size; i++) { collection.add(itemCreator.getValidItem()); itemCreator.incrementValidNext(); } return collection; }
private void advanceToNextCreator() { creators[creatorIndex].setReturnOnlyValidItems(true); creatorIndex++; if (creators[creatorIndex].hasInvalidNext()) { creators[creatorIndex].setReturnOnlyValidItems(false); } else { advanceToNextCreator(); } } }
if (itemCreator.hasInvalidNext()) { addInvalidType(createInvalidArrayOfSize(maxSize, itemCreator)); addInvalidType(createInvalidArrayOfSize(minSize, itemCreator));
private T[] createInvalidArrayOfSize(int size, ObjectCreator<T> itemCreator) { Collection<T> collection = new ArrayList<>(size); for (int i = 0; i < size; i++) { collection.add(itemCreator.getInvalidItem()); itemCreator.incrementInvalidNext(); } return toArray(collection, clazz); }