001/*
002 * JDrupes Builder
003 * Copyright (C) 2026 Michael N. Lipp
004 * 
005 * This program is free software: you can redistribute it and/or modify
006 * it under the terms of the GNU Affero General Public License as
007 * published by the Free Software Foundation, either version 3 of the
008 * License, or (at your option) any later version.
009 *
010 * This program is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
013 * GNU Affero General Public License for more details.
014 *
015 * You should have received a copy of the GNU Affero General Public License
016 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
017 */
018
019package org.jdrupes.builder.api;
020
021import java.io.InputStream;
022import java.time.Instant;
023
024/// Represents a resource that has readable contents.
025/// 
026/// Implementations of this interface must provide a [ResourceFactory]
027/// that supports the invocation of [ResourceFactory#create] with
028/// arguments
029///
030/// * [Instant] the modification time
031/// * [InputStream] the input stream
032///
033public interface InputResource extends Resource {
034
035    /// Returns the input stream.
036    ///
037    /// @return the input stream
038    ///
039    InputStream inputStream();
040
041    /// Creates a new input resource.
042    ///
043    /// @param asOf the modification date
044    /// @param inputData the data
045    /// @return the file resource
046    ///
047    @SuppressWarnings({ "PMD.UseDiamondOperator", "PMD.ShortMethodName" })
048    static InputResource of(Instant asOf, InputStream inputData) {
049        return ResourceFactory.create(new ResourceType<InputResource>() {},
050            asOf, inputData);
051    }
052}