List of usage examples for com.google.common.collect Iterables getFirst
@Nullable public static <T> T getFirst(Iterable<? extends T> iterable, @Nullable T defaultValue)
From source file:org.apache.metron.common.field.transformation.SimpleFieldTransformation.java
@Override public Map<String, Object> map(Map<String, Object> input, List<String> outputField, LinkedHashMap<String, Object> fieldMappingConfig, Map<String, Object> sensorConfig, Context context) { Object value = (input == null) ? null : Iterables.getFirst(input.values(), null); return map(value, outputField.get(0)); }
From source file:com.facebook.buck.artifact_cache.DummyArtifactCache.java
@Override public ListenableFuture<Void> store(ArtifactInfo info, BorrowablePath output) { storeKey = Iterables.getFirst(info.getRuleKeys(), null); return Futures.immediateFuture(null); }
From source file:org.apache.druid.server.router.TimeBoundaryTieredBrokerSelectorStrategy.java
@Override public Optional<String> getBrokerServiceName(TieredBrokerConfig tierConfig, Query query) { // Somewhat janky way of always selecting highest priority broker for this type of query if (query instanceof TimeBoundaryQuery) { return Optional.of(Iterables.getFirst(tierConfig.getTierToBrokerMap().values(), tierConfig.getDefaultBrokerServiceName())); }//from www .java2 s .co m return Optional.absent(); }
From source file:nextmethod.web.razor.utils.MiscUtils.java
public static String createTestFilePath(final String... parts) { final List<String> pathParts = Lists.newArrayList(parts); final FileSystem fileSystem = FileSystems.getDefault(); String first = pathAsString(Iterables.getFirst(fileSystem.getRootDirectories(), null)); if (first != null && !first.startsWith(fileSystem.getSeparator())) { // Strip the last character if it equals the filesystem separator if (first.length() > 1 && first.endsWith(fileSystem.getSeparator())) { first = first.substring(0, first.length() - 1); }// w ww .ja va 2 s. com pathParts.add(0, first); } return Joiner.on(fileSystem.getSeparator()).join(pathParts); }
From source file:org.apache.brooklyn.entity.software.base.VanillaWindowsProcessImpl.java
@Override protected void preStart() { super.preStart(); sensors().set(RDP_PORT, 3389);//ww w .j a va 2s. co m sensors().set(RDP_PORT_CAMEL_CASE, 3389); WinRmMachineLocation loc = Iterables.getFirst(Iterables.filter(getLocations(), WinRmMachineLocation.class), null); if (loc != null) { sensors().set(WINRM_PORT, loc.getPort()); sensors().set(WINRM_PORT_SHORTEN, loc.getPort()); sensors().set(WINRM_PORT_CAMEL_CASE, loc.getPort()); } }
From source file:kihira.foxlib.common.EnumHeadType.java
private static GameProfile refreshGameProfile(GameProfile profile) { if (profile != null && !StringUtils.isNullOrEmpty(profile.getName())) { if (!profile.isComplete() || !profile.getProperties().containsKey("textures")) { //This would always need to get textures as textures aren't saved client side GameProfile gameprofile = MinecraftServer.getServer().func_152358_ax() .func_152655_a(profile.getName()); if (gameprofile != null) { Property property = (Property) Iterables.getFirst(gameprofile.getProperties().get("textures"), (Object) null); if (property == null) gameprofile = MinecraftServer.getServer().func_147130_as() .fillProfileProperties(gameprofile, true); profile = gameprofile;/*from w w w . j a v a 2 s . c om*/ } } } return profile; }
From source file:org.eclipse.xtext.xbase.ui.builder.EclipseGeneratorConfigProvider.java
@Override public GeneratorConfig get(EObject context) { GeneratorConfig result = new GeneratorConfig(); IProject project = null;//from w w w. ja v a 2 s . com if (context.eResource() != null) { Pair<IStorage, IProject> pair = Iterables .getFirst(storage2UriMapper.getStorages(context.eResource().getURI()), null); if (pair != null) { project = pair.getSecond(); } } xbaseBuilderPreferenceAccess.loadBuilderPreferences(result, project); return result; }
From source file:org.zalando.github.spring.pagination.LinkRelationExtractor.java
public Optional<LinkRelation> extractLinkRelation(String linkHeaderValue, String relation) { Iterable<String> splittedHeaderIterable = splitter.split(linkHeaderValue); Iterable<LinkRelation> linkRelations = Iterables.transform(splittedHeaderIterable, transformer); linkRelations = Iterables.filter(linkRelations, new RelationsPredicate(relation)); return Optional.fromNullable(Iterables.getFirst(linkRelations, null)); }
From source file:com.davidbracewell.wordnet.SynsetPathWalker.java
@Override public Synset next() { Synset toReturn = synset;/*from w w w. j a v a 2 s .co m*/ seen.add(toReturn.toString()); synset = Iterables.getFirst(Iterables.concat(synset.getRelatedSynsets(Relation.HYPERNYM), synset.getRelatedSynsets(Relation.HYPERNYM_INSTANCE)), null); if (synset != null && seen.contains(synset.toString())) { synset = null; } return toReturn; }
From source file:minium.web.internal.actions.AbstractWebInteraction.java
/** * Gets the first element.//from w w w .j av a 2 s . c o m * * @param elems the elems * @return the first element */ protected WebElement getFirstElement(Elements elems) { return Iterables.getFirst(elems.as(InternalWebElements.class).wrappedNativeElements(), null); }