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


Java Predicate.apply方法代码示例

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


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

示例1: hasPlayerMatchingInRange

import com.google.common.base.Predicate; //导入方法依赖的package包/类
public boolean hasPlayerMatchingInRange(double range, Predicate<EntityPlayerMP> predicate)
{
    int i = 0;

    for (int j = this.players.size(); i < j; ++i)
    {
        EntityPlayerMP entityplayermp = (EntityPlayerMP)this.players.get(i);

        if (predicate.apply(entityplayermp) && this.pos.getDistanceSq(entityplayermp) < range * range)
        {
            return true;
        }
    }

    return false;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:17,代码来源:PlayerChunkMapEntry.java

示例2: clearVisualBlocks

import com.google.common.base.Predicate; //导入方法依赖的package包/类
/**
 * Clears all visual blocks that are shown to a player of a given VisualType.
 *
 * @param player
 *            the player to clear for
 * @param visualType
 *            the visual type
 * @param predicate
 *            the predicate to filter to
 * @param sendRemovalPackets
 *            if a packet to send a block change should be sent (this is used to prevent unnecessary packets sent when disconnecting or changing worlds, for example)
 * @return mapping of the removed visualises
 */
@Deprecated
public Map<Location, VisualBlock> clearVisualBlocks(Player player, @Nullable VisualType visualType, @Nullable Predicate<VisualBlock> predicate, boolean sendRemovalPackets) {

    synchronized (storedVisualises) {
        if (!this.storedVisualises.containsRow(player.getUniqueId()))
            return Collections.emptyMap();
        Map<Location, VisualBlock> results = new HashMap<>(this.storedVisualises.row(player.getUniqueId())); // copy to prevent commodification
        Map<Location, VisualBlock> removed = new HashMap<>();
        for (Map.Entry<Location, VisualBlock> entry : results.entrySet()) {
            VisualBlock visualBlock = entry.getValue();

            if ((predicate == null || predicate.apply(visualBlock)) && (visualType == null || visualBlock.getVisualType() == visualType)) {
                Location location = entry.getKey();
                if (removed.put(location, visualBlock) == null) { // not really necessary, but might as well
                    this.clearVisualBlock(player, location, sendRemovalPackets); // this will call remove on storedVisualises.
                }
            }
        }

        return removed;
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:36,代码来源:VisualiseHandler.java

示例3: getEntitiesOfTypeWithinAAAB

import com.google.common.base.Predicate; //导入方法依赖的package包/类
public <T extends Entity> void getEntitiesOfTypeWithinAAAB(Class <? extends T > entityClass, AxisAlignedBB aabb, List<T> listToFill, Predicate <? super T > p_177430_4_)
{
    int i = MathHelper.floor_double((aabb.minY - 2.0D) / 16.0D);
    int j = MathHelper.floor_double((aabb.maxY + 2.0D) / 16.0D);
    i = MathHelper.clamp_int(i, 0, this.entityLists.length - 1);
    j = MathHelper.clamp_int(j, 0, this.entityLists.length - 1);

    for (int k = i; k <= j; ++k)
    {
        for (T t : this.entityLists[k].getByClass(entityClass))
        {
            if (t.getEntityBoundingBox().intersectsWith(aabb) && (p_177430_4_ == null || p_177430_4_.apply(t)))
            {
                listToFill.add(t);
            }
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:19,代码来源:Chunk.java

示例4: referenceHasBeenFound

import com.google.common.base.Predicate; //导入方法依赖的package包/类
private boolean referenceHasBeenFound(Predicate<URI> targetURIs, URI refURI, EObject instanceOrProxy) {
	boolean result = false;
	// If the EObject is a composed member, we compare the target URIs with the URIs of the constituent members.
	if (instanceOrProxy instanceof TMember && ((TMember) instanceOrProxy).isComposed()) {
		TMember member = (TMember) instanceOrProxy;
		if (member.isComposed()) {
			for (TMember constituentMember : member.getConstituentMembers()) {
				URI constituentReffURI = EcoreUtil2
						.getPlatformResourceOrNormalizedURI(constituentMember);
				result = result || targetURIs.apply(constituentReffURI);
			}
		}
	} else {
		// Standard case
		result = targetURIs.apply(refURI);
	}
	return result;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:19,代码来源:ConcreteSyntaxAwareReferenceFinder.java

示例5: getEntitiesOfTypeWithinAAAB

import com.google.common.base.Predicate; //导入方法依赖的package包/类
public <T extends Entity> void getEntitiesOfTypeWithinAAAB(Class <? extends T > entityClass, AxisAlignedBB aabb, List<T> listToFill, Predicate <? super T > filter)
{
    int i = MathHelper.floor_double((aabb.minY - World.MAX_ENTITY_RADIUS) / 16.0D);
    int j = MathHelper.floor_double((aabb.maxY + World.MAX_ENTITY_RADIUS) / 16.0D);
    i = MathHelper.clamp_int(i, 0, this.entityLists.length - 1);
    j = MathHelper.clamp_int(j, 0, this.entityLists.length - 1);

    for (int k = i; k <= j; ++k)
    {
        for (T t : this.entityLists[k].getByClass(entityClass))
        {
            if (t.getEntityBoundingBox().intersectsWith(aabb) && (filter == null || filter.apply(t)))
            {
                listToFill.add(t);
            }
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:19,代码来源:Chunk.java

示例6: removeFromColumnIf

import com.google.common.base.Predicate; //导入方法依赖的package包/类
/**
 * Removes all {@code Column} mappings whose row key and value satisfy the
 * given predicate.
 */
@CanIgnoreReturnValue
boolean removeFromColumnIf(Predicate<? super Entry<R, V>> predicate) {
  boolean changed = false;
  Iterator<Entry<R, Map<C, V>>> iterator = backingMap.entrySet().iterator();
  while (iterator.hasNext()) {
    Entry<R, Map<C, V>> entry = iterator.next();
    Map<C, V> map = entry.getValue();
    V value = map.get(columnKey);
    if (value != null && predicate.apply(Maps.immutableEntry(entry.getKey(), value))) {
      map.remove(columnKey);
      changed = true;
      if (map.isEmpty()) {
        iterator.remove();
      }
    }
  }
  return changed;
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:23,代码来源:StandardTable.java

示例7: getEntities

import com.google.common.base.Predicate; //导入方法依赖的package包/类
public <T extends Entity> List<T> getEntities(Class <? extends T > entityType, Predicate <? super T > filter)
{
    List<T> list = Lists.<T>newArrayList();

    for (Entity entity : this.loadedEntityList)
    {
        if (entityType.isAssignableFrom(entity.getClass()) && filter.apply((T)entity))
        {
            list.add((T)entity);
        }
    }

    return list;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:15,代码来源:World.java

示例8: lastIndexOf

import com.google.common.base.Predicate; //导入方法依赖的package包/类
public static <T> int lastIndexOf(@Nonnull Iterable<T> iterable, @Nonnull Predicate<? super T> predicate) {
    int index = 0;
    int lastMatchingIndex = -1;
    for (T item: iterable) {
        if (predicate.apply(item)) {
            lastMatchingIndex = index;
        }
        index++;
    }
    return lastMatchingIndex;
}
 
开发者ID:CvvT,项目名称:andbg,代码行数:12,代码来源:CollectionUtils.java

示例9: removeFirstMatching

import com.google.common.base.Predicate; //导入方法依赖的package包/类
/**
 * Removes and returns the first matching element, or returns {@code null} if there is none.
 */
@Nullable
static <T> T removeFirstMatching(Iterable<T> removeFrom, Predicate<? super T> predicate) {
  checkNotNull(predicate);
  Iterator<T> iterator = removeFrom.iterator();
  while (iterator.hasNext()) {
    T next = iterator.next();
    if (predicate.apply(next)) {
      iterator.remove();
      return next;
    }
  }
  return null;
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:17,代码来源:Iterables.java

示例10: filter

import com.google.common.base.Predicate; //导入方法依赖的package包/类
FailureReport filter(Predicate<String> predicate) {
    FailureReport result = new FailureReport(rule, priority);
    for (String message : failureMessages) {
        if (predicate.apply(message)) {
            result.add(message);
        }
    }
    return result;
}
 
开发者ID:TNG,项目名称:ArchUnit,代码行数:10,代码来源:FailureReport.java

示例11: getEntitiesWithinAABBForEntity

import com.google.common.base.Predicate; //导入方法依赖的package包/类
/**
 * Fills the given list of all entities that intersect within the given bounding box that aren't the passed entity.
 */
public void getEntitiesWithinAABBForEntity(Entity entityIn, AxisAlignedBB aabb, List<Entity> listToFill, Predicate <? super Entity > p_177414_4_)
{
    int i = MathHelper.floor_double((aabb.minY - 2.0D) / 16.0D);
    int j = MathHelper.floor_double((aabb.maxY + 2.0D) / 16.0D);
    i = MathHelper.clamp_int(i, 0, this.entityLists.length - 1);
    j = MathHelper.clamp_int(j, 0, this.entityLists.length - 1);

    for (int k = i; k <= j; ++k)
    {
        if (!this.entityLists[k].isEmpty())
        {
            for (Entity entity : this.entityLists[k])
            {
                if (entity.getEntityBoundingBox().intersectsWith(aabb) && entity != entityIn)
                {
                    if (p_177414_4_ == null || p_177414_4_.apply(entity))
                    {
                        listToFill.add(entity);
                    }

                    Entity[] aentity = entity.getParts();

                    if (aentity != null)
                    {
                        for (int l = 0; l < aentity.length; ++l)
                        {
                            entity = aentity[l];

                            if (entity != entityIn && entity.getEntityBoundingBox().intersectsWith(aabb) && (p_177414_4_ == null || p_177414_4_.apply(entity)))
                            {
                                listToFill.add(entity);
                            }
                        }
                    }
                }
            }
        }
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:43,代码来源:Chunk.java

示例12: hasMatchingParent

import com.google.common.base.Predicate; //导入方法依赖的package包/类
private boolean hasMatchingParent(TableInfo tableInfo, ReferenceInfo info, Predicate<ReferenceInfo> parentMatchPredicate) {
    ColumnIdent parent = info.ident().columnIdent().getParent();
    while (parent != null) {
        ReferenceInfo parentInfo = tableInfo.getReferenceInfo(parent);
        if (parentMatchPredicate.apply(parentInfo)) {
            return true;
        }
        parent = parent.getParent();
    }
    return false;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:12,代码来源:UpdateStatementAnalyzer.java

示例13: countAnswersMatchingPredicate

import com.google.common.base.Predicate; //导入方法依赖的package包/类
public int countAnswersMatchingPredicate(List<String> answers, Predicate<String> predicate) {
    int counter = 0;
    for (String answer : answers) {
        if (predicate.apply(answer)) {
            counter++;
        }
    }
    return counter;
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:10,代码来源:GeneralAnswersCounter.java

示例14: EntityAINearestAttackableTarget

import com.google.common.base.Predicate; //导入方法依赖的package包/类
public EntityAINearestAttackableTarget(EntityCreature creature, Class<T> classTarget, int chance, boolean checkSight, boolean onlyNearby, final Predicate <? super T > targetSelector)
{
    super(creature, checkSight, onlyNearby);
    this.targetClass = classTarget;
    this.targetChance = chance;
    this.theNearestAttackableTargetSorter = new EntityAINearestAttackableTarget.Sorter(creature);
    this.setMutexBits(1);
    this.targetEntitySelector = new Predicate<T>()
    {
        public boolean apply(T p_apply_1_)
        {
            if (targetSelector != null && !targetSelector.apply(p_apply_1_))
            {
                return false;
            }
            else
            {
                if (p_apply_1_ instanceof EntityPlayer)
                {
                    double d0 = EntityAINearestAttackableTarget.this.getTargetDistance();

                    if (p_apply_1_.isSneaking())
                    {
                        d0 *= 0.800000011920929D;
                    }

                    if (p_apply_1_.isInvisible())
                    {
                        float f = ((EntityPlayer)p_apply_1_).getArmorVisibility();

                        if (f < 0.1F)
                        {
                            f = 0.1F;
                        }

                        d0 *= (double)(0.7F * f);
                    }

                    if ((double)p_apply_1_.getDistanceToEntity(EntityAINearestAttackableTarget.this.taskOwner) > d0)
                    {
                        return false;
                    }
                }

                return EntityAINearestAttackableTarget.this.isSuitableTarget(p_apply_1_, false);
            }
        }
    };
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:50,代码来源:EntityAINearestAttackableTarget.java

示例15: visitFetchReference

import com.google.common.base.Predicate; //导入方法依赖的package包/类
@Override
public Boolean visitFetchReference(FetchReference fetchReference, Predicate<Symbol> symbolPredicate) {
    return symbolPredicate.apply(fetchReference)
           || fetchReference.docId().accept(this, symbolPredicate)
           || fetchReference.ref().accept(this, symbolPredicate);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:7,代码来源:SymbolVisitors.java


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