<commit_before>package filter;

import java.util.ArrayList;
import java.util.List;

import model.TurboIssue;

public class Conjunction implements FilterExpression {
	private FilterExpression left;
	private FilterExpression right;

	public Conjunction(FilterExpression left, FilterExpression right) {
		this.left = left;
		this.right = right;
	}

	@Override
	public String toString() {
		return "(" + left + " and " + right + ")";
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Conjunction other = (Conjunction) obj;
		if (left == null) {
			if (other.left != null)
				return false;
		} else if (!left.equals(other.left))
			return false;
		if (right == null) {
			if (other.right != null)
				return false;
		} else if (!right.equals(other.right))
			return false;
		return true;
	}

	public boolean isSatisfiedBy(TurboIssue issue) {
		return left.isSatisfiedBy(issue) && right.isSatisfiedBy(issue);
	}
	
	@Override
	public boolean canBeAppliedToIssue() {
		return left.canBeAppliedToIssue() && right.canBeAppliedToIssue();
	}

	@Override
	public void applyTo(TurboIssue issue) {
		left.applyTo(issue);<commit_msg>Only conjunctions which don't contain duplicate predicate names can be applied to issues<commit_after>package filter;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;

import model.TurboIssue;

public class Conjunction implements FilterExpression {
	private FilterExpression left;
	private FilterExpression right;

	public Conjunction(FilterExpression left, FilterExpression right) {
		this.left = left;
		this.right = right;
	}

	@Override
	public String toString() {
		return "(" + left + " and " + right + ")";
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Conjunction other = (Conjunction) obj;
		if (left == null) {
			if (other.left != null)
				return false;
		} else if (!left.equals(other.left))
			return false;
		if (right == null) {
			if (other.right != null)
				return false;
		} else if (!right.equals(other.right))
			return false;
		return true;
	}

	public boolean isSatisfiedBy(TurboIssue issue) {
		return left.isSatisfiedBy(issue) && right.isSatisfiedBy(issue);
	}
	
	private boolean containsDuplicatePredicateNames() {
		List<String> predicateNames = getPredicateNames();
		HashSet<String> noDuplicates = new HashSet<>(predicateNames);
		return noDuplicates.size() != predicateNames.size();
	}
	
	@Override
	public boolean canBeAppliedToIssue() {
		return !containsDuplicatePredicateNames() && left.canBeAppliedToIssue() && right.canBeAppliedToIssue();
	}

	@Override
	public void applyTo(TurboIssue issue) {
		left.applyTo(issue);
{'fraction_non_alphanumeric': 0.11674239776301992, 'fraction_numerical': 0.0, 'mean_word_length': 4.251376146788991, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, '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': '331458', 'n_tokens_mistral': 1006, 'n_tokens_neox': 887, 'n_words': 243}