Avoid sharing script objects or script arrays across threads (this includes global.) Sharing script objects is asking for trouble. Share only primitive data types, or Java objects.
List<Predicate> predicates = new ArrayList<Predicate>();
//Adding predicates in case of parameter not being null
if (param1 != null) {
predicates.add(
qb.equal(customer.get("someAttribute"), param1));
}
if (paramNull != null) {
predicates.add(
qb.equal(customer.get("someOtherAttribute"), paramNull));
}
//query itself
cq.select(customer)
.where(predicates.toArray(new Predicate[]{}));
// create the JAXP XPath evaluation environment.
XPath xpath = XPathFactory.newInstance().newXPath();
// creat an xpath expression. This example select all nodes with the
// name 'link' from the root of the document.
String expression = "//link";
// get a list of nodes using the xpath environment, DOM Document and the
// XPath expression. Specify the type of node that is retrived (in this
// case its a NODESET which is a list of nodes)
NodeList linkNodes = (NodeList) xpath.evaluate(expression, bbcDoc, XPathConstants.NODESET);
for (int i = 0; i < linkNodes.getLength(); i++) {
// System.out.println(linkNodes.item(i).getTextContent());
}
// Convert elements to strings and concatenate them, separated by commas String joined = things.stream() .map(Object::toString) .collect(Collectors.joining(", "));