List of usage examples for com.google.common.base Predicates equalTo
public static <T> Predicate<T> equalTo(@Nullable T target)
From source file:ezbake.security.service.processor.EzSecurityHandler.java
protected Set<String> filterCommunityAuthorizations(Set<String> auths, Set<String> appAuths, Set<String> targetAppAuths, List<String> chain) throws AppNotRegisteredException { // Set up the filter by intersecting all apps if (targetAppAuths != null) { appAuths.retainAll(targetAppAuths); }/*from w w w . j ava 2 s .c o m*/ if (chain != null) { for (String securityIdLink : chain) { appAuths.addAll(Sets.newHashSet( fetchApplication(securityIdLink).getRegistration().getCommunityAuthorizations())); } } auths = Sets.intersection(auths, appAuths); return Sets.filter(auths, Predicates.and(Predicates.notNull(), Predicates.not(Predicates.equalTo("")))); }
From source file:ezbake.security.service.processor.EzSecurityHandler.java
protected Set<String> filterAuthorizations(Set<String> auths, Set<String> appAuths, Set<String> targetAppAuths, Set<String> preFiltered, List<String> chain) throws AppNotRegisteredException { if (preFiltered != null) { appAuths = Sets.intersection(appAuths, preFiltered); } else if (chain != null && !chain.isEmpty()) { appAuths = getAuthorizationsFromChain(Sets.newHashSet(chain), appAuths); }/* ww w .ja va2 s .c o m*/ auths = Sets.intersection(auths, appAuths); if (targetAppAuths != null) { auths = Sets.intersection(auths, targetAppAuths); } return Sets.filter(auths, Predicates.and(Predicates.notNull(), Predicates.not(Predicates.equalTo("")))); }
From source file:net.pterodactylus.sone.core.Core.java
/** * Loads the configuration.// www . jav a 2 s. c om */ private void loadConfiguration() { /* create options. */ options.addIntegerOption("InsertionDelay", new DefaultOption<Integer>(60, new IntegerRangePredicate(0, Integer.MAX_VALUE), new OptionWatcher<Integer>() { @Override public void optionChanged(Option<Integer> option, Integer oldValue, Integer newValue) { SoneInserter.setInsertionDelay(newValue); } })); options.addIntegerOption("PostsPerPage", new DefaultOption<Integer>(10, new IntegerRangePredicate(1, Integer.MAX_VALUE))); options.addIntegerOption("ImagesPerPage", new DefaultOption<Integer>(9, new IntegerRangePredicate(1, Integer.MAX_VALUE))); options.addIntegerOption("CharactersPerPost", new DefaultOption<Integer>(400, Predicates.<Integer>or(new IntegerRangePredicate(50, Integer.MAX_VALUE), Predicates.equalTo(-1)))); options.addIntegerOption("PostCutOffLength", new DefaultOption<Integer>(200, Predicates.<Integer>or(new IntegerRangePredicate(50, Integer.MAX_VALUE), Predicates.equalTo(-1)))); options.addBooleanOption("RequireFullAccess", new DefaultOption<Boolean>(false)); options.addIntegerOption("PositiveTrust", new DefaultOption<Integer>(75, new IntegerRangePredicate(0, 100))); options.addIntegerOption("NegativeTrust", new DefaultOption<Integer>(-25, new IntegerRangePredicate(-100, 100))); options.addStringOption("TrustComment", new DefaultOption<String>("Set from Sone Web Interface")); options.addBooleanOption("ActivateFcpInterface", new DefaultOption<Boolean>(false, new OptionWatcher<Boolean>() { @Override @SuppressWarnings("synthetic-access") public void optionChanged(Option<Boolean> option, Boolean oldValue, Boolean newValue) { fcpInterface.setActive(newValue); } })); options.addIntegerOption("FcpFullAccessRequired", new DefaultOption<Integer>(2, new OptionWatcher<Integer>() { @Override @SuppressWarnings("synthetic-access") public void optionChanged(Option<Integer> option, Integer oldValue, Integer newValue) { fcpInterface.setFullAccessRequired(FullAccessRequired.values()[newValue]); } })); loadConfigurationValue("InsertionDelay"); loadConfigurationValue("PostsPerPage"); loadConfigurationValue("ImagesPerPage"); loadConfigurationValue("CharactersPerPost"); loadConfigurationValue("PostCutOffLength"); options.getBooleanOption("RequireFullAccess") .set(configuration.getBooleanValue("Option/RequireFullAccess").getValue(null)); loadConfigurationValue("PositiveTrust"); loadConfigurationValue("NegativeTrust"); options.getStringOption("TrustComment") .set(configuration.getStringValue("Option/TrustComment").getValue(null)); options.getBooleanOption("ActivateFcpInterface") .set(configuration.getBooleanValue("Option/ActivateFcpInterface").getValue(null)); options.getIntegerOption("FcpFullAccessRequired") .set(configuration.getIntValue("Option/FcpFullAccessRequired").getValue(null)); /* load known Sones. */ int soneCounter = 0; while (true) { String knownSoneId = configuration.getStringValue("KnownSone/" + soneCounter++ + "/ID").getValue(null); if (knownSoneId == null) { break; } synchronized (knownSones) { knownSones.add(knownSoneId); } } /* load Sone following times. */ soneCounter = 0; while (true) { String soneId = configuration.getStringValue("SoneFollowingTimes/" + soneCounter + "/Sone") .getValue(null); if (soneId == null) { break; } long time = configuration.getLongValue("SoneFollowingTimes/" + soneCounter + "/Time") .getValue(Long.MAX_VALUE); synchronized (soneFollowingTimes) { soneFollowingTimes.put(soneId, time); } ++soneCounter; } /* load bookmarked posts. */ int bookmarkedPostCounter = 0; while (true) { String bookmarkedPostId = configuration .getStringValue("Bookmarks/Post/" + bookmarkedPostCounter++ + "/ID").getValue(null); if (bookmarkedPostId == null) { break; } synchronized (bookmarkedPosts) { bookmarkedPosts.add(bookmarkedPostId); } } }