本文整理汇总了Java中com.google.common.base.Function.apply方法的典型用法代码示例。如果您正苦于以下问题:Java Function.apply方法的具体用法?Java Function.apply怎么用?Java Function.apply使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.base.Function
的用法示例。
在下文中一共展示了Function.apply方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: openShell
import com.google.common.base.Function; //导入方法依赖的package包/类
public static void openShell(String format, int weight, int height, Function<Shell, Control> function) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setSize(weight, height);
shell.setLayout(new FillLayout());
function.apply(shell);
shell.open();
while(!shell.isDisposed()) {
if(!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
示例2: getProposal
import com.google.common.base.Function; //导入方法依赖的package包/类
/**
* Creates initial proposal adjusted for the N4JS imports. Then passes that proposal to the provided delegate
* proposal factory. Obtained ICompletionProposal is configured with a FQNImporter as custom text. applier.
*
* @param candidate
* for which proposal is created
* @param delegateProposalFactory
* delegate proposal factory
* @return code completion proposal
*/
private ICompletionProposal getProposal(IEObjectDescription candidate, EObject model,
IScope scope,
EReference reference,
ContentAssistContext context,
Predicate<IEObjectDescription> filter,
Function<IEObjectDescription, ICompletionProposal> delegateProposalFactory) {
final IEObjectDescription inputToUse = getAliasedDescription(candidate, reference, context);
final ICompletionProposal result = delegateProposalFactory.apply(inputToUse);
if (result instanceof ConfigurableCompletionProposal) {
final FQNImporter importer = fqnImporterFactory.create(
model.eResource(),
scope,
valueConverter,
filter,
context.getViewer());
((ConfigurableCompletionProposal) result).setTextApplier(importer);
}
return result;
}
示例3: recurseWorkflowItems
import com.google.common.base.Function; //导入方法依赖的package包/类
/**
* @return true if the recursion should stop.
*/
private static <T extends WorkflowNode> boolean recurseWorkflowItems(Map<String, T> items, WorkflowNode node, Function<WorkflowNode, Boolean> includeFunc)
{
if( includeFunc.apply(node) )
{
items.put(node.getUuid(), (T) node);
}
if( !node.isLeafNode() )
{
WorkflowTreeNode treenode = (WorkflowTreeNode) node;
int num = treenode.numberOfChildren();
for( int i = 0; i < num; i++ )
{
boolean stop = recurseWorkflowItems(items, treenode.getChild(i), includeFunc);
if( stop )
{
return true;
}
}
}
return false;
}
示例4: extractFromSystemResponseIfPossible
import com.google.common.base.Function; //导入方法依赖的package包/类
/**
* Function to turn a {@link com.bbn.kbp.events2014.Response} to its equivalence class if the
* coreference information is known for the filler. If it isn't, {@link
* com.google.common.base.Optional#absent()} is returned.
*/
public static Function<Response, Optional<TypeRoleFillerRealis>> extractFromSystemResponseIfPossible(
final Function<KBPString, Optional<KBPString>> CASNormalizer) {
return new Function<Response, Optional<TypeRoleFillerRealis>>() {
@Override
public Optional<TypeRoleFillerRealis> apply(final Response arg) {
final Optional<KBPString> normalizedCAS = CASNormalizer.apply(arg.canonicalArgument());
if (normalizedCAS.isPresent()) {
return Optional.of(TypeRoleFillerRealis.of(arg.docID(), arg.type(),
arg.role(), arg.realis(), normalizedCAS.get()));
} else {
return Optional.absent();
}
}
};
}
示例5: verifyNodeRemoved
import com.google.common.base.Function; //导入方法依赖的package包/类
protected void verifyNodeRemoved(YangInstanceIdentifier path,
Function<YangInstanceIdentifier,NormalizedNode<?,?>> reader) {
AssertionError lastError = null;
Stopwatch sw = Stopwatch.createStarted();
while (sw.elapsed(TimeUnit.MILLISECONDS) <= 5000) {
try {
NormalizedNode<?, ?> node = reader.apply(path);
Assert.assertNull("Node was not removed at path: " + path, node);
return;
} catch (AssertionError e) {
lastError = e;
Uninterruptibles.sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
}
}
throw lastError;
}
示例6: forAllRegistries
import com.google.common.base.Function; //导入方法依赖的package包/类
private static void forAllRegistries(PersistentRegistry registrySet, Function<Map.Entry<ResourceLocation, FMLControlledNamespacedRegistry<?>>, Void> operation)
{
for (Map.Entry<ResourceLocation, FMLControlledNamespacedRegistry<?>> r : registrySet.registries.entrySet())
{
operation.apply(r);
}
}
示例7: mapToList
import com.google.common.base.Function; //导入方法依赖的package包/类
@Override
public List<Formula> mapToList(Function<Formula, List<Formula>> func, boolean alwaysRecurse) {
List<Formula> res = func.apply(this);
if (res.isEmpty() || alwaysRecurse) {
res.addAll(child1.mapToList(func, alwaysRecurse));
res.addAll(child2.mapToList(func, alwaysRecurse));
}
return res;
}
示例8: mapToList
import com.google.common.base.Function; //导入方法依赖的package包/类
@Override
public List<Formula> mapToList(Function<Formula, List<Formula>> func, boolean alwaysRecurse) {
List<Formula> res = func.apply(this);
if (res.isEmpty() || alwaysRecurse) {
res.addAll(relation.mapToList(func, alwaysRecurse));
res.addAll(child.mapToList(func, alwaysRecurse));
}
return res;
}
示例9: asEntryTransformer
import com.google.common.base.Function; //导入方法依赖的package包/类
/**
* Views a function as an entry transformer that ignores the entry key.
*/
static <K, V1, V2> EntryTransformer<K, V1, V2> asEntryTransformer(
final Function<? super V1, V2> function) {
checkNotNull(function);
return new EntryTransformer<K, V1, V2>() {
@Override
public V2 transformEntry(K key, V1 value) {
return function.apply(value);
}
};
}
示例10: unsubscribe
import com.google.common.base.Function; //导入方法依赖的package包/类
private <T> boolean unsubscribe(Function<T, Boolean> f, T sub) {
if (f.apply(sub)) {
log.info("Subscription removed: {}", sub);
return true;
} else {
log.warn("Subscription was already removed: {}", sub);
return false;
}
}
示例11: unsubscribe
import com.google.common.base.Function; //导入方法依赖的package包/类
private <T> boolean unsubscribe(Function<T, Boolean> f, T sub) {
if (f.apply(sub)) {
log.info("Subscription removed: {}", sub);
return true;
} else {
log.warn("Subscription was already removed: {}", sub);
return false;
}
}
示例12: mapToList
import com.google.common.base.Function; //导入方法依赖的package包/类
@Override
public List<Formula> mapToList(Function<Formula, List<Formula>> func, boolean alwaysRecurse) {
List<Formula> res = func.apply(this);
if (res.isEmpty() || alwaysRecurse)
res.addAll(body.mapToList(func, alwaysRecurse));
return res;
}
示例13: map
import com.google.common.base.Function; //导入方法依赖的package包/类
public Formula map(Function<Formula, Formula> func) {
Formula result = func.apply(this);
return result == null ? new ReverseFormula(child.map(func)) : result;
}
示例14: doFallback
import com.google.common.base.Function; //导入方法依赖的package包/类
@Override
@Nullable
V doFallback(Function<? super X, ? extends V> fallback, X cause) throws Exception {
return fallback.apply(cause);
}
示例15: map
import com.google.common.base.Function; //导入方法依赖的package包/类
public <T> T map(Function<? super Pair<L, R>, ? extends T> function) throws Exception {
return function.apply(this);
}