<commit_before>package org.aikodi.chameleon.core.element;

public class DescendantStream extends AbstractEventStream<Change,Element> implements EventListener<Change,Element> {

  private Element _element;

  public DescendantStream(Element element) {
    this._element = element;
  }

  @Override
  protected void activate() {
    _element.children().stream().forEach(c -> {
      EventStream<Change,Element> descendant = c.when().descendant();
      descendant.call(this);
    });
  }

  @Override
  protected void deactivate() {
    _element.children().stream().forEach(c -> {
      c.when().descendant().stopCalling(this);
    });
  }

  @Override
  public void accept(Event<? extends Change, ? extends Element> event) {
    send(event);
  }

}
<commit_msg>connect and disconnect to children<commit_after>package org.aikodi.chameleon.core.element;

public class DescendantStream extends AbstractEventStream<Change,Element> implements EventListener<Change,Element> {

  private Element _element;

  private EventListener<? super Added, ? super Element> _adder = c -> {
    c.change().element().when().any().call(this);
  };
  private EventListener<? super Removed, ? super Element> _remover = c -> {
    c.change().element().when().any().stopCalling(this);
  };

  private EventStream<Added, Element> _addStream;

  private EventStream<Removed, Element> _removeStream;

  public DescendantStream(Element element) {
    this._element = element;
  }

  @Override
  protected void activate() {
    _element.children().stream().forEach(c -> {
      c.when().any().call(this);
    });
    _addStream = _element.when().self().about(Added.class);
    _addStream.call(_adder);
    _removeStream = _element.when().self().about(Removed.class);
    _removeStream.call(_remover);
  }

  @Override
  protected void deactivate() {
    _element.children().stream().forEach(c -> {
      c.when().any().stopCalling(this);
    });
    _addStream.stopCalling(_adder);
    _removeStream.stopCalling(_remover);
  }

  @Override
  public void accept(Event<? extends Change, ? extends Element> event) {
    send(event);
  }

}

{'fraction_non_alphanumeric': 0.14102564102564102, 'fraction_numerical': 0.0, 'mean_word_length': 4.04066985645933, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6034454', 'n_tokens_mistral': 638, 'n_tokens_neox': 623, 'n_words': 119}