IrCollection.java
/*******************************************************************************
* Copyright (c) 2025 Eclipse RDF4J contributors.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Distribution License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*******************************************************************************/
package org.eclipse.rdf4j.queryrender.sparql.ir;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.rdf4j.query.algebra.Var;
/**
* IR node representing an RDF Collection term used as an object: a parenthesized list of terms.
*/
public class IrCollection extends IrNode {
private final List<Var> items = new ArrayList<>();
public IrCollection(boolean newScope) {
super(newScope);
}
public void addItem(Var v) {
if (v != null) {
items.add(v);
}
}
@Override
public void print(IrPrinter p) {
StringBuilder sb = new StringBuilder();
sb.append("(");
for (int i = 0; i < items.size(); i++) {
if (i > 0) {
sb.append(' ');
}
sb.append(p.convertVarToString(items.get(i)));
}
sb.append(")");
p.append(sb.toString());
}
}