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


Java IterableExtensions.fold方法代码示例

本文整理汇总了Java中org.eclipse.xtext.xbase.lib.IterableExtensions.fold方法的典型用法代码示例。如果您正苦于以下问题:Java IterableExtensions.fold方法的具体用法?Java IterableExtensions.fold怎么用?Java IterableExtensions.fold使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.xtext.xbase.lib.IterableExtensions的用法示例。


在下文中一共展示了IterableExtensions.fold方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getValueAsString

import org.eclipse.xtext.xbase.lib.IterableExtensions; //导入方法依赖的package包/类
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public String getValueAsString() {
	final StringBuilder result = new StringBuilder("`");
	final Function1<Expression, StringBuilder> _function = new Function1<Expression, StringBuilder>() {
		public StringBuilder apply(final Expression expr) {
			StringBuilder _switchResult = null;
			boolean _matched = false;
			if (expr instanceof Literal) {
				_matched=true;
				_switchResult = result.append(TemplateLiteralImpl.this.getValueAsString());
			}
			if (!_matched) {
				_switchResult = result.append("<<").append(TemplateLiteralImpl.this.eClass().getName()).append(">>");
			}
			return _switchResult;
		}
	};
	final Function1<Expression, StringBuilder> appender = _function;
	final Function2<Boolean, Expression, Boolean> _function_1 = new Function2<Boolean, Expression, Boolean>() {
		public Boolean apply(final Boolean isRaw, final Expression expression) {
			if ((!(isRaw).booleanValue())) {
				result.append("${");
				appender.apply(expression);
				result.append("}");
			}
			else {
				appender.apply(expression);
			}
			return Boolean.valueOf((!(isRaw).booleanValue()));
		}
	};
	IterableExtensions.<Expression, Boolean>fold(this.getSegments(), Boolean.valueOf(true), _function_1);
	result.append("`");
	return result.toString();
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:40,代码来源:TemplateLiteralImpl.java

示例2: getLenght

import org.eclipse.xtext.xbase.lib.IterableExtensions; //导入方法依赖的package包/类
public int getLenght() {
  final Function2<Integer, LeafInfo, Integer> _function = (Integer x, LeafInfo i) -> {
    ILeafNode _node = i.getNode();
    int _length = 0;
    if (_node!=null) {
      _length=_node.getLength();
    }
    return Integer.valueOf(((x).intValue() + _length));
  };
  return (int) IterableExtensions.<LeafInfo, Integer>fold(this.leafs, Integer.valueOf(0), _function);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:12,代码来源:HiddenLeafs.java

示例3: getNewLines

import org.eclipse.xtext.xbase.lib.IterableExtensions; //导入方法依赖的package包/类
public int getNewLines() {
  final Function2<Integer, LeafInfo, Integer> _function = (Integer x, LeafInfo i) -> {
    int _newLines = i.getNewLines();
    return Integer.valueOf(((x).intValue() + _newLines));
  };
  return (int) IterableExtensions.<LeafInfo, Integer>fold(this.leafs, Integer.valueOf(0), _function);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:8,代码来源:HiddenLeafs.java

示例4: getNewLinesInComments

import org.eclipse.xtext.xbase.lib.IterableExtensions; //导入方法依赖的package包/类
public int getNewLinesInComments() {
  final Function2<Integer, CommentInfo, Integer> _function = (Integer x, CommentInfo i) -> {
    int _newLines = i.getNewLines();
    return Integer.valueOf(((x).intValue() + _newLines));
  };
  return (int) IterableExtensions.<CommentInfo, Integer>fold(Iterables.<CommentInfo>filter(this.leafs, CommentInfo.class), Integer.valueOf(0), _function);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:8,代码来源:HiddenLeafs.java

示例5: replace

import org.eclipse.xtext.xbase.lib.IterableExtensions; //导入方法依赖的package包/类
public TypeReference replace(final TypeReference target, final Map<? extends TypeReference, ? extends TypeReference> mappings) {
  final Function2<TypeReference, Map.Entry<? extends TypeReference, ? extends TypeReference>, TypeReference> _function = new Function2<TypeReference, Map.Entry<? extends TypeReference, ? extends TypeReference>, TypeReference>() {
    @Override
    public TypeReference apply(final TypeReference result, final Map.Entry<? extends TypeReference, ? extends TypeReference> mapping) {
      return Util.this.replace(result, mapping.getKey(), mapping.getValue());
    }
  };
  return IterableExtensions.fold(mappings.entrySet(), target, _function);
}
 
开发者ID:eclipse,项目名称:xtext-lib,代码行数:10,代码来源:DelegateProcessor.java

示例6: getEObject

import org.eclipse.xtext.xbase.lib.IterableExtensions; //导入方法依赖的package包/类
/**
 * Finds an EObject for the given context EObject and fragment.
 * 
 * @param from the EObject from which the path should be resolved
 * @param toFragment the fragment
 * 
 * @return the resolved EObject based. If the given fragment is <code>null</null>, the given EObject itself will be returned.
 */
public EObject getEObject(final EObject from, final String toFragment) {
  if ((toFragment == null)) {
    return from;
  }
  final Iterable<String> splitted = Splitter.on("/").split(toFragment);
  final Function2<EObject, String, EObject> _function = (EObject $0, String $1) -> {
    return ((InternalEObject) $0).eObjectForURIFragmentSegment($1);
  };
  return IterableExtensions.<String, EObject>fold(splitted, from, _function);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:19,代码来源:PortableURIs.java


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