@Override
    public boolean match(Message msg, StreamRule rule) {
        Object rawField = msg.getField(rule.getField());

        if (rawField == null) {
            return rule.getInverted();
        }

        if (rawField instanceof String) {
            String field = (String) rawField;
            Boolean result = rule.getInverted() ^ !(field.trim().isEmpty());
            return result;
        }

        return !rule.getInverted();
    }
@Test
    public void testInvertedRandomNumberFieldMatch() throws Exception {
        String fieldName = "sampleField";
        Integer randomNumber = 4;
        StreamRule rule = getSampleRule();
        rule.setField(fieldName);
        rule.setType(StreamRuleType.PRESENCE);
        rule.setInverted(true);

        Message message = getSampleMessage();
        message.addField(fieldName, randomNumber);

        StreamRuleMatcher matcher = getMatcher(rule);

        Boolean result = matcher.match(message, rule);
        assertFalse(result);
    }