package org.studiorailgun.sim.space;

import java.util.LinkedList;
import java.util.List;

/**
 * A recursive tree of regions that contain locations at their leaves
 */
public class Region {

    /**
     * The id of the region
     */
    int id;
    
    /**
     * The child reglions of this region
     */
    transient List<Region> children = new LinkedList<Region>();

    /**
     * The discrete locations that are within this region
     */
    transient List<Location> locations = new LinkedList<Location>();

    /**
     * Gets the child regions of this region
     * @return The list of child regions
     */
    public List<Region> getChildren() {
        return children;
    }

    /**
     * Sets the list of child regions of this region
     * @param children The new list of child regions
     */
    public void setChildren(List<Region> children) {
        this.children = children;
    }

    /**
     * Adds a child region
     * @param child The child region
     */
    public void addChild(Region child){
        children.add(child);
    }

    /**
     * Gets the locations of this region
     * @return The locations of this region
     */
    public List<Location> getLocations() {
        return locations;
    }

    /**
     * Sets the locations of this region
     * @param locations The locations of this region
     */
    public void setLocations(List<Location> locations) {
        this.locations = locations;
    }

    /**
     * Adds a location to the region
     * @param location The location
     */
    public void addLocation(Location location){
        this.locations.add(location);
    }

}
