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

org.nuiton.jaxx.compiler.java.JavaArgument Maven / Gradle / Ivy

The newest version!
/*
 * #%L
 * JAXX :: Compiler
 * %%
 * Copyright (C) 2008 - 2024 Code Lutin, Ultreia.io
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Lesser Public License for more details.
 *
 * You should have received a copy of the GNU General Lesser Public
 * License along with this program.  If not, see
 * .
 * #L%
 */

package org.nuiton.jaxx.compiler.java;

/**
 * Represents an argument to a JavaMethod.
 *
 * @see JavaMethod
 */
public class JavaArgument extends JavaElement {

    private String type;

    private final boolean isFinal;

    /**
     * Creates a new JavaArgument with the specified name and type.  For example, the method main()
     * might have a JavaArgument with a name of "arg" and a type of "java.lang.String[]".
     *
     * @param type the argument's type, as it would appear in Java source code
     * @param name the argument's name
     */
    JavaArgument(String type, String name) {
        this(type, name, false);
    }

    /**
     * Creates a new JavaArgument with the specified name, type, and finality.  For example, the method main()
     * might have a JavaArgument with a name of "arg" and a type of "java.lang.String[]".  The
     * isFinal parameter allows the presence of the final keyword on the argument to be controlled.
     *
     * @param type    the argument's type, as it would appear in Java source code
     * @param name    the argument's name
     * @param isFinal true if the argument should be marked final
     */
    JavaArgument(String type, String name, boolean isFinal) {
        super(0, name);
        this.type = type;
        this.isFinal = isFinal;
    }

    /**
     * Returns the argument's type as it would be represented in Java source code.
     *
     * @return the argument's type
     */
    public String getType() {
        return type;
    }

    /**
     * Returns true if the final keyword should appear before the argument.
     *
     * @return true if the argument is final
     */
    public boolean isFinal() {
        return isFinal;
    }

    public void setType(String type) {
        this.type = type;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy