All Downloads are FREE. Search and download functionalities are using the official Maven repository.

spoon.reflect.path.impl.AbstractPathElement Maven / Gradle / Ivy

Go to download

Spoon is a tool for meta-programming, analysis and transformation of Java programs.

There is a newer version: 11.1.1-beta-14
Show newest version
/*
 * SPDX-License-Identifier: (MIT OR CECILL-C)
 *
 * Copyright (C) 2006-2023 INRIA and contributors
 *
 * Spoon is available either under the terms of the MIT License (see LICENSE-MIT.txt) or the Cecill-C License (see LICENSE-CECILL-C.txt). You as the user are entitled to choose the terms under which to adopt Spoon.
 */
package spoon.reflect.path.impl;

import spoon.reflect.declaration.CtElement;
import spoon.reflect.visitor.CtScanner;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;
import java.util.StringJoiner;
import java.util.TreeMap;

/**
 * Partial implementation for CtPathElement
 */
public abstract class AbstractPathElement

implements CtPathElement { public static final String ARGUMENT_START = "["; public static final String ARGUMENT_END = "]"; public static final String ARGUMENT_NAME_SEPARATOR = "="; private Map arguments = new TreeMap<>(); public Map getArguments() { return arguments; } @Override public > C addArgument(String key, String value) { arguments.put(key, value); return (C) this; } Collection getChildren(CtElement element) { final Collection elements = new ArrayList<>(); if (element != null) { element.accept(new CtScanner() { @Override public void scan(CtElement element) { elements.add(element); } }); } return elements; } protected String getParamString() { if (arguments.isEmpty()) { return ""; } StringJoiner joiner = new StringJoiner(";", "[", "]"); for (Map.Entry entry : arguments.entrySet()) { joiner.add(entry.getKey() + "=" + entry.getValue()); } return joiner.toString(); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy