List of usage examples for com.google.common.base Predicates alwaysTrue
@GwtCompatible(serializable = true) public static <T> Predicate<T> alwaysTrue()
From source file:com.eucalyptus.autoscaling.common.internal.groups.PersistenceAutoScalingGroups.java
@Override public <T> List<T> listRequiringInstanceReplacement(final Function<? super AutoScalingGroup, T> transform) throws AutoScalingMetadataException { final DetachedCriteria criteria = DetachedCriteria.forClass(AutoScalingInstance.class) .add(Example.create(AutoScalingInstance.withHealthStatus(HealthStatus.Unhealthy))) .setProjection(Projections.property("autoScalingGroup")); return persistenceSupport.listByExample(AutoScalingGroup.withOwner(null), Predicates.alwaysTrue(), Property.forName("id").in(criteria), Collections.<String, String>emptyMap(), transform); }
From source file:com.davidbracewell.io.JarUtils.java
/** * @return A list of all resources on the classpath *///from w w w. j a va2s . co m public static List<Resource> getClasspathResources() { synchronized (classpathResources) { if (classpathResources.isEmpty()) { for (String jar : SystemInfo.JAVA_CLASS_PATH.split(SystemInfo.PATH_SEPARATOR)) { File file = new File(jar); if (file.isDirectory()) { classpathResources.addAll(new FileResource(file).getChildren(true)); } else { classpathResources.addAll(getJarContents(Resources.fromFile(jar), Predicates.alwaysTrue())); } } } return Collections.unmodifiableList(classpathResources); } }
From source file:net.shibboleth.idp.saml.impl.nameid.LegacyNameIdentifierGenerator.java
/** * Constructor.//from ww w. java 2s .c o m * * @param clazz encoder class type */ protected LegacyNameIdentifierGenerator(@Nonnull Class<? extends NameIdentifierAttributeEncoder> clazz) { activationCondition = Predicates.alwaysTrue(); encoderType = Constraint.isNotNull(clazz, "Encoder class type cannot be null"); // ProfileRequestContext -> RelyingPartyContext -> AttributeContext attributeContextLookupStrategy = Functions.compose(new ChildContextLookup<>(AttributeContext.class), new ChildContextLookup<ProfileRequestContext, RelyingPartyContext>(RelyingPartyContext.class)); }
From source file:org.locationtech.geogig.api.plumbing.diff.DepthTreeIterator.java
public DepthTreeIterator(final String treePath, final ObjectId metadataId, RevTree tree, ObjectDatabase source, Strategy strategy) {/*from www.j a v a 2 s .c o m*/ checkNotNull(treePath); checkNotNull(metadataId); checkNotNull(tree); checkNotNull(source); checkNotNull(strategy); this.tree = tree; this.treePath = treePath; this.metadataId = metadataId; this.source = source; this.strategy = strategy; this.functor = new NodeToRef(treePath, metadataId); this.boundsFilter = Predicates.alwaysTrue(); }
From source file:com.android.monkeyrunner.MonkeyRunnerStarter.java
private Predicate<PythonInterpreter> handlePlugin(File f) { JarFile jarFile;//w ww . j a va 2 s . c om try { jarFile = new JarFile(f); } catch (IOException e) { LOG.log(Level.SEVERE, "Unable to open plugin file. Is it a jar file? " + f.getAbsolutePath(), e); return Predicates.alwaysFalse(); } Manifest manifest; try { manifest = jarFile.getManifest(); } catch (IOException e) { LOG.log(Level.SEVERE, "Unable to get manifest file from jar: " + f.getAbsolutePath(), e); return Predicates.alwaysFalse(); } Attributes mainAttributes = manifest.getMainAttributes(); String pluginClass = mainAttributes.getValue(MONKEY_RUNNER_MAIN_MANIFEST_NAME); if (pluginClass == null) { // No main in this plugin, so it always succeeds. return Predicates.alwaysTrue(); } URL url; try { url = f.toURI().toURL(); } catch (MalformedURLException e) { LOG.log(Level.SEVERE, "Unable to convert file to url " + f.getAbsolutePath(), e); return Predicates.alwaysFalse(); } URLClassLoader classLoader = new URLClassLoader(new URL[] { url }, ClassLoader.getSystemClassLoader()); Class<?> clz; try { clz = Class.forName(pluginClass, true, classLoader); } catch (ClassNotFoundException e) { LOG.log(Level.SEVERE, "Unable to load the specified plugin: " + pluginClass, e); return Predicates.alwaysFalse(); } Object loadedObject; try { loadedObject = clz.newInstance(); } catch (InstantiationException e) { LOG.log(Level.SEVERE, "Unable to load the specified plugin: " + pluginClass, e); return Predicates.alwaysFalse(); } catch (IllegalAccessException e) { LOG.log(Level.SEVERE, "Unable to load the specified plugin " + "(did you make it public?): " + pluginClass, e); return Predicates.alwaysFalse(); } // Cast it to the right type if (loadedObject instanceof Runnable) { final Runnable run = (Runnable) loadedObject; return new Predicate<PythonInterpreter>() { public boolean apply(PythonInterpreter i) { run.run(); return true; } }; } else if (loadedObject instanceof Predicate<?>) { return (Predicate<PythonInterpreter>) loadedObject; } else { LOG.severe("Unable to coerce object into correct type: " + pluginClass); return Predicates.alwaysFalse(); } }
From source file:org.opensaml.saml.common.profile.AbstractNameIdentifierGenerator.java
/** Constructor. */ protected AbstractNameIdentifierGenerator() { activationCondition = Predicates.alwaysTrue(); }
From source file:org.locationtech.geogig.remotes.pack.PreparePackOp.java
private Set<ObjectId> resolveWantCommits(List<RefRequest> refs, boolean isTags) { return resolveHeadCommits(refs, isTags, Predicates.alwaysTrue(), (o) -> o.want); }
From source file:net.automatalib.util.ts.copy.TSCopy.java
/** * Copies an {@link Automaton} to a {@link MutableAutomaton} with possibly heterogeneous input alphabets and * state and transition properties. State and transitions will not be filtered. * //from w w w . j a va 2 s.c o m * @param method the traversal method to use * @param in the input transition system * @param limit the traversal limit, a value less than 0 means no limit * @param inputs the inputs to consider * @param out the output automaton * @param inputsMapping the transformation for input symbols * @param spMapping the function for obtaining state properties * @param tpMapping the function for obtaining transition properties * @return a mapping from old to new states */ public static <S1, I1, T1, S2, I2, T2, SP2, TP2> Mapping<S1, S2> rawCopy(TSTraversalMethod method, TransitionSystem<S1, ? super I1, T1> in, int limit, Collection<? extends I1> inputs, MutableAutomaton<S2, I2, T2, ? super SP2, ? super TP2> out, Function<? super I1, ? extends I2> inputsMapping, Function<? super S1, ? extends SP2> spMapping, Function<? super T1, ? extends TP2> tpMapping) { return rawCopy(method, in, limit, inputs, out, inputsMapping, spMapping, tpMapping, Predicates.alwaysTrue(), TransitionPredicates.alwaysTrue()); }
From source file:org.apache.gobblin.runtime.StateStoreMigrationCli.java
@Override public void run(String[] args) throws Exception { CliObjectFactory<Command> factory = new ConstructorAndPublicMethodsCliObjectFactory<>(Command.class); Command command = factory.buildObject(args, 1, true, args[0]); FileSystem fs = FileSystem.get(new Configuration()); FSDataInputStream inputStream = fs.open(command.path); Config config = ConfigFactory.parseReader(new InputStreamReader(inputStream, Charset.defaultCharset())); Preconditions.checkNotNull(config.getObject(SOURCE_KEY)); Preconditions.checkNotNull(config.getObject(DESTINATION_KEY)); DatasetStateStore dstDatasetStateStore = DatasetStateStore .buildDatasetStateStore(config.getConfig(DESTINATION_KEY)); DatasetStateStore srcDatasetStateStore = DatasetStateStore .buildDatasetStateStore(config.getConfig(SOURCE_KEY)); Map<String, JobState.DatasetState> map; // if migrating state for all jobs then list the store names (job names) and copy the current jst files if (ConfigUtils.getBoolean(config, MIGRATE_ALL_JOBS, Boolean.valueOf(DEFAULT_MIGRATE_ALL_JOBS))) { List<String> jobNames = srcDatasetStateStore.getStoreNames(Predicates.alwaysTrue()); for (String jobName : jobNames) { migrateStateForJob(srcDatasetStateStore, dstDatasetStateStore, jobName, command.deleteSourceStateStore); }/*from w ww. j a va2 s .com*/ } else { Preconditions.checkNotNull(config.getString(JOB_NAME_KEY)); migrateStateForJob(srcDatasetStateStore, dstDatasetStateStore, config.getString(JOB_NAME_KEY), command.deleteSourceStateStore); } }
From source file:org.eclipse.emf.compare.internal.merge.MergeDependenciesUtil.java
/** * This will map the given differences in a dependency graph, enabling EMF Compare to differentiate what * can be safely merged from what cannot. * <p>//from w ww . java 2 s. c o m * Typically, all differences that are not in a real conflict with another and that do not depend, * directly or indirectly, on a conflicting difference can be pre-merged without corrupting the models. * For example, if adding a reference "ref1" to an added class "C1" depends on the addition of a package * "P1" (i.e. three additions in a row), but "C1" has also been added in another place in the other model * (a conflict between two "same" elements added into different containers), then we can safely pre-merge * the addition of P1, but not the addition of its contained class C1, nor the addition of ref1. * </p> * * @param differences * The differences to be mapped into a dependency graph. * @param mergerRegistry * The {@link IMerger.Registry merger registry} currently in use. * @param mergeRightToLeft * The direction in which we're preparing a merge. * @param mergeMode * The merge mode. If MergeMode is null, then no differences will be filtered. * @return The dependency graph of this comparison's differences. */ public static IGraph<Diff> mapDifferences(Collection<Diff> differences, IMerger.Registry mergerRegistry, boolean mergeRightToLeft, MergeMode mergeMode) { IGraph<Diff> differencesGraph = new Graph<Diff>(); final Predicate<? super Diff> filter; if (mergeMode == MergeMode.RIGHT_TO_LEFT) { filter = fromSide(DifferenceSource.RIGHT); } else if (mergeMode == MergeMode.LEFT_TO_RIGHT) { filter = fromSide(DifferenceSource.LEFT); } else { filter = Predicates.alwaysTrue(); } for (Diff diff : Iterables.filter(differences, filter)) { final IMerger merger = mergerRegistry.getHighestRankingMerger(diff); final Set<Diff> directParents; if (merger instanceof IMerger2) { directParents = ((IMerger2) merger).getDirectMergeDependencies(diff, mergeRightToLeft); } else { directParents = Collections.emptySet(); } if (directParents.isEmpty()) { differencesGraph.add(diff); } else { for (Diff parent : directParents) { differencesGraph.addChildren(parent, Collections.singleton(diff)); } } } return differencesGraph; }