@Override
    protected void writeAttributes(XMLStreamWriter out)
        throws XMLStreamException {
        super.writeAttributes(out);

        if (upgradesFrom != null) {
            out.writeAttribute("upgradesFrom", upgradesFrom.getId());
        }
        out.writeAttribute("workplaces", Integer.toString(workPlaces));
        out.writeAttribute("basicProduction", Integer.toString(basicProduction));
        if (minSkill > UNDEFINED) {
            out.writeAttribute("minSkill", Integer.toString(minSkill));
        }
        if (maxSkill < INFINITY) {
            out.writeAttribute("maxSkill", Integer.toString(maxSkill));
        }
        if (upkeep > 0) {
            out.writeAttribute("upkeep", Integer.toString(upkeep));
        }
        if (priority != Consumer.BUILDING_PRIORITY) {
            out.writeAttribute("priority", Integer.toString(priority));
        }
        if (consumes != null) {
            out.writeAttribute("consumes", consumes.getId());
        }
        if (produces != null) {
            out.writeAttribute("produces", produces.getId());
        }
    }