@Override public boolean equals(Object o) { if (!(o instanceof Repetition)) { return false; } Repetition that = (Repetition) o; return this.body.equals(that.body) && this.min == that.min && this.max == that.max && this.greedy == that.greedy; }
@Override public boolean equals(Object o) { if (!(o instanceof LookbehindAssertion)) { return false; } LookbehindAssertion that = (LookbehindAssertion) o; return this.positive == that.positive && this.body.equals(that.body); }
@Override public boolean equals(Object o) { if (!(o instanceof LookaheadAssertion)) { return false; } LookaheadAssertion that = (LookaheadAssertion) o; return this.positive == that.positive && this.body.equals(that.body); }
@Override public boolean equals(Object o) { return o instanceof CapturingGroup && body.equals(((CapturingGroup) o).body); }
@Override public boolean equals(Object o) { if (!(o instanceof Repetition)) { return false; } Repetition that = (Repetition) o; return this.body.equals(that.body) && this.min == that.min && this.max == that.max && this.greedy == that.greedy; }
@Override public boolean equals(Object o) { if (!(o instanceof LookaheadAssertion)) { return false; } LookaheadAssertion that = (LookaheadAssertion) o; return this.positive == that.positive && this.body.equals(that.body); }
@Override public boolean equals(Object o) { return o instanceof CapturingGroup && body.equals(((CapturingGroup) o).body); }
@Override public boolean equals(Object o) { return o instanceof NamedCaptureGroup && name.equals(((NamedCaptureGroup) o).name) && body.equals(((NamedCaptureGroup) o).body); }
@Override public RegExpTree simplify(String flags) { RegExpTree body = this.body.simplify(flags); if (max == 0 && !body.hasCapturingGroup()) { return Empty.INSTANCE; } if (body instanceof Empty || NEVER_MATCHES.equals(body)) { return body; } int min = this.min; int max = this.max; if (body instanceof Repetition) { Repetition rbody = (Repetition) body; if (rbody.greedy == greedy) { long lmin = ((long) min) * rbody.min; long lmax = ((long) max) * rbody.max; if (lmin < Integer.MAX_VALUE) { body = rbody.body; min = (int) lmin; max = lmax >= Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) lmax; } } } if (min == 1 && max == 1) { return body; } boolean greedy = this.greedy || min == max; return body.equals(this.body) && min == this.min && max == this.max && greedy == this.greedy ? this : new Repetition(body, min, max, greedy).simplify(flags); }
@Override public RegExpTree simplify(String flags) { RegExpTree body = this.body.simplify(flags); if (max == 0 && !body.hasCapturingGroup()) { return Empty.INSTANCE; } if (body instanceof Empty || NEVER_MATCHES.equals(body)) { return body; } int min = this.min; int max = this.max; if (body instanceof Repetition) { Repetition rbody = (Repetition) body; if (rbody.greedy == greedy) { long lmin = ((long) min) * rbody.min; long lmax = ((long) max) * rbody.max; if (lmin < Integer.MAX_VALUE) { body = rbody.body; min = (int) lmin; max = lmax >= Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) lmax; } } } if (min == 1 && max == 1) { return body; } boolean greedy = this.greedy || min == max; return body.equals(this.body) && min == this.min && max == this.max && greedy == this.greedy ? this : new Repetition(body, min, max, greedy).simplify(flags); }