@Test(timeout = 1000) public void testExplosive() { String name = "archer" + Strings.repeat('e', 50000) + "s ring"; WildcardMatchLoader loader = new WildcardMatchLoader(Arrays.asList(name + "* < 100")); assertTrue(loader.load(new NamedQuantity(name, 50))); assertFalse(loader.load(new NamedQuantity(name, 150))); }
@Override public Boolean load(@Nonnull final NamedQuantity key) { if (Strings.isNullOrEmpty(key.getName())) { return false; } final String filteredName = key.getName().trim(); for (final ItemThreshold entry : itemThresholds) { if (WildcardMatcher.matches(entry.getItemName(), filteredName) && entry.quantityHolds(key.getQuantity())) { return true; } } return false; }
WildcardMatchLoader extends CacheLoader<NamedQuantity, Boolean> { @Override public Boolean load(@Nonnull final NamedQuantity key) { if (Strings.isNullOrEmpty(key.getName())) { return false; } final String filteredName = key.getName().trim(); for (final ItemThreshold entry : itemThresholds) { if (WildcardMatcher.matches(entry.getItemName(), filteredName) && entry.quantityHolds(key.getQuantity())) { return true; } } return false; } }
WildcardMatchLoader extends CacheLoader<NamedQuantity, Boolean> { @Override public Boolean load(@Nonnull final NamedQuantity key) { if (Strings.isNullOrEmpty(key.getName())) { return false; } final String filteredName = key.getName().trim(); for (final ItemThreshold entry : itemThresholds) { if (WildcardMatcher.matches(entry.getItemName(), filteredName) && entry.quantityHolds(key.getQuantity())) { return true; } } return false; } WildcardMatchLoader(List<String> configEntries); }
WildcardMatchLoader extends CacheLoader<NamedQuantity, Boolean> { @Override public Boolean load(@Nonnull final NamedQuantity key) { if (Strings.isNullOrEmpty(key.getName())) { return false; } final String filteredName = key.getName().trim(); for (final ItemThreshold entry : itemThresholds) { if (WildcardMatcher.matches(entry.getItemName(), filteredName) && entry.quantityHolds(key.getQuantity())) { return true; } } return false; } WildcardMatchLoader(List<String> configEntries); @Override Boolean load(@Nonnull final NamedQuantity key); }
WildcardMatchLoader extends CacheLoader<NamedQuantity, Boolean> { @Override public Boolean load(@Nonnull final NamedQuantity key) { if (Strings.isNullOrEmpty(key.getName())) { return false; } final String filteredName = key.getName().trim(); for (final ItemThreshold entry : itemThresholds) { if (WildcardMatcher.matches(entry.getItemName(), filteredName) && entry.quantityHolds(key.getQuantity())) { return true; } } return false; } WildcardMatchLoader(List<String> configEntries); @Override Boolean load(@Nonnull final NamedQuantity key);  }