本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
}
示例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");
}
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
}
示例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();
}
}
示例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;
}
}
示例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;
}
示例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();
}
示例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);
}