本文整理汇总了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();
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}