List of usage examples for com.google.common.collect ImmutableSortedSet toArray
@Override
public <T> T[] toArray(T[] other)
From source file:com.facebook.buck.jvm.java.FakeJavaLibrary.java
public FakeJavaLibrary(BuildTarget target, SourcePathResolver resolver, ProjectFilesystem filesystem, ImmutableSortedSet<BuildRule> deps) { super(target, filesystem, resolver, deps.toArray(new BuildRule[deps.size()])); }
From source file:org.graylog2.rest.SearchResponseCsvWriter.java
@Override public void writeTo(SearchResponse searchResponse, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException { final CSVWriter csvWriter = new CSVWriter(new OutputStreamWriter(entityStream, StandardCharsets.UTF_8)); final ImmutableSortedSet<String> sortedFields = ImmutableSortedSet .copyOf(Iterables.concat(searchResponse.fields(), Lists.newArrayList("source", "timestamp"))); // write field headers csvWriter.writeNext(sortedFields.toArray(new String[sortedFields.size()])); // write result set in same order as the header row final String[] fieldValues = new String[sortedFields.size()]; for (ResultMessageSummary message : searchResponse.messages()) { int idx = 0; // first collect all values from the current message for (String fieldName : sortedFields) { final Object val = message.message().get(fieldName); fieldValues[idx++] = ((val == null) ? null : val.toString().replaceAll("\n", "\\\\n")); fieldValues[idx++] = ((val == null) ? null : val.toString().replaceAll("\r", "\\\\r")); }/* w w w. ja v a 2 s . com*/ // write the complete line, some fields might not be present in the message, so there might be null values csvWriter.writeNext(fieldValues); } if (csvWriter.checkError()) { LOG.error( "Encountered unspecified error when writing message result as CSV, result is likely malformed."); } csvWriter.close(); }
From source file:juicebox.mapcolorui.HeatmapRenderer.java
private void updatePreDefColors() { int arrSize = MainViewPanel.preDefMapColorGradient.size(); ImmutableSortedSet<Integer> set = ContiguousSet.create(Range.closed(0, arrSize), DiscreteDomain.integers()); Integer[] arrTmp = set.toArray(new Integer[arrSize]); final int[] arrScores = new int[arrSize]; for (int idx = 0; idx < arrSize; idx++) { arrScores[idx] = arrTmp[idx];//from ww w . j a v a 2s. com } preDefColorScale.updateColors(MainViewPanel.preDefMapColorGradient.toArray(new Color[arrSize]), arrScores); }