/** * Converts an iterable of tokens into an array of primitive integers. Returns * with an empty array if the argument is {@code null} or empty. * * <p> * <ul> * <li>{@code array[3*i]} is the {@link Token#character character} of the * token.</li> * <li>{@code array[3*i+1]} is the {@link Token#length length} of the * token.</li> * <li>{@code array[3*i+2]} is the token {@link Token#scope scope}.</li> * </ul> */ public static int[] toIntArray(Iterable<? extends Token> tokens) { if (IterableExtensions.isNullOrEmpty(tokens)) { return EMPTY_ARRAY; } int[] array = new int[Iterables.size(tokens) * 3]; int i = 0; for (Token token : tokens) { array[i++] = token.character; array[i++] = token.length; array[i++] = token.scope; } return array; }
/** * Converts an iterable of tokens into an array of primitive integers. Returns * with an empty array if the argument is {@code null} or empty. * * <p> * <ul> * <li>{@code array[3*i]} is the {@link Token#character character} of the * token.</li> * <li>{@code array[3*i+1]} is the {@link Token#length length} of the * token.</li> * <li>{@code array[3*i+2]} is the token {@link Token#scope scope}.</li> * </ul> */ public static int[] toIntArray(Iterable<? extends Token> tokens) { if (IterableExtensions.isNullOrEmpty(tokens)) { return EMPTY_ARRAY; } int[] array = new int[Iterables.size(tokens) * 3]; int i = 0; for (Token token : tokens) { array[i++] = token.character; array[i++] = token.length; array[i++] = token.scope; } return array; }
/** * Encodes the iterable of tokens into a compact, {@code base64} string. Returns * with an empty string if the {@code tokens} argument is {@code null} or empty. */ public static String encode(Iterable<? extends Token> tokens) { if (IterableExtensions.isNullOrEmpty(tokens)) { return ""; } // 2 stands for: number of elements for the output; the "character" and the // "length and scope". // 4 stands for: 4 byte for a primitive integer. ByteBuffer buffer = ByteBuffer.allocate(Iterables.size(tokens) * 2 * 4); for (Token token : tokens) { int character = token.character; int length = token.length; int scope = token.scope; int lengthAndScope = length; lengthAndScope = lengthAndScope << LENGTH_SHIFT; lengthAndScope |= scope; buffer.putInt(character); buffer.putInt(lengthAndScope); } return Base64.getEncoder().encodeToString(buffer.array()); }
/** * Encodes the iterable of tokens into a compact, {@code base64} string. Returns * with an empty string if the {@code tokens} argument is {@code null} or empty. */ public static String encode(Iterable<? extends Token> tokens) { if (IterableExtensions.isNullOrEmpty(tokens)) { return ""; } // 2 stands for: number of elements for the output; the "character" and the // "length and scope". // 4 stands for: 4 byte for a primitive integer. ByteBuffer buffer = ByteBuffer.allocate(Iterables.size(tokens) * 2 * 4); for (Token token : tokens) { int character = token.character; int length = token.length; int scope = token.scope; int lengthAndScope = length; lengthAndScope = lengthAndScope << LENGTH_SHIFT; lengthAndScope |= scope; buffer.putInt(character); buffer.putInt(lengthAndScope); } return Base64.getEncoder().encodeToString(buffer.array()); }
public boolean hasDimensions(final VariableDeclarationFragment fragment) { boolean _java8orHigher = this.java8orHigher(); if (_java8orHigher) { List<ASTNode> dimensions = this._aSTFlattenerUtils.genericChildListProperty(fragment, "extraDimensions2"); boolean _isNullOrEmpty = IterableExtensions.isNullOrEmpty(dimensions); return (!_isNullOrEmpty); } else { int _extraDimensions = fragment.getExtraDimensions(); return (_extraDimensions > 0); } }
public Map<Integer,StyleSpecificationProperty> combineStyles(final List<Style> list) { boolean _isNullOrEmpty = IterableExtensions.isNullOrEmpty(list); if (_isNullOrEmpty) { return null;
public static CharSequence writeIdentities(final Set<IdentitySchemaNode> identities) { CharSequence _xblockexpression = null; { boolean _isNullOrEmpty = IterableExtensions.isNullOrEmpty(identities); if (_isNullOrEmpty) { return ""; } StringConcatenation _builder = new StringConcatenation(); { for(final IdentitySchemaNode identity : identities) { CharSequence _writeIdentity = YangTemplate.writeIdentity(identity); _builder.append(_writeIdentity, ""); _builder.newLineIfNotEmpty(); } } _xblockexpression = _builder; } return _xblockexpression; }
public static CharSequence writeUnknownSchemaNodes(final List<UnknownSchemaNode> unknownSchemaNodes) { CharSequence _xblockexpression = null; { boolean _isNullOrEmpty = IterableExtensions.isNullOrEmpty(unknownSchemaNodes); if (_isNullOrEmpty) { return ""; } StringConcatenation _builder = new StringConcatenation(); { for(final UnknownSchemaNode unknownSchemaNode : unknownSchemaNodes) { CharSequence _writeUnknownSchemaNode = YangTemplate.writeUnknownSchemaNode(unknownSchemaNode); _builder.append(_writeUnknownSchemaNode, ""); _builder.newLineIfNotEmpty(); } } _xblockexpression = _builder; } return _xblockexpression; }
public boolean handleLambdaExpression(final ASTNode node) { this.appendToBuffer("["); final List<ASTNode> params = this._aSTFlattenerUtils.genericChildListProperty(node, "parameters"); boolean _isNullOrEmpty = IterableExtensions.isNullOrEmpty(params); boolean _not = (!_isNullOrEmpty); if (_not) { this.visitAllSeparatedByComma(params); this.appendToBuffer(" | "); } ASTNode _genericChildProperty = this._aSTFlattenerUtils.genericChildProperty(node, "body"); if (_genericChildProperty!=null) { _genericChildProperty.accept(this); } this.appendToBuffer("]"); return false; }
}; final Function1<List<String>, Boolean> _function_2 = (List<String> it) -> { boolean _isNullOrEmpty = IterableExtensions.isNullOrEmpty(it); return Boolean.valueOf((!_isNullOrEmpty)); };
final Function1<DocumentSymbol, String> _function_3 = (DocumentSymbol symbol) -> { final Function1<DocumentSymbol, Boolean> _function_4 = (DocumentSymbol it) -> { return Boolean.valueOf((((it != symbol) && (!IterableExtensions.isNullOrEmpty(it.getChildren()))) && it.getChildren().contains(symbol))); }; DocumentSymbol _findFirst = IterableExtensions.<DocumentSymbol>findFirst(symbols, _function_4);
@Override public boolean visit(final ArrayType node) { boolean _java8orHigher = this.java8orHigher(); boolean _not = (!_java8orHigher); if (_not) { node.getComponentType().accept(this); this.appendToBuffer("[]"); } else { ASTNode _genericChildProperty = this._aSTFlattenerUtils.genericChildProperty(node, "elementType"); if (_genericChildProperty!=null) { _genericChildProperty.accept(this); } List<ASTNode> dimensions = this._aSTFlattenerUtils.genericChildListProperty(node, "dimensions"); boolean _isNullOrEmpty = IterableExtensions.isNullOrEmpty(dimensions); boolean _not_1 = (!_isNullOrEmpty); if (_not_1) { final Consumer<ASTNode> _function = (ASTNode dim) -> { List<ASTNode> _genericChildListProperty = this._aSTFlattenerUtils.genericChildListProperty(dim, "annotations"); if (_genericChildListProperty!=null) { this.visitAll(_genericChildListProperty); } this.appendToBuffer("[]"); }; dimensions.forEach(_function); } } return false; }
public static CharSequence writeRpcInput(final ContainerSchemaNode input) { CharSequence _xblockexpression = null; { boolean _equals = Objects.equal(input, null); if (_equals) { return ""; } StringConcatenation _builder = new StringConcatenation(); _builder.append("input {"); _builder.newLine(); { Collection<DataSchemaNode> _childNodes = input.getChildNodes(); boolean _isNullOrEmpty = IterableExtensions.isNullOrEmpty(_childNodes); boolean _not = (!_isNullOrEmpty); if (_not) { _builder.append(" "); Collection<DataSchemaNode> _childNodes_1 = input.getChildNodes(); CharSequence _writeDataSchemaNodes = YangTemplate.writeDataSchemaNodes(_childNodes_1); _builder.append(_writeDataSchemaNodes, " "); _builder.newLineIfNotEmpty(); } } _builder.append("}"); _builder.newLine(); _builder.newLine(); _xblockexpression = _builder; } return _xblockexpression; }
final Document doc = ctx.getDocument(); final List<? extends ColoringInformation> coloringInfos = coloringService.getColoring(resource, doc); boolean _isNullOrEmpty = IterableExtensions.isNullOrEmpty(coloringInfos); boolean _not = (!_isNullOrEmpty); if (_not) {
public static CharSequence writeRpcOutput(final ContainerSchemaNode output) { CharSequence _xblockexpression = null; { boolean _equals = Objects.equal(output, null); if (_equals) { return ""; } StringConcatenation _builder = new StringConcatenation(); _builder.append("output {"); _builder.newLine(); { Collection<DataSchemaNode> _childNodes = output.getChildNodes(); boolean _isNullOrEmpty = IterableExtensions.isNullOrEmpty(_childNodes); boolean _not = (!_isNullOrEmpty); if (_not) { _builder.append(" "); Collection<DataSchemaNode> _childNodes_1 = output.getChildNodes(); CharSequence _writeDataSchemaNodes = YangTemplate.writeDataSchemaNodes(_childNodes_1); _builder.append(_writeDataSchemaNodes, " "); _builder.newLineIfNotEmpty(); } } _builder.append("}"); _builder.newLine(); _xblockexpression = _builder; } return _xblockexpression; }
public static String generateYangSnipet(final Set<? extends SchemaNode> nodes) { String _xblockexpression = null; { boolean _isNullOrEmpty = IterableExtensions.isNullOrEmpty(nodes); if (_isNullOrEmpty) { return ""; } StringConcatenation _builder = new StringConcatenation(); { for(final SchemaNode node : nodes) { { if ((node instanceof NotificationDefinition)) { CharSequence _writeNotification = YangTemplate.writeNotification(((NotificationDefinition)node)); _builder.append(_writeNotification, ""); _builder.newLineIfNotEmpty(); } else { if ((node instanceof RpcDefinition)) { CharSequence _writeRPC = YangTemplate.writeRPC(((RpcDefinition) node)); _builder.append(_writeRPC, ""); _builder.newLineIfNotEmpty(); } } } } } _xblockexpression = _builder.toString(); } return _xblockexpression; }
public static String writeModuleImports(final Set<ModuleImport> moduleImports) { String _xblockexpression = null; boolean _isNullOrEmpty = IterableExtensions.isNullOrEmpty(moduleImports); if (_isNullOrEmpty) { return "";
boolean _isNullOrEmpty = IterableExtensions.isNullOrEmpty(_groupings); boolean _not = (!_isNullOrEmpty); if (_not) { boolean _isNullOrEmpty_1 = IterableExtensions.isNullOrEmpty(_childNodes); boolean _not_1 = (!_isNullOrEmpty_1); if (_not_1) { boolean _isNullOrEmpty_2 = IterableExtensions.isNullOrEmpty(_unknownSchemaNodes); boolean _not_2 = (!_isNullOrEmpty_2); if (_not_2) {
@Override public boolean visit(final TryStatement node) { this.appendToBuffer("try "); final List<ASTNode> resources = this._aSTFlattenerUtils.genericChildListProperty(node, "resources"); boolean _isNullOrEmpty = IterableExtensions.isNullOrEmpty(resources); boolean _not = (!_isNullOrEmpty); if (_not) { this.appendToBuffer("("); for (final ASTNode child : resources) { child.accept(this); } this.appendToBuffer(")"); this.addProblem(node, "Try with resource is not yet supported."); } node.getBody().accept(this); final Consumer<Object> _function = (Object it) -> { ((ASTNode) it).accept(this); }; node.catchClauses().forEach(_function); Block _finally = node.getFinally(); boolean _tripleNotEquals = (_finally != null); if (_tripleNotEquals) { this.appendToBuffer(" finally "); node.getFinally().accept(this); } else { this.appendLineWrapToBuffer(); } return false; }
boolean _isNullOrEmpty = IterableExtensions.isNullOrEmpty(_childNodes); boolean _not = (!_isNullOrEmpty); if (_not) { boolean _isNullOrEmpty_1 = IterableExtensions.isNullOrEmpty(_availableAugmentations); boolean _not_1 = (!_isNullOrEmpty_1); if (_not_1) { boolean _isNullOrEmpty_2 = IterableExtensions.isNullOrEmpty(_groupings); boolean _not_2 = (!_isNullOrEmpty_2); if (_not_2) { boolean _isNullOrEmpty_3 = IterableExtensions.isNullOrEmpty(_uses); boolean _not_3 = (!_isNullOrEmpty_3); if (_not_3) { boolean _isNullOrEmpty_4 = IterableExtensions.isNullOrEmpty(_unknownSchemaNodes); boolean _not_4 = (!_isNullOrEmpty_4); if (_not_4) {