List of usage examples for com.google.common.collect ImmutableSet builder
public static <E> Builder<E> builder()
From source file:org.onehippo.cms7.essentials.dashboard.restservices.RestServicesInstructionPackage.java
@Override public Set<String> groupNames() { final String restType = (String) getProperties().get(RestPluginConst.REST_TYPE); if (restType != null) { return new ImmutableSet.Builder<String>().add(restType).build(); }/*w ww .j a v a2s . com*/ return EssentialConst.DEFAULT_GROUPS; }
From source file:org.apache.gobblin.metrics.context.filter.AllContextFilter.java
@Override public Set<MetricContext> getMatchingContexts() { ImmutableSet.Builder<MetricContext> builder = ImmutableSet.builder(); addContextsRecursively(builder, RootMetricContext.get()); return builder.build(); }
From source file:ninja.leaping.permissionsex.sponge.PEXContextCalculator.java
void update(PermissionsExConfiguration config) { final ImmutableSet.Builder<Context> serverTagsBuild = ImmutableSet.builder(); for (String tag : config.getServerTags()) { serverTagsBuild.add(new Context(SERVER_TAG_KEY, tag)); }//w ww. j av a 2 s . c om this.serverTags = serverTagsBuild.build(); }
From source file:es.udc.pfc.gamelib.chess.pieces.ChessKing.java
@Override public final ImmutableSet<Position> getStandardMoves(final ChessBoard board) { final ImmutableSet.Builder<Position> moves = ImmutableSet.builder(); for (final int[] element : king) { final Position pos = board.getPositionFor(this).relative(element[0], element[1]); if (board.isValidPosition(pos) && (!board.isPieceAt(pos) || isEnemy(board.getPieceAt(pos)))) { moves.add(pos);//from w w w. j a v a 2 s . com } } return moves.build(); }
From source file:com.stackframe.sarariman.ContactsGlobalAudit.java
private Set<Contact> projectTimesheetContacts() throws SQLException { try (Connection connection = dataSource.getConnection(); PreparedStatement ps = connection .prepareStatement("SELECT contact FROM project_timesheet_contacts"); ResultSet rs = ps.executeQuery();) { ImmutableSet.Builder<Contact> setBuilder = ImmutableSet.<Contact>builder(); while (rs.next()) { setBuilder.add(contacts.get(rs.getInt("contact"))); }/*from w w w .j a v a2 s . c om*/ return setBuilder.build(); } }
From source file:org.gradle.platform.base.internal.VariantAspectExtractionStrategy.java
@Nullable @Override/*from w w w.ja v a 2 s. co m*/ public ModelSchemaAspectExtractionResult extract(ModelSchemaExtractionContext<?> extractionContext, final List<ModelPropertyExtractionResult<?>> propertyResults) { ImmutableSet.Builder<ModelProperty<?>> dimensionsBuilder = ImmutableSet.builder(); for (ModelPropertyExtractionResult<?> propertyResult : propertyResults) { ModelProperty<?> property = propertyResult.getProperty(); if (propertyResult.getGetter().isAnnotationPresent(Variant.class)) { Class<?> propertyType = property.getType().getRawClass(); if (!String.class.equals(propertyType) && !Named.class.isAssignableFrom(propertyType)) { throw invalidProperty(extractionContext, property, String.format( "@Variant annotation only allowed for properties of type String and %s, but property has type %s", Named.class.getName(), propertyType.getName())); } dimensionsBuilder.add(property); } if (propertyResult.getSetter() != null && propertyResult.getSetter().isAnnotationPresent(Variant.class)) { throw invalidProperty(extractionContext, property, "@Variant annotation is only allowed on getter methods"); } } ImmutableSet<ModelProperty<?>> dimensions = dimensionsBuilder.build(); if (dimensions.isEmpty()) { return null; } return new ModelSchemaAspectExtractionResult(new VariantAspect(dimensions)); }
From source file:es.udc.pfc.gamelib.chess.pieces.ChessKnight.java
@Override public final ImmutableSet<Position> getStandardMoves(final ChessBoard board) { final ImmutableSet.Builder<Position> moves = ImmutableSet.builder(); for (final int[] element : knight) { final Position pos = board.getPositionFor(this).relative(element[0], element[1]); if (board.isValidPosition(pos) && (!board.isPieceAt(pos) || isEnemy(board.getPieceAt(pos)))) { moves.add(pos);/*w ww.j a va2 s. co m*/ } } return moves.build(); }
From source file:com.stackframe.sarariman.TimesheetAudit.java
private Set<Project> projects(Iterable<Timesheet> timesheets) { ImmutableSet.Builder<Project> projects = ImmutableSet.<Project>builder(); for (Timesheet timesheet : timesheets) { for (TimesheetEntry entry : timesheet.getEntries()) { Task task = entry.getTask(); if (task.isBillable()) { Project project = task.getProject(); if (project != null) { // FIXME: Billable tasks should always have a project. projects.add(project); }/* ww w . j a v a 2 s . com*/ } } } return projects.build(); }
From source file:org.caleydo.view.lineup.internal.model.data.CategoricalGroupingAdapter.java
@Override public Set<Integer> apply(IRow in) { IDRow r = (IDRow) in;/*ww w . java2 s . c om*/ IDType idType = groups.getIdType(); Builder<Integer> builder = ImmutableSet.builder(); for (Integer id : r.getIDAs(idType)) { List<Group> gs = groups.getGroupOf(id); if (gs == null) continue; for (Group g : gs) { builder.add(g.getGroupIndex()); } } return builder.build(); }
From source file:com.smoketurner.notification.application.core.LongSetParam.java
@Override protected Set<Long> parse(final String input) throws Exception { if (Strings.isNullOrEmpty(input)) { return Collections.emptySet(); }/*from w w w . ja v a 2 s . c o m*/ final Iterable<String> splitter = Splitter.on(',').omitEmptyStrings().trimResults().split(input); final ImmutableSet.Builder<Long> builder = ImmutableSet.builder(); for (String value : splitter) { try { builder.add(Long.parseLong(value)); } catch (NumberFormatException ignore) { // ignore invalid numbers } } return builder.build(); }