List of usage examples for com.google.common.primitives Longs asList
public static List<Long> asList(long... backingArray)
From source file:eu.esdihumboldt.hale.common.instance.model.InstanceUtil.java
private static List<?> arrayToList(Object array) { if (array instanceof byte[]) { return Bytes.asList((byte[]) array); }//from w ww.j a va 2 s . c om if (array instanceof int[]) { return Ints.asList((int[]) array); } if (array instanceof short[]) { return Shorts.asList((short[]) array); } if (array instanceof long[]) { return Longs.asList((long[]) array); } if (array instanceof float[]) { return Floats.asList((float[]) array); } if (array instanceof double[]) { return Doubles.asList((double[]) array); } if (array instanceof char[]) { return Chars.asList((char[]) array); } if (array instanceof boolean[]) { return Booleans.asList((boolean[]) array); } return Arrays.asList((Object[]) array); }
From source file:org.voltcore.agreement.matcher.SiteFailureMatchers.java
static public final Matcher<SiteFailureMessage> siteFailureIs(final Donor<List<Pair<Long, Long>>> safeTxns, final Set<Long> decision, final long... survivors) { final Map<Long, Long> safeTxnIds = Maps.newHashMap(); for (Pair<Long, Long> sp : safeTxns.value()) { safeTxnIds.put(sp.getFirst(), sp.getSecond()); }/*from w w w . j a va 2s . com*/ final Set<Long> survivorSet = ImmutableSet.copyOf(Longs.asList(survivors)); return new TypeSafeMatcher<SiteFailureMessage>() { @Override public void describeTo(Description d) { d.appendText("SiteFailureMessage [").appendText("decision: ") .appendValueList("", ", ", "", decision).appendText(", survivors: ") .appendValueList("", ", ", "", Longs.asList(survivors)).appendText(", safeTxnIds: ") .appendValue(safeTxnIds).appendText("]"); } @Override protected boolean matchesSafely(SiteFailureMessage m) { return equalTo(survivorSet).matches(m.m_survivors) && equalTo(decision).matches(m.m_decision) && equalTo(safeTxnIds).matches(m.m_safeTxnIds); } }; }
From source file:org.immutables.generator.Intrinsics.java
public static Iterable<Long> $in(long[] elements) { return Longs.asList(elements); }
From source file:com.wdhis.util.CollectionsUtil.java
/** * long?List, ?Long. */ public static List<Long> asList(long... backingArray) { return Longs.asList(backingArray); }
From source file:org.glowroot.agent.fat.storage.GaugeValueDao.java
GaugeValueDao(DataSource dataSource, GaugeDao gaugeMetaDao, ConfigRepository configRepository, Clock clock) throws Exception { this.dataSource = dataSource; this.gaugeMetaDao = gaugeMetaDao; this.configRepository = configRepository; this.clock = clock; this.rollupConfigs = ImmutableList.copyOf(RollupConfig.buildRollupConfigs()); for (int i = 0; i <= rollupConfigs.size(); i++) { dataSource.syncTable("gauge_value_rollup_" + castUntainted(i), columns); dataSource.syncIndexes("gauge_value_rollup_" + castUntainted(i), ImmutableList.<Index>of(ImmutableIndex.of("gauge_value_rollup_" + castUntainted(i) + "_idx", ImmutableList.of("gauge_id", "capture_time", "value", "weight")))); }//from w ww . j a va 2 s . com List<Column> columns = Lists.newArrayList(); for (int i = 1; i <= rollupConfigs.size(); i++) { columns.add(ImmutableColumn.of("last_rollup_" + i + "_time", ColumnType.BIGINT)); } dataSource.syncTable("gauge_value_last_rollup_times", columns); List<String> columnNames = Lists.newArrayList(); for (int i = 1; i <= rollupConfigs.size(); i++) { columnNames.add("last_rollup_" + i + "_time"); } Joiner joiner = Joiner.on(", "); String selectClause = castUntainted(joiner.join(columnNames)); long[] lastRollupTimes = dataSource.query(new LastRollupTimesQuery(selectClause)); if (lastRollupTimes == null) { long[] values = new long[rollupConfigs.size()]; String valueClause = castUntainted(joiner.join(Longs.asList(values))); dataSource.update("insert into gauge_value_last_rollup_times (" + selectClause + ") values (" + valueClause + ")"); this.lastRollupTimes = new AtomicLongArray(values); } else { this.lastRollupTimes = new AtomicLongArray(lastRollupTimes); } // TODO initial rollup in case store is not called in a reasonable time }
From source file:co.cask.cdap.hive.objectinspector.StandardListObjectInspector.java
public List<?> getList(Object data) { if (data == null) { return null; }//from w w w . j ava 2s . c o m // We support List<Object>, Object[], and Collection<Object> // so we have to do differently. if (!(data instanceof List)) { if (data instanceof Collection) { data = Lists.newArrayList((Collection<?>) data); } else if (data instanceof Object[]) { data = java.util.Arrays.asList((Object[]) data); } else if (data instanceof byte[]) { data = Bytes.asList((byte[]) data); } else if (data instanceof int[]) { data = Ints.asList((int[]) data); } else if (data instanceof double[]) { data = Doubles.asList((double[]) data); } else if (data instanceof float[]) { data = Floats.asList((float[]) data); } else if (data instanceof short[]) { data = Shorts.asList((short[]) data); } else if (data instanceof long[]) { data = Longs.asList((long[]) data); } else if (data instanceof boolean[]) { data = Booleans.asList((boolean[]) data); } else { throw new UnsupportedOperationException("Data object is neither a Collection nor an array."); } } List<?> list = (List<?>) data; return list; }
From source file:com.b2international.commons.collect.LongSets.java
/** * Returns with a list containing all long values. * @param collection the collection of primitive longs * @return a list of long values./*from w ww. j a v a 2 s .c o m*/ */ public static List<Long> toList(final LongCollection collection) { checkNotNull(collection, "Long collection argument cannot be null."); collection.trimToSize(); return Longs.asList(collection.toArray()); }
From source file:com.todoroo.astrid.ui.ReminderControlSet.java
@Nullable @Override//w w w.ja v a2s.c o m public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = super.onCreateView(inflater, container, savedInstanceState); remindAdapter = new HiddenTopArrayAdapter(context, android.R.layout.simple_spinner_item, spinnerOptions); String[] modes = getResources().getStringArray(R.array.reminder_ring_modes); ArrayAdapter<String> modeAdapter = new ArrayAdapter<>(context, android.R.layout.simple_spinner_item, modes); modeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mode.setAdapter(modeAdapter); if (savedInstanceState != null) { taskId = savedInstanceState.getLong(EXTRA_TASK_ID); flags = savedInstanceState.getInt(EXTRA_FLAGS); randomReminder = savedInstanceState.getLong(EXTRA_RANDOM_REMINDER); List<Geofence> geofences = new ArrayList<>(); List<Parcelable> geofenceArray = savedInstanceState.getParcelableArrayList(EXTRA_GEOFENCES); for (Parcelable geofence : geofenceArray) { geofences.add((Geofence) geofence); } setup(Longs.asList(savedInstanceState.getLongArray(EXTRA_ALARMS)), geofences); } else { setup(currentAlarms(), geofenceService.getGeofences(taskId)); } addSpinner.setAdapter(remindAdapter); return view; }
From source file:eshioji.java8.twitter.FilterQuery.java
public void populate(AsyncHttpClient.BoundRequestBuilder req) { req.addParameter("count", count + ""); if (follow != null && follow.length > 0) { req.addParameter("follow", ON_COMMA.join(Longs.asList(follow))); }/*from w w w . ja v a2s. c o m*/ if (track != null && track.length > 0) { req.addParameter("track", ON_COMMA.join(track)); } if (locations != null && locations.length > 0) { req.addParameter("locations", toLocationsString(locations)); } if (language != null && language.length > 0) { req.addParameter("language", ON_COMMA.join(language)); } }
From source file:com.facebook.swift.codec.ArrayField.java
private static Function<long[], List<Long>> longArrayAsList() { return new Function<long[], List<Long>>() { @Nullable// w w w .ja v a2s . c o m @Override public List<Long> apply(@Nullable long[] input) { if (input == null) { return null; } return Longs.asList(input); } }; }