當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。