当前位置: 首页>>代码示例>>Java>>正文


Java Iterables.getFirst方法代码示例

本文整理汇总了Java中com.google.common.collect.Iterables.getFirst方法的典型用法代码示例。如果您正苦于以下问题:Java Iterables.getFirst方法的具体用法?Java Iterables.getFirst怎么用?Java Iterables.getFirst使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.common.collect.Iterables的用法示例。


在下文中一共展示了Iterables.getFirst方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getActueleWaarde

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
private Object getActueleWaarde(final MetaObject o, final GroepElement groepElement, final AttribuutElement attribuutElement) {
    final Object waarde;
    final MetaGroep groep = o.getGroep(groepElement);
    final MetaRecord sorteerRecord;
    if (groep.getGroepElement().isIdentiteitGroep()) {
        sorteerRecord = Iterables.getOnlyElement(groep.getRecords());
    } else {
        final List<MetaRecord> tempRecordList = new ArrayList<>(groep.getRecords());
        tempRecordList.sort(BerichtRecordComparatorFactory.maakComparator(berichtgegevens));
        sorteerRecord = Iterables.getFirst(tempRecordList, null);
    }
    if (sorteerRecord == null) {
        waarde = null;
    } else {
        final MetaAttribuut attribuut = sorteerRecord.getAttribuut(attribuutElement);
        waarde = attribuut == null ? null : attribuut.getWaarde();
    }
    return waarde;
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:20,代码来源:BerichtObjectComparator.java

示例2: topoSortViews

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
/**
 * Performs a topological sort using a depth-first search algorithm and returns a sorted list of
 * database views for the schema upgrade.
 *
 * @param allViews all of the database views bound into the target schema.
 * @param index a complete index of all views in both the source and target schema.
 * @return a topologically sorted list {@link http://en.wikipedia.org/wiki/Topological_sorting} of view names
 */
private List<String> topoSortViews(Collection<View> allViews, Map<String, View> index) {
  if (log.isDebugEnabled()) {
    log.debug("Toposorting: " + Joiner.on(", ").join(Collections2.transform(allViews, viewToName())));
  }

  // The set of views we want to perform the sort on.
  Set<String> unmarkedViews = newHashSet(Collections2.transform(allViews, viewToName()));
  Set<String> temporarilyMarkedRecords = newHashSet();
  List<String> sortedList = newLinkedList();

  while (!unmarkedViews.isEmpty()) {
    String node = Iterables.getFirst(unmarkedViews, null);
    visit(node, temporarilyMarkedRecords, sortedList, index);
    unmarkedViews.remove(node);
  }

  return sortedList;
}
 
开发者ID:alfasoftware,项目名称:morf,代码行数:27,代码来源:ViewChanges.java

示例3: findInstanceDataChildByNameAndNamespace

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
/**
 * Looks for a DataSchemaNode by Name and Namespace.
 * @param container - Container
 * @param name - Child Name
 * @param namespace - Namespace
 * @return DataSchemaNode or null if one was not found
 */
private static DataSchemaNode findInstanceDataChildByNameAndNamespace(final DataNodeContainer container, final String name,
        final URI namespace) {
    Preconditions.<URI> checkNotNull(namespace);

    final List<DataSchemaNode> potentialSchemaNodes = findInstanceDataChildrenByName(container, name);

    final Predicate<DataSchemaNode> filter = new Predicate<DataSchemaNode>() {
        @Override
        public boolean apply(final DataSchemaNode node) {
            return Objects.equal(node.getQName().getNamespace(), namespace);
        }
    };

    final Iterable<DataSchemaNode> result = Iterables.filter(potentialSchemaNodes, filter);
    return Iterables.getFirst(result, null);
}
 
开发者ID:opendaylight,项目名称:fpc,代码行数:24,代码来源:NameResolver.java

示例4: findEmptyShard

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
/**
 * Finds an existing empty shard, or returns null if none exist.
 */
private static Shard findEmptyShard(RangeShardMap<Integer> shardMap) {
    // Get all shards in the shard map (ordered by name)
    List<Shard> allShards = shardMap.getShards().stream().sorted(Comparator.comparing(shard -> shard.getLocation().getDatabase()))
            .collect(Collectors.toList());

    // Get all mappings in the shard map
    List<RangeMapping> allMappings = shardMap.getMappings();

    // Determine which shards have mappings
    Set<UUID> shardsIdsWithMappings = allMappings.stream().map(RangeMapping::getShard).map(Shard::getId).collect(Collectors.toSet());

    // Remove all the shards that has mappings
    allShards.removeIf(shard -> shardsIdsWithMappings.contains(shard.getId()));

    // Get the first shard, if it exists
    return Iterables.getFirst(allShards, null);
}
 
开发者ID:Microsoft,项目名称:elastic-db-tools-for-java,代码行数:21,代码来源:CreateShardSample.java

示例5: updateGameprofile

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
public static GameProfile updateGameprofile(GameProfile input)
{
    if (input != null && !StringUtils.isNullOrEmpty(input.getName()))
    {
        if (input.isComplete() && input.getProperties().containsKey("textures"))
        {
            return input;
        }
        else if (profileCache != null && sessionService != null)
        {
            GameProfile gameprofile = profileCache.getGameProfileForUsername(input.getName());

            if (gameprofile == null)
            {
                return input;
            }
            else
            {
                Property property = (Property)Iterables.getFirst(gameprofile.getProperties().get("textures"), null);

                if (property == null)
                {
                    gameprofile = sessionService.fillProfileProperties(gameprofile, true);
                }

                return gameprofile;
            }
        }
        else
        {
            return input;
        }
    }
    else
    {
        return input;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:39,代码来源:TileEntitySkull.java

示例6: initStream

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
private void initStream()
{
    try
    {
        this.stream = new TwitchStream(this, (Property)Iterables.getFirst(this.twitchDetails.get("twitch_access_token"), null));
    }
    catch (Throwable throwable)
    {
        this.stream = new NullStream(throwable);
        logger.error("Couldn\'t initialize twitch stream");
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:13,代码来源:Minecraft.java

示例7: getClassifierObjectDescriptionForFQN

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
/**
 * Returns with the index entry representing a classifier for the given classifier FQN argument.
 *
 * @param fqn
 *            the fully qualified name of the classifier.
 * @return the index entry representing the classifier.
 */
protected IEObjectDescription getClassifierObjectDescriptionForFQN(String fqn) {
	QualifiedName name = qualifiedNameConverter.toQualifiedName(fqn);
	Iterable<IEObjectDescription> foundObjects = descriptions.getExportedObjects(
			TypesPackage.eINSTANCE.getTClassifier(),
			name, false);

	return Iterables.getFirst(foundObjects, null);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:16,代码来源:N4JSClassifierWizardModelValidator.java

示例8: getOwner

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
private FlexPlayer getOwner() {
    FlexPlayer t = Iterables.getFirst( viewers, null );
    if ( t == null ) {
        throw new NullPointerException();
    }
    return t;
}
 
开发者ID:lukas81298,项目名称:FlexMC,代码行数:8,代码来源:FlexPlayerInventory.java

示例9: testFeignClientIsFound

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
@Test
public void testFeignClientIsFound() {
    Set<Relationship> relations = detector.detect();
    Assertions.assertThat(relations).isNotEmpty();
    Assertions.assertThat(relations).hasSize(1);
    Relationship relation = Iterables.getFirst(relations, null);
    Assertions.assertThat(relation.getComponent().getName()).isEqualTo("dummy-api");
    Assertions.assertThat(relation.getComponent().getType()).isEqualTo(ComponentType.HTTP_APPLICATION);
}
 
开发者ID:cereebro,项目名称:cereebro,代码行数:10,代码来源:FeignClientRelationshipDetectorTest.java

示例10: apply

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
@Override
@SuppressFBWarnings(value = "DE_MIGHT_IGNORE", justification = "Any exceptions are to be ignored")
public T apply(final Iterable<T> input) {
    if (null == input) {
        throw new IllegalArgumentException("Input cannot be null");
    }
    try {
        return Iterables.getFirst(input, null);
    } finally {
        CloseableUtil.close(input);
    }
}
 
开发者ID:gchq,项目名称:koryphe,代码行数:13,代码来源:FirstItem.java

示例11: getEffectiveMaterialization

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
Optional<Materialization> getEffectiveMaterialization(final Layout layout) {
  MaterializationWrapper materializationInfo = Iterables.getFirst(getEffectiveMaterialization(layout, getActiveHosts(), false), null);
  if (materializationInfo != null) {
    return Optional.of(materializationInfo.getMaterialization());
  } else {
    return Optional.absent();
  }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:9,代码来源:AccelerationServiceImpl.java

示例12: getSkinFromGameProfile

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
/**
 * Gets the skin from a game profile, if one exists, otherwise Skin.EMPTY_SKIN is returned.
 *
 * @param profile the profile
 * @return the skin of the profile
 */
public Skin getSkinFromGameProfile(GameProfileWrapper profile) {
    Validate.isTrue(enabled, "NameTagChanger is disabled");
    Validate.notNull(profile, "profile cannot be null");
    if (profile.getProperties().containsKey("textures")) {
        GameProfileWrapper.PropertyWrapper property = Iterables.getFirst(profile.getProperties().get("textures"), null);
        if (property == null) {
            return Skin.EMPTY_SKIN;
        } else {
            return new Skin(profile.getUUID(), property.getValue(), property.getSignature());
        }
    } else {
        return Skin.EMPTY_SKIN;
    }
}
 
开发者ID:Alvin-LB,项目名称:NameTagChanger,代码行数:21,代码来源:NameTagChanger.java

示例13: pick

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
/**
 * Pick the estimated cheapest problem,
 * return a a problem collection with that generator removed
 *
 * @return
 */
public ProblemContainerPick<S> pick() {
    ProblemContainerPick<S> result;

    Entry<? extends Comparable<?>, Collection<GenericProblem<S, ?>>> currEntry = sizeToProblem.firstEntry();
    if(currEntry != null) {
        Comparable<?> pickedKey = currEntry.getKey();
        GenericProblem<S, ?> pickedProblem = Iterables.getFirst(currEntry.getValue(), null);




        NavigableMap<Comparable<?>, Collection<GenericProblem<S, ?>>> remaining = new TreeMap<>();
        sizeToProblem.forEach((k, v) -> {
            Collection<GenericProblem<S, ?>> ps = v.stream().filter(i -> i != pickedProblem).collect(Collectors.toList());
            remaining.computeIfAbsent(k, (x) -> new ArrayList<GenericProblem<S, ?>>()).addAll(ps);
        });
                //ArrayListMultimap.create(sizeToProblem);
        //remaining.remove(pickedKey, pickedProblem);

        ProblemContainerImpl<S> r = new ProblemContainerImpl<>(remaining);

        result = null; //new ProblemContainerPick<>(pickedProblem, r);
    } else {
        throw new IllegalStateException();
    }

    return result;
}
 
开发者ID:SmartDataAnalytics,项目名称:SubgraphIsomorphismIndex,代码行数:35,代码来源:ProblemContainerImpl.java

示例14: hasComplex

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
public boolean hasComplex()
{
    // We start by the end cause we know complex columns sort after the simple ones
    ColumnData cd = Iterables.getFirst(BTree.<ColumnData>iterable(btree, BTree.Dir.DESC), null);
    return cd != null && cd.column.isComplex();
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:7,代码来源:BTreeRow.java

示例15: getFirstTagByName

import com.google.common.collect.Iterables; //导入方法依赖的package包/类
private static MetricsTag getFirstTagByName(MetricsRecord record, String name) {
  return Iterables.getFirst(Iterables.filter(record.tags(),
      new MetricsTagPredicate(name)), null);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:5,代码来源:MetricsRecords.java


注:本文中的com.google.common.collect.Iterables.getFirst方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。