List of usage examples for com.google.common.collect Iterables filter
@GwtIncompatible("Class.isInstance") @CheckReturnValue public static <T> Iterable<T> filter(final Iterable<?> unfiltered, final Class<T> desiredType)
From source file:org.apache.isis.viewer.wicket.model.links.LinkAndLabel.java
public static List<LinkAndLabel> positioned(final List<LinkAndLabel> entityActionLinks, final ActionLayout.Position position) { return Lists.newArrayList(Iterables.filter(entityActionLinks, Predicates.positioned(position))); }
From source file:org.polarsys.reqcycle.traceability.types.configuration.typeconfiguration.util.ConfigUtils.java
public static Iterable<CustomType> getCustomTypeSubTypeOf(TypeConfigContainer container, final String id) { return Iterables.filter(Iterables.filter(container.getTypes(), new Predicate<Type>() { public boolean apply(Type t) { if (t instanceof CustomType) { CustomType custom = (CustomType) t; return id.equals(custom.getSuperType().getTypeId()); }//ww w .ja v a2s . c o m return false; } }), CustomType.class); }
From source file:org.trancecode.concurrent.TcFutures.java
public static <T> Iterable<Future<T>> notDone(final Iterable<Future<T>> tasks) { final Predicate<Future<T>> filter = FuturePredicates.isDone(); return Iterables.filter(tasks, Predicates.not(filter)); }
From source file:org.obiba.opal.web.magma.ClientErrorDtos.java
public static ClientErrorDto.Builder getErrorMessage(Response.StatusType responseStatus, String errorStatus, String... args) {//from www .j a va 2s . c o m ClientErrorDto.Builder builder = ClientErrorDto.newBuilder() // .setCode(responseStatus.getStatusCode()) // .setStatus(errorStatus == null ? "" : errorStatus); if (args != null) { builder.addAllArguments(Iterables.filter(Arrays.asList(args), new Predicate<String>() { @Override public boolean apply(@Nullable String s) { return s != null; } })); } return builder; }
From source file:com.brainardphotography.gravatar.GravatarParameters.java
public Iterable<Optional<GravatarParameter>> getNonEmptyParams() { return Iterables.filter(this, new OptionalPredicate()); }
From source file:org.eclipse.viatra.query.patternlanguage.emf.helper.EMFPatternLanguageHelper.java
/** * Returns an iterable of package imports in a selected pattern model. If an import package is an unresolvable * proxy, it is omitted.//from ww w. ja va2 s.c o m * * @param model */ public static Iterable<PackageImport> getPackageImportsIterable(PatternModel model) { XImportSection imports = model.getImportPackages(); if (imports == null) { return ImmutableList.of(); } return Iterables.filter(imports.getPackageImport(), new Predicate<PackageImport>() { @Override public boolean apply(PackageImport pImport) { return !pImport.eIsProxy(); } }); }
From source file:com.threerings.tools.gxlate.spreadsheet.Folder.java
/** * Queries the contents of the given google doc folder and returns a new folder instance. *///w ww . j a v a2 s . c o m public static Folder open(String appName, String user, String password, String folderId) throws AuthenticationException, ServiceException, IOException { DocsService docs = new DocsService(appName); docs.setUserCredentials(user, password); DocumentListFeed documentListFeed = docs.getFeed( new URL("https://docs.google.com/feeds/default/private/full/folder%3A" + folderId + "/contents"), DocumentListFeed.class); Iterable<DocumentListEntry> contents = documentListFeed.getEntries(); SpreadsheetService spreadsheets = new SpreadsheetService(appName); spreadsheets.setUserCredentials(user, password); return new Folder(Iterables.filter(contents, Predicates.not(DELETED)), spreadsheets); }
From source file:org.apache.hadoop.metrics2.impl.MetricsRecords.java
private static MetricsTag getFirstTagByName(MetricsRecord record, String name) { return Iterables.getFirst(Iterables.filter(record.tags(), new MetricsTagPredicate(name)), null); }
From source file:com.android.tools.idea.structure.services.DeveloperServices.java
@NotNull public static Iterable<DeveloperService> getFor(@NotNull Module module, final ServiceCategory category) { return Iterables.filter(getAll(module), new Predicate<DeveloperService>() { @Override/*from w w w. j a v a 2 s. co m*/ public boolean apply(DeveloperService service) { return service.getCategory() == category; } }); }
From source file:Drafts.java
private static void perfTestMembers() throws Exception { List<Class<?>> classes = new LinkedList<Class<?>>(); JarFile jarFile = new JarFile(new File("/usr/lib/jvm/java-6-sun-1.6.0.20/jre/lib/rt.jar")); Enumeration<JarEntry> enums = jarFile.entries(); while (enums.hasMoreElements()) { JarEntry entry = enums.nextElement(); if (entry.getName().endsWith(".class")) { if (entry.getName().startsWith("javax/swing") || entry.getName().startsWith("java/awt") || entry.getName().startsWith("java/awt")) classes.add(Class .forName(entry.getName().replace('/', '.').substring(0, entry.getName().length() - 6))); }/*from w w w . ja v a 2 s .co m*/ } System.out.println("classes: " + classes.size()); long time = System.nanoTime(); for (int i = 0; i < 1000; i++) { for (Class<?> c : classes) { Iterables.filter(Reflect.findMethods(c), Reflect.annotatedBy(Deprecated.class)); } } long end = System.nanoTime(); System.out.println((end - time) + "ns = " + ((end - time) / 1000000) + "ms"); }