/**
   * Extracts the address information from the given primitive into a newly created {@link Node}.
   * The new node is added into the JOSM database.
   *
   * <p>If the extraction in not applicable, nothing happens.
   *
   * @param primitive the {@link Way} from which the address will be extracted
   */
  @Override
  public void apply(OsmPrimitive primitive) {

    if (!isApplicable(primitive)) return;

    Way way = (Way) primitive;

    BoundingXYVisitor visitor = new BoundingXYVisitor();
    way.accept(visitor);

    Node addrNode = new Node(visitor.getBounds().getCenter());

    for (String key : way.keySet()) if (key.startsWith("addr")) addrNode.put(key, way.get(key));

    for (String key : addrNode.keySet()) way.remove(key);

    Main.main.getCurrentDataSet().addPrimitive(addrNode);
  }