001/*
002 *  Copyright 2020 Anyware Services
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 */
016package org.ametys.plugins.repository.data.holder.values;
017
018import java.util.Optional;
019
020import org.ametys.plugins.repository.data.external.ExternalizableDataProvider.ExternalizableDataStatus;
021
022/**
023 * Object that gives some context for data in data holder manipulations
024 */
025public class ValueContext
026{
027    private Optional<ExternalizableDataStatus> _status = Optional.empty();
028    
029    /**
030     * Creates a new instance of a {@link ValueContext}
031     */
032    protected ValueContext()
033    {
034        // Empty constructor
035    }
036    
037    /**
038     * Creates a new instance of a {@link ValueContext}
039     * @return the created instance
040     */
041    public static ValueContext newInstance()
042    {
043        return new ValueContext();
044    }
045    
046    /**
047     * Retrieves the status of the data to set
048     * @return the data status
049     */
050    public Optional<ExternalizableDataStatus> getStatus()
051    {
052        return _status;
053    }
054    
055    /**
056     * Set the status of the data to set
057     * @param status the data status to set
058     * @return the current {@link ValueContext}
059     */
060    public ValueContext withStatus(ExternalizableDataStatus status)
061    {
062        _status = Optional.ofNullable(status);
063        return this;
064    }
065}