List of usage examples for com.google.common.base Predicates instanceOf
@GwtIncompatible("Class.isInstance") public static Predicate<Object> instanceOf(Class<?> clazz)
From source file:org.jclouds.logging.LoggingModules.java
/** * the first available {@link LoggingModule}s from * {@link java.util.ServiceLoader} or {@link JDKLoggingModule} *//*from w ww. jav a 2 s . c o m*/ public static LoggingModule firstOrJDKLoggingModule() { try { return find(ServiceLoader.load(LoggingModule.class), Predicates.not(Predicates.instanceOf(JDKLoggingModule.class))); } catch (NoSuchElementException e) { return new JDKLoggingModule(); } }
From source file:org.apache.abdera2.common.selector.Selectors.java
public static Selector<Object> instanceOf(final Class<?> _class) { return forPredicate(Predicates.instanceOf(_class)); }
From source file:org.eclipse.sirius.common.tools.api.resource.ResourceMigrationMarker.java
/** * Return true if the {@link Resource} has a migration marker. * /*from w w w . j a va 2s. c o m*/ * @param res * resource to test. * @return true if the {@link Resource} has a migration marker. */ public static boolean hasMigrationMarker(Resource res) { return Iterators.any(res.eAdapters().iterator(), Predicates.instanceOf(ResourceMigrationMarker.class)); }
From source file:com.google.jenkins.plugins.dsl.YamlHistoryAction.java
/** * Search the actions of the {@link YamlBuild} for a {@link YamlHistoryAction} * * @return the action, or null if not found (or no build was passed) *//* ww w . j a va2 s. c o m*/ @Nullable public static YamlHistoryAction of(YamlBuild build) { if (build == null) { return null; } try { return (YamlHistoryAction) Iterables.find(build.getRawActions(), Predicates.instanceOf(YamlHistoryAction.class)); } catch (NoSuchElementException e) { return null; } }
From source file:vazkii.botania.common.item.equipment.bauble.ItemTinyPlanet.java
public static void applyEffect(World world, double x, double y, double z) { int range = 8; List<Entity> entities = world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(x - range, y - range, z - range, x + range, y + range, z + range), Predicates.instanceOf(IManaBurst.class)); for (Entity entity : entities) { IManaBurst burst = (IManaBurst) entity; ItemStack lens = burst.getSourceLens(); if (lens != null && lens.getItem() instanceof ITinyPlanetExcempt && !((ITinyPlanetExcempt) lens.getItem()).shouldPull(lens)) continue; int orbitTime = getEntityOrbitTime(entity); if (orbitTime == 0) burst.setMinManaLoss(burst.getMinManaLoss() * 3); float radius = Math.min(7.5F, (Math.max(40, orbitTime) - 40) / 40F + 1.5F); int angle = orbitTime % 360; float xTarget = (float) (x + Math.cos(angle * 10 * Math.PI / 180F) * radius); float yTarget = (float) y; float zTarget = (float) (z + Math.sin(angle * 10 * Math.PI / 180F) * radius); Vector3 targetVec = new Vector3(xTarget, yTarget, zTarget); Vector3 currentVec = new Vector3(entity.posX, entity.posY, entity.posZ); Vector3 moveVector = targetVec.subtract(currentVec); burst.setMotion(moveVector.x, moveVector.y, moveVector.z); incrementOrbitTime(entity);/*from w ww . j ava 2s . c o m*/ } }
From source file:eu.stratosphere.sopremo.function.FunctionUtil.java
public static EvaluationExpression addToBatch(final BatchAggregationExpression bae, final ExpressionFunction aggregation, final EvaluationExpression preprocessing) { return aggregation.inline(preprocessing).replace(Predicates.instanceOf(AggregationExpression.class), new Function<EvaluationExpression, EvaluationExpression>() { @Override// w w w. ja va2 s . c om public EvaluationExpression apply(final EvaluationExpression expression) { final AggregationExpression ae = (AggregationExpression) expression; return bae.add(ae.getAggregation(), ExpressionUtil.replaceArrayProjections(ae.getInputExpression())); } }); }
From source file:com.complexible.common.openrdf.model.Statements.java
public static Predicate<Statement> objectIs(final Class<? extends Value> theValue) { return Predicates.compose(Predicates.instanceOf(theValue), object()); }
From source file:org.apache.wicket.atmosphere.ListenerEventSubscription.java
/** * Construct./*from w ww . java 2s . co m*/ * * @param component * @param behavior * @param method */ public ListenerEventSubscription(AtmosphereEventSubscription eventListener, Predicate filter, Class eventType) { this.eventListener = eventListener; this.filter = Predicates.and(Predicates.instanceOf(eventType), filter); }
From source file:org.obeonetwork.dsl.uml2.design.api.services.PackageContainmentServices.java
/** * Get all the packageable elements available in the semantic resources. * * @param element//from w w w . j a va 2s . c om * Semantic element * @return All the packageable elements */ public List<EObject> getAllPackageableElements(Element element) { final List<EObject> result = Lists.newArrayList(); final List<Package> rootPkgs = getAllAvailableRootPackages(element); result.addAll(rootPkgs); for (final Package pkg : rootPkgs) { Iterators.addAll(result, Iterators.filter(pkg.eAllContents(), Predicates.instanceOf(PackageableElement.class))); } if (element instanceof Package) { result.removeAll(((Package) element).getPackagedElements()); } return result; }
From source file:org.sosy_lab.cpachecker.util.expressions.And.java
private And(ImmutableSet<ExpressionTree<LeafType>> pOperands) { assert Iterables.size(pOperands) >= 2; assert !Iterables.contains(pOperands, ExpressionTrees.getFalse()); assert !Iterables.contains(pOperands, ExpressionTrees.getTrue()); assert !FluentIterable.from(pOperands).anyMatch(Predicates.instanceOf(And.class)); operands = pOperands;// w w w . j ava 2 s . c om hashCode = operands.hashCode(); }