001package org.unix4j.unix.grep;
002
003import org.unix4j.line.Line;
004
005/**
006 * Inverts the result of another matcher that is passed to the constructor.
007 */
008class InvertedMatcher implements LineMatcher {
009        
010        private final LineMatcher matcher;
011        
012        /**
013         * Constructor with matcher to invert.
014         * @param matcher the matcher to invert
015         */
016        public InvertedMatcher(LineMatcher matcher) {
017                this.matcher = matcher;
018        }
019
020        @Override
021        public boolean matches(Line line) {
022                return !matcher.matches(line);
023        }
024
025}