本文整理了Java中com.google.common.base.Predicate.apply()
方法的一些代码示例,展示了Predicate.apply()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Predicate.apply()
方法的具体详情如下:
包路径:com.google.common.base.Predicate
类名称:Predicate
方法名:apply
[英]Returns the result of applying this predicate to input (Java 8 users, see notes in the class documentation above). This method is generally expected, but not absolutely required, to have the following properties:
代码示例来源:origin: google/guava
@SuppressWarnings("deprecation") // intentional; deprecation is for callers primarily
@Override
public boolean apply(Character character) {
return predicate.apply(checkNotNull(character));
}
代码示例来源:origin: thinkaurelius/titan
@Override
public boolean apply(@Nullable InternalRelation internalRelation) {
return !SCHEMA_FILTER.apply(internalRelation);
}
};
代码示例来源:origin: jclouds/legacy-jclouds
@Test
public void testRebootServer() throws Exception {
assertTrue(serverStatusChecker.apply(Server.State.RUNNING));
serverApi.reboot(serverId);
assertTrue(serverStatusChecker.apply(Server.State.RUNNING));
}
代码示例来源:origin: jclouds/legacy-jclouds
@Test
public void testTypeEqualsWhenNotEqual() {
assert !typeEquals("AAAA").apply(rrs);
}
}
代码示例来源:origin: jclouds/legacy-jclouds
protected void assertEventuallyImageStateEquals(ServerImage image, final ServerImageState state) {
assertTrue(retry(new Predicate<ServerImage>() {
public boolean apply(ServerImage input) {
return Iterables.getOnlyElement(api.getImageServices().getImagesById(input.getId()))
.getState() == state;
}
}, 600, 1, SECONDS).apply(image));
}
}
代码示例来源:origin: google/guava
@Override
public boolean removeIf(java.util.function.Predicate<? super E> filter) {
checkNotNull(filter);
return unfiltered.removeIf(element -> predicate.apply(element) && filter.test(element));
}
代码示例来源:origin: jenkinsci/gitlab-plugin
@Override
public boolean apply(@Nullable MergeRequestObjectAttributes mergeRequestObjectAttributes) {
for (Predicate<MergeRequestObjectAttributes> predicate : rejectRules) {
if (predicate.apply(mergeRequestObjectAttributes)) {
return false;
}
}
for (Predicate<MergeRequestObjectAttributes> predicate : acceptRules) {
if (predicate.apply(mergeRequestObjectAttributes)) {
return true;
}
}
return false;
}
}
代码示例来源:origin: jclouds/legacy-jclouds
@Test
public void testStopAndStartServer() throws Exception {
assertTrue(serverStatusChecker.apply(Server.State.RUNNING));
serverApi.stop(serverId);
assertTrue(serverStatusChecker.apply(Server.State.STOPPED));
serverApi.start(serverId);
assertTrue(serverStatusChecker.apply(Server.State.RUNNING));
}
代码示例来源:origin: jclouds/legacy-jclouds
@Test
public void testHrefEqualsWhenNotEqual() {
assert !hrefEquals(URI.create("foo")).apply(ref);
}
}
代码示例来源:origin: jclouds/legacy-jclouds
private void destroyMachine(VirtualMachine virtualMachine) {
assertTrue(adminJobComplete.apply(
adminClient.getVirtualMachineClient().destroyVirtualMachine(virtualMachine.getId())), virtualMachine.toString());
assertTrue(adminVirtualMachineDestroyed.apply(virtualMachine));
}
代码示例来源:origin: google/guava
/**
* Returns {@code true} if every element returned by {@code iterator} satisfies the given
* predicate. If {@code iterator} is empty, {@code true} is returned.
*/
public static <T> boolean all(Iterator<T> iterator, Predicate<? super T> predicate) {
checkNotNull(predicate);
while (iterator.hasNext()) {
T element = iterator.next();
if (!predicate.apply(element)) {
return false;
}
}
return true;
}
代码示例来源:origin: googleapis/google-cloud-java
private static boolean hasCauseMatching(
@Nullable Throwable cause, Predicate<? super Throwable> matcher) {
while (cause != null) {
if (matcher.apply(cause)) {
return true;
}
cause = cause.getCause();
}
return false;
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
@Test
public void testIsCatalogItemType() {
RegisteredType item = createItem(CatalogItemBuilder.newEntity("foo", "1.0")
.plan("services:\n- type: org.apache.brooklyn.entity.stock.BasicEntity")
.build());
assertTrue(RegisteredTypePredicates.IS_ENTITY.apply(item));
assertFalse(RegisteredTypePredicates.IS_LOCATION.apply(item));
assertFalse(RegisteredTypePredicates.IS_APPLICATION.apply(item));
assertFalse(RegisteredTypePredicates.IS_ENRICHER.apply(item));
assertFalse(RegisteredTypePredicates.IS_POLICY.apply(item));
}
代码示例来源:origin: jclouds/legacy-jclouds
@Test
public void testNameEqualsWhenNotEqual() {
assert !nameEquals("kclouds.org.").apply(zone);
}
}
代码示例来源:origin: jclouds/legacy-jclouds
public void testPropertyChangesPrefix() {
GroupNamingConvention fn = Guice.createInjector(new AbstractModule() {
@Override
protected void configure() {
bindConstant().annotatedWith(Names.named(RESOURCENAME_PREFIX)).to("kclouds");
}
}).getInstance(GroupNamingConvention.Factory.class).create();
assertEquals(fn.sharedNameForGroup("cluster"), "kclouds-cluster");
assertEquals(fn.groupInSharedNameOrNull("kclouds-cluster"), "cluster");
assertEquals(fn.groupInUniqueNameOrNull("kclouds-cluster"), null);
assertTrue(fn.containsGroup("cluster").apply("kclouds-cluster"));
}
代码示例来源:origin: google/j2objc
@SuppressWarnings("deprecation") // intentional; deprecation is for callers primarily
@Override
public boolean apply(Character character) {
return predicate.apply(checkNotNull(character));
}
代码示例来源:origin: facebook/litho
@Nullable
private ImmutableList<View> findChild(
View root,
Predicate<View> predicate,
Predicate<? super ViewGroup> shouldCheckChildren) {
if (predicate.apply(root)) {
return ImmutableList.of(root);
}
if (root instanceof ViewGroup && shouldCheckChildren.apply((ViewGroup) root)) {
ViewGroup viewGroup = (ViewGroup) root;
for (int i = 0; i < viewGroup.getChildCount(); i++) {
View child = viewGroup.getChildAt(i);
ImmutableList<View> result = findChild(child, predicate, shouldCheckChildren);
if (result != null) {
return ImmutableList.<View>builder()
.add(root)
.addAll(result)
.build();
}
}
}
return null;
}
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
@Test
public void testNameEqualTo() throws Exception {
assertTrue(ConfigPredicates.nameEqualTo("test.str1").apply(STR1));
assertFalse(ConfigPredicates.nameEqualTo("wrong").apply(STR1));
}
代码示例来源:origin: jclouds/legacy-jclouds
@Test
public void testNamespaceEqualsWhenNotEqual() {
assert !namespaceEquals(URI.create("foo")).apply(ref);
}
}
代码示例来源:origin: jclouds/legacy-jclouds
public void testSharedName() {
FormatSharedNamesAndAppendUniqueStringToThoseWhichRepeat fn = new FormatSharedNamesAndAppendUniqueStringToThoseWhichRepeat(
"jclouds", '_', Suppliers.ofInstance("123"), okValidator);
assertEquals(fn.sharedNameForGroup("cluster"), "jclouds_cluster");
assertEquals(fn.groupInSharedNameOrNull("jclouds_cluster"), "cluster");
assertEquals(fn.groupInUniqueNameOrNull("jclouds_cluster"), null);
assertTrue(fn.containsGroup("cluster").apply("jclouds_cluster"));
}
内容来源于网络,如有侵权,请联系作者删除!