@Test
 public void testEqualsWithSamePatternButDiffFlagsGetsFalse() {
   Pattern p1 = Pattern.compile("(a)(b)(?:c)(?<named>x)");
   Pattern p2 =
       Pattern.compile("(a)(b)(?:c)(?<named>x)", java.util.regex.Pattern.CASE_INSENSITIVE);
   assertFalse(p1.equals(p2));
 }
Example #2
0
 @Override
 public Set<Pattern> gatherSubPatternsExcluding(Pattern except, boolean includeOptionals) {
   if (except.equals(this)) {
     return Collections.emptySet();
   } else {
     return graphPattern.gatherSubPatternsExcluding(except, includeOptionals);
   }
 }
Example #3
0
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (!super.equals(obj)) return false;
   if (getClass() != obj.getClass()) return false;
   WindowDeclaration other = (WindowDeclaration) obj;
   if (name == null) {
     if (other.name != null) return false;
   } else if (!name.equals(other.name)) return false;
   if (pattern == null) {
     if (other.pattern != null) return false;
   } else if (!pattern.equals(other.pattern)) return false;
   return true;
 }
 @Test
 public void testEqualsGetsTrueForSameInstance() {
   Pattern p = Pattern.compile("(a)(b)(?:c)(?<named>x)");
   assertTrue(p.equals(p));
 }
 @Test
 public void testEqualsWithSameFlagsButDiffPatternGetsFalse() {
   Pattern p1 = Pattern.compile("(a)(b)(?:c)(?<named>x)", java.util.regex.Pattern.DOTALL);
   Pattern p2 = Pattern.compile("(?<named>x)", java.util.regex.Pattern.DOTALL);
   assertFalse(p1.equals(p2));
 }
 @Test
 public void testEqualsWithSamePatternAndFlagsGetsTrue() {
   Pattern p1 = Pattern.compile("(a)(b)(?:c)(?<named>x)");
   Pattern p2 = Pattern.compile("(a)(b)(?:c)(?<named>x)");
   assertTrue(p1.equals(p2));
 }
 @Test
 public void testEqualsDiffDataTypeGetsFalse() {
   Pattern p = Pattern.compile("(a)(b)(?:c)(?<named>x)");
   assertFalse(p.equals(new Object()));
 }
 @Test
 public void testEqualsNullGetsFalse() {
   Pattern p = Pattern.compile("(a)(b)(?:c)(?<named>x)");
   assertFalse(p.equals(null));
 }