protected <T extends JFIFPiece> List<T> filterSegments(final List<T> segments, final SegmentFilter filter, final boolean reverse) {
        final List<T> result = new ArrayList<>();

        for (final T piece : segments) {
            if (piece instanceof JFIFPieceSegment) {
                if (filter.filter((JFIFPieceSegment) piece) == reverse) {
                    result.add(piece);
                }
            } else if (!reverse) {
                result.add(piece);
            }
        }

        return result;
    }
Constructs a new instance with the default, big-endian, byte order.
<p>
Whether a file contains an image based on its file extension.
</p>
src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegRewriter.java