List of usage examples for com.google.common.collect Iterables contains
public static boolean contains(Iterable<?> iterable, @Nullable Object element)
From source file:edu.umn.msi.tropix.storage.core.authorization.impl.IterableAuthorizationProviderImpl.java
public Boolean canDelete(final String id, final String callerIdentity) { if (Iterables.contains(canDeleteIds, callerIdentity)) { return inPermission; } else {//from ww w. j a v a2 s. c o m return outPermission; } }
From source file:com.cinchapi.common.collect.Sequences.java
@SuppressWarnings("unchecked") public static <T> boolean contains(Object sequence, T element) { Preconditions.checkArgument(isSequence(sequence), sequence + " is not a valid sequence"); if (sequence instanceof Iterable) { return Iterables.contains((Iterable<T>) sequence, element); } else {//from w ww .ja v a 2 s. c om return stream(sequence).filter(Predicate.isEqual(element)).count() > 0; } }
From source file:com.bennavetta.vetinari.build.internal.phase.TemplatePhase.java
private TemplateEngine getTemplateEngine(Page page, Site site) { TemplateEngine templateEngine = null; // Use the second file extension, if any. The first is for the renderer. final String templateExtension = getFileExtension(getNameWithoutExtension(page.getPath().toString())); Optional<TemplateEngine> templateEngineFromExtension = Iterables.tryFind(templateEngines, t -> Iterables.contains(t.getFileExtensions(), templateExtension)); if (templateEngineFromExtension.isPresent()) { templateEngine = templateEngineFromExtension.get(); } else if (page.getMetadata().hasPath("templateEngine")) { final String templateEngineName = page.getMetadata().getString("templateEngine"); templateEngine = Iterables.find(templateEngines, t -> templateEngineName.equals(t.getName())); } else {/* w w w .j av a 2s.c o m*/ templateEngine = Iterables.find(templateEngines, t -> site.getDefaultTemplateEngine().equals(t.getName())); } return templateEngine; }
From source file:com.torodb.kvdocument.values.KvArray.java
public boolean contains(KvValue<?> element) { return Iterables.contains(this, element); }
From source file:com.torodb.torod.core.subdocument.values.ScalarArray.java
public boolean contains(ScalarValue<?> element) { return Iterables.contains(this, element); }
From source file:org.eclipse.xtext.graphview.behavior.visibility.RevealRequest.java
public boolean addToSelection(EditPart selectedEditPart) { if (!(selectedEditPart instanceof IInstanceModelEditPart)) return false; else if (Iterables.contains(revealedEditPartMap.getLayoutables(), selectedEditPart)) return selection.add((IInstanceModelEditPart) selectedEditPart); else/* w w w .j a v a 2s.c om*/ return addToSelection(selectedEditPart.getParent()); }
From source file:org.cs3.plunit.matcher.PrologResultsInAnyOrder.java
private boolean containsAll(Iterable<String> iterable, Object[] array) { for (Object string : array) { if (!Iterables.contains(iterable, string)) { return false; }/*from w ww.j ava 2s.co m*/ } return true; }
From source file:com.bennavetta.vetinari.template.TemplateLoader.java
@Inject public TemplateLoader(VetinariContext context, Set<TemplateEngine> templateEngines) { this.context = context; this.templateEngines = templateEngines; this.defaultTemplateEngine = Iterables.find(this.templateEngines, t -> t.getName().equals(this.context.getSiteConfig().getString("defaultTemplateEngine"))); this.templateCache = CacheBuilder.newBuilder().build(new CacheLoader<String, Template>() { @Override//from ww w . jav a 2 s. co m public Template load(String templateName) throws Exception { final Path templatePath = context.getTemplateRoot().resolve(templateName); final String extension = getFileExtension(templateName); final TemplateEngine engine = Iterables .tryFind(templateEngines, t -> Iterables.contains(t.getFileExtensions(), extension)) .or(defaultTemplateEngine); log.debug("Compiling template from {} with {}", templatePath, engine); String source = new String(Files.readAllBytes(templatePath), context.getContentEncoding()); log.trace("Read template source \"{}\"", source); return engine.compile(source); } }); }
From source file:org.jclouds.aws.s3.functions.BindRegionToXmlPayload.java
@Override public void bindToRequest(HttpRequest request, Object input) { input = input == null ? Iterables.get(defaultRegions, 0) : input; checkArgument(input instanceof String, "this binder is only valid for Region!"); String constraint = (String) input; String value = null;/* w w w. j a v a2 s.c om*/ if (Iterables.contains(defaultRegions, constraint)) { // nothing to bind as this is default. return; } else if (Iterables.contains(regions, constraint)) { value = constraint; } else { if (constraint.equals(Region.EU_WEST_1)) { value = "EU"; } else { logger.warn("region %s not in %s ", constraint, regions); value = constraint; } } String payload = String.format( "<CreateBucketConfiguration><LocationConstraint>%s</LocationConstraint></CreateBucketConfiguration>", value); super.bindToRequest(request, payload); request.getPayload().getContentMetadata().setContentType(MediaType.TEXT_XML); }
From source file:edu.umn.msi.tropix.storage.core.authorization.impl.IterableAuthorizationProviderImpl.java
private Boolean canRead(final String callerIdentity) { if (Iterables.contains(canReadIds, callerIdentity)) { return inPermission; } else {// w w w. jav a2 s . c om return outPermission; } }