Java Code Examples for com.google.common.collect.Lists
The following code examples are extracted from open source projects. You can click to
vote up the examples that are useful to you.
Example 1
From project agit, under directory /agit/src/main/java/com/madgag/agit/filepath/.
Source file: CachingFilePathListMatcher.java

public CachingFilePathListMatcher(final List<FilePath> filePaths){ filteredPathsCache=new LruCache<String,List<FilePath>>(32){ @Override protected List<FilePath> create( String key){ List<FilePath> searchSpace; if (key.length() > 1) { searchSpace=filteredPathsCache.get(key.substring(0,key.length() - 1)); } else { searchSpace=filePaths; } return newArrayList(filter(searchSpace,new FilePathMatcher(key))); } } ; sortedPathsCache=new LruCache<String,List<FilePath>>(16){ @Override protected List<FilePath> create( String key){ Iterable<FilePath> filteredPaths=filteredPathsCache.get(key); return Lists.transform(ScoredPath.ORDERING.sortedCopy(transform(filteredPaths,scoreFor(key))),ScoredPath.PATH); } } ; }
Example 2
From project ades, under directory /src/main/java/com/cloudera/science/pig/.
Source file: Bin.java

@Override public Schema outputSchema(Schema input){ if (input.size() != 2) { throw new IllegalArgumentException("Expected two bags; input has != 2 fields"); } try { byte binType=checkField(input.getField(0)); byte quantileType=checkField(input.getField(1)); if (quantileType != DataType.DOUBLE) { throw new IllegalArgumentException("Expected doubles for quantile bag"); } List<FieldSchema> fields=Lists.newArrayList(new FieldSchema("bin",DataType.INTEGER),new FieldSchema("value",binType)); Schema tupleSchema=new Schema(fields); FieldSchema tupleFieldSchema=new FieldSchema("t",tupleSchema,DataType.TUPLE); Schema bagSchema=new Schema(tupleFieldSchema); bagSchema.setTwoLevelAccessRequired(true); FieldSchema bagFieldSchema=new FieldSchema("b",bagSchema,DataType.BAG); return new Schema(bagFieldSchema); } catch ( Exception e) { throw new RuntimeException(e); } }
Example 3
From project atlassian-rest-cli, under directory /rest-cli-runner/src/main/java/com/galeoconsulting/leonardinius/api/impl/.
Source file: ServletVelocityHelperImpl.java

@Override public List<SessionBean> getAllSessionBeans(){ List<SessionBean> list=Lists.newArrayList(); for ( Map.Entry<SessionId,ScriptSession> entry : sessionManager.listAllSessions().entrySet()) { list.add(SessionBean.newInstance(entry.getKey(),entry.getValue(),getUserProfile(entry.getValue().getCreator()))); } Collections.sort(list,new Comparator<SessionBean>(){ @Override public int compare( SessionBean o1, SessionBean o2){ long cmp; if (o2.getCreatedAtTimestamp() < 0) { cmp=-(o2.getCreatedAtTimestamp() - o1.getCreatedAtTimestamp()); } else { cmp=o1.getCreatedAtTimestamp() - o2.getCreatedAtTimestamp(); } return cmp == 0 ? 0 : cmp < 0 ? -1 : 1; } } ); return list; }
Example 4
From project airlift, under directory /bootstrap/src/main/java/io/airlift/bootstrap/.
Source file: ColumnPrinter.java

/** * Generate the output as a list of string lines * @return lines */ List<String> generate(){ List<String> lines=Lists.newArrayList(); StringBuilder workStr=new StringBuilder(); List<AtomicInteger> columnWidths=getColumnWidths(); List<Iterator<String>> dataIterators=getDataIterators(); Iterator<AtomicInteger> columnWidthIterator=columnWidths.iterator(); for ( String columnName : columnNames) { int thisWidth=columnWidthIterator.next().intValue(); printValue(workStr,columnName,thisWidth); } pushLine(lines,workStr); boolean done=false; while (!done) { boolean hadValue=false; Iterator<Iterator<String>> rowIterator=dataIterators.iterator(); for ( AtomicInteger width : columnWidths) { Iterator<String> thisDataIterator=rowIterator.next(); if (thisDataIterator.hasNext()) { hadValue=true; String value=thisDataIterator.next(); printValue(workStr,value,width.intValue()); } else { printValue(workStr,"",width.intValue()); } } pushLine(lines,workStr); if (!hadValue) { done=true; } } return lines; }
Example 5
From project b1-pack, under directory /cli/src/main/java/org/b1/pack/cli/.
Source file: FileTools.java

public static List<String> getPath(File file){ LinkedList<String> result=Lists.newLinkedList(); do { String name=file.getName(); if (name.isEmpty() || name.equals(".") || name.equals("..")) { return result; } result.addFirst(name); file=file.getParentFile(); } while (file != null); return result; }
Example 6
From project android-bankdroid, under directory /src/com/liato/bankdroid/lockpattern/.
Source file: LockPatternUtils.java

/** * Deserialize a pattern. * @param string The pattern serialized with {@link #patternToString} * @return The pattern. */ public static List<LockPatternView.Cell> stringToPattern(String string){ List<LockPatternView.Cell> result=Lists.newArrayList(); final byte[] bytes=string.getBytes(); for (int i=0; i < bytes.length; i++) { byte b=bytes[i]; result.add(LockPatternView.Cell.of(b / 3,b % 3)); } return result; }
Example 7
From project artifactory-plugin, under directory /src/main/java/org/jfrog/hudson/action/.
Source file: ActionableHelper.java

/** * Get a list of {@link Builder}s that are related to the project. * @param project The project from which to get the builder. * @param type The type of the builder (the actual class) * @param < T > The type that the class represents * @return A list of builders that answer the class definition that are attached to the project. */ public static <T extends Builder>List<T> getBuilder(Project<?,?> project,Class<T> type){ List<T> result=Lists.newArrayList(); DescribableList<Builder,Descriptor<Builder>> builders=project.getBuildersList(); for ( Builder builder : builders) { if (type.isInstance(builder)) { result.add(type.cast(builder)); } } return result; }
Example 8
From project artimate, under directory /artimate-demo/src/main/java/com/ardor3d/extension/animation/skeletal/clip/.
Source file: JointChannel.java

@Override public AbstractAnimationChannel getSubchannelByTime(final String name,final float startTime,final float endTime){ if (startTime > endTime) { throw new IllegalArgumentException("startTime > endTime"); } final List<Float> times=Lists.newArrayList(); final List<ReadOnlyQuaternion> rotations=Lists.newArrayList(); final List<ReadOnlyVector3> translations=Lists.newArrayList(); final List<ReadOnlyVector3> scales=Lists.newArrayList(); final JointData jData=new JointData(); updateSample(startTime,jData); times.add(0f); rotations.add(jData.getRotation()); translations.add(jData.getTranslation()); scales.add(jData.getScale()); for (int i=0; i < getSampleCount(); i++) { final float time=_times[i]; if (time > startTime && time < endTime) { times.add(time - startTime); rotations.add(_rotations[i]); translations.add(_translations[i]); scales.add(_scales[i]); } } updateSample(endTime,jData); times.add(endTime - startTime); rotations.add(jData.getRotation()); translations.add(jData.getTranslation()); scales.add(jData.getScale()); final float[] timesArray=new float[times.size()]; int i=0; for ( final float time : times) { timesArray[i++]=time; } return newChannel(name,timesArray,rotations.toArray(new ReadOnlyQuaternion[rotations.size()]),translations.toArray(new ReadOnlyVector3[translations.size()]),scales.toArray(new ReadOnlyVector3[scales.size()])); }
Example 9
From project atlas, under directory /src/main/java/com/ning/atlas/.
Source file: ActualDeployment.java

private void install(List<LifecycleListener> listeners,ListeningExecutorService es){ log.info("starting install"); bus.startNewStage(); fire(Events.startInstall,listeners); List<Pair<Host,List<Uri<Installer>>>> floggles=Lists.newArrayList(); for ( Host host : map.findLeaves()) { floggles.add(Pair.of(host,host.getInstallationUris())); } performInstalls(es,floggles); fire(Events.finishInstall,listeners); log.info("finished install"); }
Example 10
From project atunit, under directory /atunit/src/test/java/atunit/core/.
Source file: PluginUtilsTests.java

@Test public void tGetPluginClasses() throws Exception { List<Class<? extends AtUnitPlugin>> expectedPlugins=Lists.newArrayList(); expectedPlugins.add(DummyPlugin1.class); expectedPlugins.add(DummyPlugin2.class); expectedPlugins.add(DummyContainerPlugin.class); List<Class<? extends AtUnitPlugin>> plugins=PluginUtils.getPluginClasses(TestClasses.TestWithPlugins.class); assertEquals(expectedPlugins,plugins); }
Example 11
From project bitfluids, under directory /src/main/java/at/bitcoin_austria/bitfluids/.
Source file: BitFluidsMainActivity.java

private void restoreState(Bundle savedInstanceState){ Preconditions.checkNotNull(bitcoinTransactionListener); if (savedInstanceState != null) { state=(BitFluidsActivityState)savedInstanceState.getSerializable("state"); } if (state == null) { state=new BitFluidsActivityState(); } bitcoinTransactionListener.addHashes(state.getTransactionItems()); list_view_adapter=new ArrayAdapter<TransactionItem>(this,R.layout.list_tx_item,Lists.reverse(state.getTransactionItems())); list_view_tx.setAdapter(list_view_adapter); }
Example 12
From project aim3-tu-berlin, under directory /seminar/exercises/datamining/core/src/test/java/de/tuberlin/dima/aim/exercises/three/.
Source file: AverageTemperaturePerMonthPactTest.java

Iterable<KeyValuePair<AverageTemperaturePerMonthPact.YearMonthKey,PactDouble>> expectedResults() throws IOException { List<KeyValuePair<AverageTemperaturePerMonthPact.YearMonthKey,PactDouble>> results=Lists.newArrayList(); for ( String line : readLines("/three/averageTemperatures.tsv")) { String[] tokens=SEPARATOR.split(line); results.add(new KeyValuePair<AverageTemperaturePerMonthPact.YearMonthKey,PactDouble>(new AverageTemperaturePerMonthPact.YearMonthKey(Short.parseShort(tokens[0]),Short.parseShort(tokens[1])),new PactDouble(Double.parseDouble(tokens[2])))); } return results; }
Example 13
From project AirCastingAndroidClient, under directory /src/main/java/pl/llp/aircasting/activity/.
Source file: SessionsActivity.java

@Override protected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); calibrateOldRecords(); setContentView(R.layout.sessions); getListView().setOnItemLongClickListener(this); dummySensor=new DummySensor(all); sensorAdapter=new SensorsAdapter(this,Lists.<SensorWrapper>newArrayList(),dummySensor); sensorAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); sensorAdapter.insert(dummySensor,ALL_ID); sensorSpinner.setAdapter(sensorAdapter); }
Example 14
From project android_packages_apps_Tag, under directory /src/com/android/apps/tag/.
Source file: MyTagList.java

protected SelectActiveTagDialog(Context context,Cursor cursor){ super(context); setTitle(context.getResources().getString(R.string.choose_my_tag)); ListView list=new ListView(context); mData=Lists.newArrayList(); mSelectAdapter=new SimpleAdapter(context,mData,android.R.layout.simple_list_item_1,new String[]{"title"},new int[]{android.R.id.text1}); list.setAdapter(mSelectAdapter); list.setOnItemClickListener(this); setView(list); setIcon(0); setButton(DialogInterface.BUTTON_POSITIVE,context.getString(android.R.string.cancel),this); setData(cursor); }
Example 15
From project annotare2, under directory /app/om/src/main/java/uk/ac/ebi/fg/annotare2/dao/dummy/.
Source file: DummyData.java

public static List<Submission> getSubmissions(User user){ return Lists.transform(new ArrayList<Integer>(userSubmissions.get(user.getId())),new Function<Integer,Submission>(){ public Submission apply( @Nullable Integer id){ return getSubmission(id); } } ); }
Example 16
From project appdriver, under directory /android/src/com/google/android/testing/nativedriver/client/.
Source file: AdbConnection.java

/** * Runs {@code adb} using the given arguments and under the configurationvalues passed to the constructor. * @param arguments the arguments to pass to the {@code adb} utility * @return a {@code Process} object representing the {@code adb} process */ protected Process runAdb(String... arguments){ List<String> commandLine=Lists.asList(adbPath,arguments); ProcessBuilder processBuilder=newProcessBuilder(commandLine); Map<String,String> environment=processBuilder.environment(); if (adbServerPort != null) { environment.put("ANDROID_ADB_SERVER_PORT",adbServerPort.toString()); } if (emulatorConsolePort != null) { environment.put("ANDROID_EMULATOR_CONSOLE_PORT",emulatorConsolePort.toString()); } if (emulatorAdbPort != null) { environment.put("ANDROID_EMULATOR_ADB_PORT",emulatorAdbPort.toString()); } try { return callProcessBuilderStart(processBuilder); } catch ( IOException exception) { throw new AdbException("An IOException occurred when starting ADB.",exception); } }
Example 17
From project Arecibo, under directory /collector/src/main/java/com/ning/arecibo/collector/process/.
Source file: CollectorEventProcessor.java

public void processEvent(final Event evt){ final List<Event> events=new ArrayList<Event>(); if (evt instanceof BatchedEvent) { events.addAll(((BatchedEvent)evt).getEvents()); } else { events.add(evt); } eventsReceived.getAndAdd(events.size()); final Collection<Event> filteredEvents=Lists.newArrayList(Iterables.filter(Iterables.transform(events,filter),Predicates.<Event>notNull())); eventsFiltered.addAndGet(events.size() - filteredEvents.size()); for ( final Event event : filteredEvents) { for ( final EventHandler handler : eventHandlers) { try { handler.handle(event); } catch ( RuntimeException ruEx) { log.warn("Exception handling event",ruEx); } } } }
Example 18
From project astyanax, under directory /src/main/java/com/netflix/astyanax/connectionpool/impl/.
Source file: HostConnectionPoolPartition.java

/** * Refresh the partition */ public synchronized void refresh(){ List<HostConnectionPool<CL>> pools=Lists.newArrayList(); for ( HostConnectionPool<CL> pool : this.pools) { if (!pool.isReconnecting()) { pools.add(pool); } } this.activePools.set(strategy.sortAndfilterPartition(pools,prioritize)); }
Example 19
From project atunit_1, under directory /test/atunit/guice/.
Source file: GuiceContainerTests.java

@Test public void tGenericFieldType() throws Exception { GuiceContainer container=new GuiceContainer(); Map<Field,Object> fieldValues=Maps.newHashMap(); List<String> stringList=Lists.newLinkedList(); fieldValues.put(GenericFieldType.class.getDeclaredField("stringList"),stringList); GenericFieldType gft=(GenericFieldType)container.createTest(GenericFieldType.class,fieldValues); assertSame(stringList,gft.stringList); }
Example 20
From project azkaban, under directory /azkaban/src/java/azkaban/serialization/de/.
Source file: ExecutableFlowDeserializer.java

private ExecutableFlow buildFlow(final String id,Iterable<String> roots,final Map<String,List<String>> dependencies,final Map<String,ExecutableFlow> jobs){ final ArrayList<ExecutableFlow> executableFlows=Lists.newArrayList(Iterables.transform(roots,new Function<String,ExecutableFlow>(){ @Override public ExecutableFlow apply( String root){ if (dependencies.containsKey(root)) { final ExecutableFlow dependeeFlow=buildFlow(id,dependencies.get(root),dependencies,jobs); if (dependeeFlow instanceof GroupedExecutableFlow) { return new MultipleDependencyExecutableFlow(id,buildFlow(id,Arrays.asList(root),Collections.<String,List<String>>emptyMap(),jobs),(ExecutableFlow[])dependeeFlow.getChildren().toArray()); } else { return new ComposedExecutableFlow(id,buildFlow(id,Arrays.asList(root),Collections.<String,List<String>>emptyMap(),jobs),dependeeFlow); } } else { if (!jobs.containsKey(root)) { throw new IllegalStateException(String.format("Expected job[%s] in jobs list[%s]",root,jobs)); } return jobs.get(root); } } } )); if (executableFlows.size() == 1) { return executableFlows.get(0); } else { return new GroupedExecutableFlow(id,executableFlows.toArray(new ExecutableFlow[executableFlows.size()])); } }
Example 21
From project bamboo-sonar-integration, under directory /bamboo-sonar-common/src/main/java/com/marvelution/bamboo/plugins/sonar/common/utils/.
Source file: SonarTaskUtils.java

/** * Get all the {@link Job}s that have a Sonar Task the specified {@link Predicate} * @param plan the {@link Plan} to get the {@link Job}s from * @param predicate the {@link Predicate} to use * @return the {@link List} of {@link Job}s */ public static List<Job> getJobsWithSonarTasks(Plan plan,Predicate<TaskDefinition> predicate){ List<Job> jobs=Lists.newArrayList(); if (plan instanceof Chain) { for ( Job job : ((Chain)plan).getAllJobs()) { if (Iterables.any(job.getBuildDefinition().getTaskDefinitions(),predicate)) { jobs.add(job); } } } else if (plan instanceof Buildable) { Job job=(Job)plan; if (Iterables.any(job.getBuildDefinition().getTaskDefinitions(),predicate)) { jobs.add(job); } } return jobs; }
Example 22
From project baseunits, under directory /src/main/java/jp/xet/baseunits/time/formatter/.
Source file: DetailedDurationFormatter.java

@Override public String format(Duration target,Locale locale){ Validate.notNull(target); Validate.notNull(locale); TimeUnitFormat format=new TimeUnitFormat(locale); List<TimeUnitAmount> amounts=divide(target); if (amounts.isEmpty()) { TimeUnit lastUnit=timeUnits[timeUnits.length - 1]; return format.format(new TimeUnitAmount(0,TIME_UNIT_MAP.get(lastUnit))); } List<String> sections=Lists.newArrayListWithCapacity(amounts.size()); for ( TimeUnitAmount amount : amounts) { sections.add(format.format(amount)); } return Joiner.on(' ').join(sections); }
Example 23
From project Betfair-Trickle, under directory /src/main/java/uk/co/onehp/trickle/controller/domain/.
Source file: DomainControllerImpl.java

private List<Bet> betsFromTodayOrLater(List<Bet> bets){ List<Bet> filteredBets; filteredBets=Lists.newArrayList(Iterables.filter(bets,new Predicate<Bet>(){ @Override public boolean apply( Bet bet){ return bet.getHorse().getRace().getStartTime().isAfter(new LocalDateTime().withHourOfDay(0).withMinuteOfHour(0).withSecondOfMinute(0)); } } )); return filteredBets; }
Example 24
From project build-info, under directory /build-info-api/src/main/java/org/jfrog/build/api/.
Source file: Build.java

public void addStatus(PromotionStatus promotionStatus){ if (statuses == null) { statuses=Lists.newArrayList(); } statuses.add(promotionStatus); }
Example 25
From project C-Cat, under directory /core/src/main/java/gov/llnl/ontology/mains/.
Source file: SelectRandomTaggedNodes.java

public static List<String> loadDocKeys(String keyFile) throws Exception { BufferedReader br=new BufferedReader(new FileReader(keyFile)); List<String> docKeys=Lists.newArrayList(); for (String line=null; (line=br.readLine()) != null; ) docKeys.add(line.trim()); return docKeys; }
Example 26
From project Cafe, under directory /webapp/src/org/openqa/selenium/android/.
Source file: AndroidTouchScreen.java

public void singleTap(Coordinates where){ Point toTap=where.getLocationOnScreen(); List<MotionEvent> motionEvents=Lists.newArrayList(); long downTime=SystemClock.uptimeMillis(); motionEvents.add(getMotionEvent(downTime,downTime,MotionEvent.ACTION_DOWN,toTap)); motionEvents.add(getMotionEvent(downTime,downTime,MotionEvent.ACTION_UP,toTap)); sendMotionEvents(motionEvents); }
Example 27
From project cdk, under directory /cmdln-generator/src/main/java/org/richfaces/cdk/.
Source file: CommandLineGenerator.java

private List<String> getDefaultTemplateIncludes(){ List<String> includes=Lists.newLinkedList(); for ( String xmlInclude : XML_INCLUDES) { includes.add(DEFAULT_TEMPLATES_ROOT + xmlInclude); } return includes; }