List of usage examples for com.google.common.collect ImmutableList forEach
default void forEach(Consumer<? super T> action)
From source file:com.spectralogic.ds3contractcomparator.print.htmlprinter.generators.row.HtmlRowGenerator.java
/** * Recursively traverse an object using reflection and constructs the rows that * represent the object using the specified function. *///from w ww . ja v a 2s . c om public static <T> ImmutableList<Row> createRows(final T object, final int indent, Function<RowAttributes, Row> function) { final Field[] fields = object.getClass().getDeclaredFields(); final ImmutableList.Builder<Row> builder = ImmutableList.builder(); for (final Field field : fields) { final String property = field.getName(); final Optional<String> value = getPropertyValue(object, property); final int fieldIndent = toFieldIndent(indent, object, field); if (value.isPresent()) { if (field.getType() == ImmutableList.class) { builder.add(new NoChangeRow(fieldIndent, property, "")); final ImmutableList<?> objList = getListPropertyFromObject(field, object); objList.forEach(obj -> builder.addAll(createRows(obj, fieldIndent + 1, function))); } else { final RowAttributes attributes = new RowAttributes(fieldIndent, property, value.get()); builder.add(function.apply(attributes)); } } } return builder.build(); }
From source file:com.facebook.buck.cli.AuditModulesCommand.java
private static void dumpModuleInformationInRawFormat(Console console, ImmutableList<AuditModuleInformation> modules) { modules.forEach(module -> dumpModuleInformationInRawFormat(console.getStdOut(), module)); }
From source file:com.spectralogic.ds3contractcomparator.print.utils.PrinterUtils.java
/** * Converts an {@link ImmutableList} of {@link Ds3Param} into an {@link ImmutableMap} of * parameter names and {@link Ds3Param}/*from www. j a v a2 s . c om*/ */ public static ImmutableMap<String, Ds3Param> toParamMap(final ImmutableList<Ds3Param> params) { if (isEmpty(params)) { return ImmutableMap.of(); } final ImmutableMap.Builder<String, Ds3Param> builder = ImmutableMap.builder(); params.forEach(param -> builder.put(param.getName(), param)); return builder.build(); }
From source file:org.locationtech.geogig.test.integration.remoting.RemotesIndexTestSupport.java
public static Map<Ref, List<Index>> createIndexes(Repository repo) { Map<Ref, List<Index>> indexes = new HashMap<>(); ImmutableList<Ref> branches = repo.command(BranchListOp.class).call(); branches.forEach(ref -> indexes.put(ref, createIndexes(repo, ref))); return indexes; }
From source file:com.spectralogic.ds3contractcomparator.print.utils.PrinterUtils.java
/** * Gets the union of names of all params within two {@link ImmutableList} of {@link Ds3Param} *//* ww w . ja va 2 s . c o m*/ public static ImmutableSet<String> getParamNameUnion(final ImmutableList<Ds3Param> oldParams, final ImmutableList<Ds3Param> newParams) { final ImmutableSet.Builder<String> builder = ImmutableSet.builder(); if (hasContent(oldParams)) { oldParams.forEach(param -> builder.add(param.getName())); } if (hasContent(newParams)) { newParams.forEach(param -> builder.add(param.getName())); } return builder.build(); }
From source file:com.spectralogic.ds3contractcomparator.Ds3ApiSpecComparatorImpl.java
/** * Creates an {@link ImmutableMap} of {@link Ds3Request#getName()} to {@link Ds3Request} for easy searching *///from ww w . j a v a2 s . co m static ImmutableMap<String, Ds3Request> toRequestMap(final ImmutableList<Ds3Request> requests) { if (isEmpty(requests)) { return ImmutableMap.of(); } final ImmutableMap.Builder<String, Ds3Request> builder = ImmutableMap.builder(); requests.forEach(request -> builder.put(request.getName(), request)); return builder.build(); }
From source file:com.spectralogic.ds3contractcomparator.print.simpleprinter.Ds3EnumConstantDiffSimplePrinter.java
/** * Converts an {@link ImmutableList} of {@link Ds3Property} into an {@link ImmutableMap} of * property names and {@link Ds3Property} *//* w w w. j a v a 2 s. co m*/ private static ImmutableMap<String, Ds3Property> toPropertyMap(final ImmutableList<Ds3Property> properties) { if (isEmpty(properties)) { return ImmutableMap.of(); } final ImmutableMap.Builder<String, Ds3Property> builder = ImmutableMap.builder(); properties.forEach(property -> builder.put(property.getName(), property)); return builder.build(); }
From source file:com.spectralogic.ds3contractcomparator.Ds3ApiSpecComparatorImpl.java
/** * Gets the union of all {@link Ds3Request} names in both lists *///from w w w. j av a2s . c o m static ImmutableSet<String> getRequestNameUnion(final ImmutableList<Ds3Request> oldRequests, final ImmutableList<Ds3Request> newRequests) { final ImmutableSet.Builder<String> builder = ImmutableSet.builder(); if (ConverterUtil.hasContent(oldRequests)) { oldRequests.forEach(request -> builder.add(request.getName())); } if (ConverterUtil.hasContent(newRequests)) { newRequests.forEach(request -> builder.add(request.getName())); } return builder.build(); }
From source file:com.spectralogic.ds3contractcomparator.print.simpleprinter.Ds3EnumConstantDiffSimplePrinter.java
/** * Gets the union of names of all properties within two {@link ImmutableList} of {@link Ds3Property} */// w w w . ja v a 2s .c o m private static ImmutableSet<String> getPropertyNameUnion(final ImmutableList<Ds3Property> oldProperties, final ImmutableList<Ds3Property> newProperties) { final ImmutableSet.Builder<String> builder = ImmutableSet.builder(); if (hasContent(oldProperties)) { oldProperties.forEach(property -> builder.add(property.getName())); } if (hasContent(newProperties)) { newProperties.forEach(property -> builder.add(property.getName())); } return builder.build(); }
From source file:com.spectralogic.ds3contractcomparator.print.simpleprinter.Ds3AnnotationDiffSimplePrinter.java
/** * Converts an {@link ImmutableList} of {@link Ds3AnnotationElement} into an {@link ImmutableMap} of * annotation names and {@link Ds3AnnotationElement} */// w w w. ja va 2 s . c o m private static ImmutableMap<String, Ds3AnnotationElement> toAnnotationElementMap( final ImmutableList<Ds3AnnotationElement> elements) { if (isEmpty(elements)) { return ImmutableMap.of(); } final ImmutableMap.Builder<String, Ds3AnnotationElement> builder = ImmutableMap.builder(); elements.forEach(element -> builder.put(element.getName(), element)); return builder.build(); }