@Override
   public boolean match(String attributeValue) {
      if (attributeValue == null) {
         return false;
      }

      switch (type) {
         case Equals:
            return attributeValue.equals(value);
         case StartsWith:
            return (length == -1 || length == attributeValue.length()) && attributeValue.startsWith(value);
         case EndsWith:
            return (length == -1 || length == attributeValue.length()) && attributeValue.endsWith(value);
         case Contains:
            return attributeValue.contains(value);
         case Regexp:
            return regexPattern.matcher(attributeValue).matches();
         default:
            throw new IllegalStateException("Unexpected type " + type);
      }
   }
@Test
   public void testGeneralMetacharEscaping() {
      assertTrue(new LikeCondition("a%(b").match("aaa(b"));
      assertTrue(new LikeCondition("a%)b").match("aaa)b"));
      assertTrue(new LikeCondition("a%[b").match("aaa[b"));
      assertTrue(new LikeCondition("a%]b").match("aaa]b"));
      assertTrue(new LikeCondition("a%{b").match("aaa{b"));
      assertTrue(new LikeCondition("a%}b").match("aaa}b"));
      assertTrue(new LikeCondition("a%$b").match("aaa$b"));
      assertTrue(new LikeCondition("a%^b").match("aaa^b"));
      assertTrue(new LikeCondition("a%.b").match("aaa.b"));
      assertTrue(new LikeCondition("a%|b").match("aaa|b"));
      assertTrue(new LikeCondition("a%\\b").match("aaa\\b"));
   }