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


Java Predicate类代码示例

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


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

示例1: initEntityAI

import com.google.common.base.Predicate; //导入依赖的package包/类
@Override
protected void initEntityAI() {
	this.tasks.addTask(8, new AIEntityFlyingTowardsPlayer(this));
       this.tasks.addTask(9, new EntityAIWatchClosest(this, EntityPlayer.class, 3.0F, 1.0F));
       this.tasks.addTask(10, new EntityAIWatchClosest(this, EntityLiving.class, 8.0F));
	this.tasks.addTask(11, new EntityAILookIdle(this));

	this.targetTasks.addTask(0, new EntityAINearestAttackableTarget<>(this, EntityPlayer.class, 10, false, false, new Predicate<EntityLivingBase>() {

		@Override
		public boolean apply(EntityLivingBase input) {
			return !input.isPotionActive(HarshenPotions.potionSoulless);
		}
	}));

}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:17,代码来源:EntitySoulPart.java

示例2: writeViewPropertyDslMethods

import com.google.common.base.Predicate; //导入依赖的package包/类
private void writeViewPropertyDslMethods(ClassVisitor visitor, Type generatedType, Collection<ModelProperty<?>> viewProperties, Class<?> viewClass) {
    boolean writable = Iterables.any(viewProperties, new Predicate<ModelProperty<?>>() {
        @Override
        public boolean apply(ModelProperty<?> viewProperty) {
            return viewProperty.isWritable();
        }
    });
    // TODO:LPTR Instead of the first view property, we should figure out these parameters from the actual property
    ModelProperty<?> firstProperty = viewProperties.iterator().next();

    writeConfigureMethod(visitor, generatedType, firstProperty, writable);
    writeSetMethod(visitor, generatedType, firstProperty);
    writeTypeConvertingSetter(visitor, generatedType, viewClass, firstProperty);

    // TODO - this should be applied to all methods, including delegating methods
    writeReadOnlySetter(visitor, viewClass, writable, firstProperty);
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:18,代码来源:ManagedProxyClassGenerator.java

示例3: initEntityAI

import com.google.common.base.Predicate; //导入依赖的package包/类
protected void initEntityAI()
{
    this.aiSit = new EntityAISit(this);
    this.aiTempt = new EntityAITempt(this, 0.6D, Items.FISH, true);
    this.tasks.addTask(1, new EntityAISwimming(this));
    this.tasks.addTask(2, this.aiSit);
    this.tasks.addTask(3, this.aiTempt);
    this.tasks.addTask(5, new EntityAIFollowOwner(this, 1.0D, 10.0F, 5.0F));
    this.tasks.addTask(6, new EntityAIOcelotSit(this, 0.8D));
    this.tasks.addTask(7, new EntityAILeapAtTarget(this, 0.3F));
    this.tasks.addTask(8, new EntityAIOcelotAttack(this));
    this.tasks.addTask(9, new EntityAIMate(this, 0.8D));
    this.tasks.addTask(10, new EntityAIWanderAvoidWater(this, 0.8D, 1.0000001E-5F));
    this.tasks.addTask(11, new EntityAIWatchClosest(this, EntityPlayer.class, 10.0F));
    this.targetTasks.addTask(1, new EntityAITargetNonTamed(this, EntityChicken.class, false, (Predicate)null));
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:17,代码来源:EntityOcelot.java

示例4: BlockPattern

import com.google.common.base.Predicate; //导入依赖的package包/类
public BlockPattern(Predicate<BlockWorldState>[][][] predicatesIn)
{
    this.blockMatches = predicatesIn;
    this.fingerLength = predicatesIn.length;

    if (this.fingerLength > 0)
    {
        this.thumbLength = predicatesIn[0].length;

        if (this.thumbLength > 0)
        {
            this.palmLength = predicatesIn[0][0].length;
        }
        else
        {
            this.palmLength = 0;
        }
    }
    else
    {
        this.thumbLength = 0;
        this.palmLength = 0;
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:25,代码来源:BlockPattern.java

示例5: resources

import com.google.common.base.Predicate; //导入依赖的package包/类
private static void resources() {
  Resources rs1 = Scanner.paths("/io/ytcode/reflect/").scan();

  Resources rs2 = rs1.pattern(".*/resource/.*").suffix(".class");
  System.out.println(rs2.size());

  Resources rs3 =
      rs1.filter(
          new Predicate<Resource>() {
            @Override
            public boolean apply(Resource r) {
              return r.name().endsWith(".xml");
            }
          });
  System.out.println(rs3.size());
}
 
开发者ID:wangyuntao,项目名称:reflect,代码行数:17,代码来源:Example.java

示例6: EntityAIAvoidEntity

import com.google.common.base.Predicate; //导入依赖的package包/类
public EntityAIAvoidEntity(EntityCreature p_i46405_1_, Class<T> p_i46405_2_, Predicate <? super T > p_i46405_3_, float p_i46405_4_, double p_i46405_5_, double p_i46405_7_)
{
    this.canBeSeenSelector = new Predicate<Entity>()
    {
        public boolean apply(Entity p_apply_1_)
        {
            return p_apply_1_.isEntityAlive() && EntityAIAvoidEntity.this.theEntity.getEntitySenses().canSee(p_apply_1_);
        }
    };
    this.theEntity = p_i46405_1_;
    this.field_181064_i = p_i46405_2_;
    this.avoidTargetSelector = p_i46405_3_;
    this.avoidDistance = p_i46405_4_;
    this.farSpeed = p_i46405_5_;
    this.nearSpeed = p_i46405_7_;
    this.entityPathNavigate = p_i46405_1_.getNavigator();
    this.setMutexBits(1);
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:19,代码来源:EntityAIAvoidEntity.java

示例7: offerEvent

import com.google.common.base.Predicate; //导入依赖的package包/类
public void offerEvent(final Event event) {
    if (!isRunning.get()) {
        log.warn("程序已停止");
        return;
    }
    if (!allHandlers.containsKey(event.getTopic()) || allHandlers.get(event.getTopic()).size() < 0) {
        log.debug("cannot find handle for event:{}", event.getTopic());
        return;
    }
    if (event.isSync()) {
        disPatch(event);
        return;
    }
    if (event.isCleanExpire()) {
        eventQueue.removeAll(Collections2.filter(eventQueue, new Predicate<Event>() {
            @Override
            public boolean apply(Event input) {
                return StringUtils.equals(input.getTopic(), event.getTopic());
            }
        }));
    }
    eventQueue.put(event);


}
 
开发者ID:virjar,项目名称:vscrawler,代码行数:26,代码来源:EventLoop.java

示例8: checkMissingPredicates

import com.google.common.base.Predicate; //导入依赖的package包/类
private void checkMissingPredicates()
{
    List<Character> list = Lists.<Character>newArrayList();

    for (Entry<Character, Predicate<BlockWorldState>> entry : this.symbolMap.entrySet())
    {
        if (entry.getValue() == null)
        {
            list.add(entry.getKey());
        }
    }

    if (!list.isEmpty())
    {
        throw new IllegalStateException("Predicates for character(s) " + COMMA_JOIN.join(list) + " are missing");
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:18,代码来源:FactoryBlockPattern.java

示例9: listAll

import com.google.common.base.Predicate; //导入依赖的package包/类
public static ArrayList<Country> listAll(Context context, final String filter) {
    ArrayList<Country> list = new ArrayList<>();

    for (String countryCode : Locale.getISOCountries()) {
        Country country = getCountry(countryCode, context);

        list.add(country);
    }

    sortList(list);

    if (filter != null && filter.length() > 0) {
        return new ArrayList<>(Collections2.filter(list, new Predicate<Country>() {
            @Override
            public boolean apply(Country input) {
                return input.getName().toLowerCase().contains(filter.toLowerCase());
            }
        }));
    } else {
        return list;
    }
}
 
开发者ID:Scrounger,项目名称:CountryCurrencyPicker,代码行数:23,代码来源:Country.java

示例10: ScoreKBPAgainstERE

import com.google.common.base.Predicate; //导入依赖的package包/类
@Inject
ScoreKBPAgainstERE(
    final Parameters params,
    final Map<String, ScoringEventObserver<DocLevelEventArg, DocLevelEventArg>> scoringEventObservers,
    final ResponsesAndLinkingFromEREExtractor responsesAndLinkingFromEREExtractor,
    ResponsesAndLinkingFromKBPExtractorFactory responsesAndLinkingFromKBPExtractorFactory,
    @DocIDsToScoreP Set<Symbol> docIdsToScore,
    @KeyFileMapP Map<Symbol, File> keyFilesMap,
    Predicate<DocLevelEventArg> inScopePredicate,
    @PermitMissingSystemDocsP boolean permitMissingSystemDocuments) {
  this.params = checkNotNull(params);
  // we use a sorted map because the binding of plugins may be non-deterministic
  this.scoringEventObservers = ImmutableSortedMap.copyOf(scoringEventObservers);
  this.responsesAndLinkingFromEREExtractor = checkNotNull(responsesAndLinkingFromEREExtractor);
  this.responsesAndLinkingFromKBPExtractorFactory = responsesAndLinkingFromKBPExtractorFactory;
  this.docIDsToScore = ImmutableSet.copyOf(docIdsToScore);
  this.goldDocIDToFileMap = ImmutableMap.copyOf(keyFilesMap);
  this.inScopePredicate = inScopePredicate;
  this.permitMissingSystemDocuments = permitMissingSystemDocuments;
}
 
开发者ID:isi-nlp,项目名称:tac-kbp-eal,代码行数:21,代码来源:ScoreKBPAgainstERE.java

示例11: EntityAIFindEntityNearest

import com.google.common.base.Predicate; //导入依赖的package包/类
public EntityAIFindEntityNearest(EntityLiving mobIn, Class <? extends EntityLivingBase > p_i45884_2_)
{
    this.mob = mobIn;
    this.classToCheck = p_i45884_2_;

    if (mobIn instanceof EntityCreature)
    {
        LOGGER.warn("Use NearestAttackableTargetGoal.class for PathfinerMob mobs!");
    }

    this.predicate = new Predicate<EntityLivingBase>()
    {
        public boolean apply(@Nullable EntityLivingBase p_apply_1_)
        {
            double d0 = EntityAIFindEntityNearest.this.getFollowRange();

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

            return p_apply_1_.isInvisible() ? false : ((double)p_apply_1_.getDistanceToEntity(EntityAIFindEntityNearest.this.mob) > d0 ? false : EntityAITarget.isSuitableTarget(EntityAIFindEntityNearest.this.mob, p_apply_1_, false, true));
        }
    };
    this.sorter = new EntityAINearestAttackableTarget.Sorter(mobIn);
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:27,代码来源:EntityAIFindEntityNearest.java

示例12: 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:SkidJava,项目名称:BaseClient,代码行数:19,代码来源:Chunk.java

示例13: 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((aabb.minY - 2.0D) / 16.0D);
    int j = MathHelper.floor((aabb.maxY + 2.0D) / 16.0D);
    i = MathHelper.clamp(i, 0, this.entityLists.length - 1);
    j = MathHelper.clamp(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:sudofox,项目名称:Backmemed,代码行数:19,代码来源:Chunk.java

示例14: getQuads

import com.google.common.base.Predicate; //导入依赖的package包/类
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand)
{
    List<BakedQuad> list = Lists.<BakedQuad>newArrayList();

    if (state != null)
    {
        for (Entry<Predicate<IBlockState>, IBakedModel> entry : this.selectors.entrySet())
        {
            if (((Predicate)entry.getKey()).apply(state))
            {
                list.addAll(((IBakedModel)entry.getValue()).getQuads(state, side, rand++));
            }
        }
    }

    return list;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:18,代码来源:MultipartBakedModel.java

示例15: updateDatasetField

import com.google.common.base.Predicate; //导入依赖的package包/类
/**
 * Update field schema
 * @param datasetConfig old dataset config
 * @param fieldName field's name
 * @param fieldSchema new field schema
 * @return updated dataset config
 */
private DatasetConfig updateDatasetField(DatasetConfig datasetConfig, final String fieldName, CompleteType fieldSchema) {
  // clone the dataset config
  Serializer<DatasetConfig> serializer = ProtostuffSerializer.of(DatasetConfig.getSchema());
  DatasetConfig newDatasetConfig = serializer.deserialize(serializer.serialize(datasetConfig));

  List<DatasetField> datasetFields = newDatasetConfig.getDatasetFieldsList();
  if (datasetFields == null) {
    datasetFields = Lists.newArrayList();
  }

  DatasetField datasetField = Iterables.find(datasetFields, new Predicate<DatasetField>() {
    @Override
    public boolean apply(@Nullable DatasetField input) {
      return fieldName.equals(input.getFieldName());
    }
  }, null);

  if (datasetField == null) {
    datasetField = new DatasetField().setFieldName(fieldName);
    datasetFields.add(datasetField);
  }

  datasetField.setFieldSchema(ByteString.copyFrom(fieldSchema.serialize()));
  newDatasetConfig.setDatasetFieldsList(datasetFields);

  return newDatasetConfig;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:35,代码来源:ConvertFromJsonOperator.java


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