001/*
002 *  Licensed to the Apache Software Foundation (ASF) under one or more
003 *  contributor license agreements.  See the NOTICE file distributed with
004 *  this work for additional information regarding copyright ownership.
005 *  The ASF licenses this file to You under the Apache License, Version 2.0
006 *  (the "License"); you may not use this file except in compliance with
007 *  the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 *  Unless required by applicable law or agreed to in writing, software
012 *  distributed under the License is distributed on an "AS IS" BASIS,
013 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 *  See the License for the specific language governing permissions and
015 *  limitations under the License.
016 */
017package org.apache.commons.compress.utils;
018
019import java.io.InputStream;
020import java.util.Objects;
021import java.util.zip.CheckedInputStream;
022import java.util.zip.Checksum;
023
024/**
025 * Calculates the checksum of the data read.
026 *
027 * @NotThreadSafe
028 * @since 1.14
029 * @deprecated Use {@link CheckedInputStream}.
030 */
031@Deprecated
032public class ChecksumCalculatingInputStream extends CheckedInputStream {
033
034    /**
035     * Constructs a new instance.
036     *
037     * @param checksum    The checksum to update
038     * @param inputStream The input stream to read.
039     * @deprecated Use {@link CheckedInputStream#CheckedInputStream(InputStream, Checksum)}.
040     */
041    @Deprecated
042    @SuppressWarnings("resource")
043    public ChecksumCalculatingInputStream(final Checksum checksum, final InputStream inputStream) {
044        super(Objects.requireNonNull(inputStream, "inputStream"), Objects.requireNonNull(checksum, "checksum"));
045    }
046
047    /**
048     * Returns the calculated checksum.
049     *
050     * @return the calculated checksum.
051     * @deprecated Use {@link CheckedInputStream#getChecksum()} and {@link Checksum#getValue()}.
052     */
053    @Deprecated
054    public long getValue() {
055        return getChecksum().getValue();
056    }
057
058}