001/*
002 * (C) Copyright 2020 Nuxeo (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Florent Guillaume
018 */
019package org.nuxeo.ecm.core.blob;
020
021import java.time.Instant;
022
023/**
024 * Status associated to a blob in storage.
025 *
026 * @since 11.1
027 */
028public class BlobStatus {
029
030    protected String storageClass;
031
032    protected boolean downloadable = true;
033
034    protected Instant downloadableUntil;
035
036    public BlobStatus withStorageClass(String storageClass) {
037        this.storageClass = storageClass;
038        return this;
039    }
040
041    public BlobStatus withDownloadable(boolean downloadable) {
042        this.downloadable = downloadable;
043        return this;
044    }
045
046    public BlobStatus withDownloadableUntil(Instant downloadableUntil) {
047        this.downloadableUntil = downloadableUntil;
048        return this;
049    }
050
051    /**
052     * The storage class, or {@code null} for the standard storage class.
053     */
054    public String getStorageClass() {
055        return storageClass;
056    }
057
058    /**
059     * Whether the blob can be immediately downloaded.
060     */
061    public boolean isDownloadable() {
062        return downloadable;
063    }
064
065    /**
066     * If the blob can be download for a limited time, until when.
067     * <p>
068     * Returns {@code null} if the blob is always downloadable, or is not immediately downloadable.
069     */
070    public Instant getDownloadableUntil() {
071        return downloadableUntil;
072    }
073
074}