@Test public void testLoadQuantities() { WildcardMatchLoader loader = new WildcardMatchLoader(Arrays.asList("rune* < 3", "*whip>3", "nature*<5", "*rune > 30")); assertTrue(loader.load(new NamedQuantity("Nature Rune", 50))); assertFalse(loader.load(new NamedQuantity("Nature Impling", 5))); assertTrue(loader.load(new NamedQuantity("Abyssal whip", 4))); assertFalse(loader.load(new NamedQuantity("Abyssal dagger", 1))); assertTrue(loader.load(new NamedQuantity("Rune Longsword", 2))); }
@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);  }