/*
 * Copyright (c) 2015 Brandon Lyon
 *
 * This file is part of Emerge Game Engine (Emerge)
 *
 * Emerge is free software: you can redistribute it and/or modify
 * it under the terms of version 3 of the GNU General Public License as
 * published by the Free Software Foundation.
 *
 * Emerge 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 Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Emerge.  If not, see <http://www.gnu.org/licenses/>.
 */

package net.etherous.emerge.manager.config;

import java.io.File;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;

@XmlAccessorType (XmlAccessType.FIELD)
public class NativeNode
{
    // Name of the native file (Required)
    @XmlAttribute (name = "name", required = true)
    String name;

    // The native's target platform (Optional. Can be inferred. May not be needed)
    @XmlAttribute (name = "plat", required = false)
    String platform;

    // The native's target architecture (Optional. Can be inferred. May not be needed)
    @XmlAttribute (name = "arch", required = false)
    String architecture;

    // File path to the native. Can be either absolute or relative to EMERGE_HOME (Optional. Can be inferred)
    @XmlAttribute (name = "path", required = false)
    String path;

    public NativeNode ()
    {
    }

    public String getName ()
    {
        return this.name;
    }
    public void setName (final String name)
    {
        this.name = name;
    }
    public String getPlatform ()
    {
        return this.platform;
    }
    public void setPlatform (final String platform)
    {
        this.platform = platform;
    }
    public String getArchitecture ()
    {
        return this.architecture;
    }
    public void setArchitecture (final String architecture)
    {
        this.architecture = architecture;
    }
    public String getPath ()
    {
        return this.path;
    }
    public void setPath (final String path)
    {
        this.path = path;
    }
    public File getFile (final File defaultPath)
    {
        final String path = this.getPath ();
        if (path != null)
            return new File (path);
        return new File (defaultPath, this.name);
    }
}
