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


Java Function.apply方法代码示例

本文整理汇总了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();
  }
 
开发者ID:TRUEJASONFANS,项目名称:JavaFX-FrameRateMeter,代码行数:21,代码来源:SWTTestUtil.java

示例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;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:33,代码来源:ImportsAwareReferenceProposalCreator.java

示例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;
}
 
开发者ID:equella,项目名称:Equella,代码行数:27,代码来源:Workflow.java

示例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();
      }
    }
  };
}
 
开发者ID:isi-nlp,项目名称:tac-kbp-eal,代码行数:22,代码来源:_TypeRoleFillerRealis.java

示例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;
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:18,代码来源:AbstractEntityOwnershipTest.java

示例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);
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:8,代码来源:PersistentRegistryManager.java

示例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;
}
 
开发者ID:cgraywang,项目名称:TextHIN,代码行数:10,代码来源:ArithmeticFormula.java

示例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;
}
 
开发者ID:cgraywang,项目名称:TextHIN,代码行数:10,代码来源:JoinFormula.java

示例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);
    }
  };
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:14,代码来源:Maps.java

示例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;
  }
}
 
开发者ID:osswangxining,项目名称:iotgateway,代码行数:10,代码来源:MqttGatewayService.java

示例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;
    }
}
 
开发者ID:thingsboard,项目名称:thingsboard-gateway,代码行数:10,代码来源:MqttGatewayService.java

示例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;
}
 
开发者ID:cgraywang,项目名称:TextHIN,代码行数:8,代码来源:LambdaFormula.java

示例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;
}
 
开发者ID:cgraywang,项目名称:TextHIN,代码行数:5,代码来源:ReverseFormula.java

示例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);
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:6,代码来源:AbstractCatchingFuture.java

示例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);
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:4,代码来源:Pair.java


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