JVMName () { final List<JVMName> optimised = new ArrayList<>(); for (JVMName evaluator : myList) { if (evaluator instanceof JVMRawText && !optimised.isEmpty() && optimised.get(optimised.size() - 1) instanceof JVMRawText nameEvaluator) { nameEvaluator.setName(nameEvaluator.getName() + ((JVMRawText)evaluator).getName()); } else { optimised.add(evaluator); } } if (optimised.size() == 1) return optimised.get(0); if (optimised.isEmpty()) return new JVMRawText(""); return new JVMName() { String myName = null; @Override public String getName(DebugProcessImpl process) throws EvaluateException { if (myName == null) { String name = ""; for (JVMName nameEvaluator : optimised) { name += nameEvaluator.getName(process); } myName = name; } return myName; } @Override public String getDisplayName(DebugProcessImpl debugProcess) { if (myName == null) { String displayName = ""; for (JVMName nameEvaluator : optimised) { displayName += nameEvaluator.getDisplayName(debugProcess); } return displayName; } return myName; } }; }