001/*
002 *  Copyright 2018 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.ametysobject;
017
018import java.util.Collection;
019
020import org.ametys.plugins.repository.AmetysObject;
021import org.ametys.plugins.repository.data.holder.DataHolder;
022import org.ametys.plugins.repository.data.holder.ModifiableDataHolder;
023import org.ametys.runtime.model.exception.BadItemTypeException;
024import org.ametys.runtime.model.exception.NotUniqueTypeException;
025import org.ametys.runtime.model.exception.UndefinedItemPathException;
026import org.ametys.runtime.model.exception.UnknownTypeException;
027
028/**
029 * {@link AmetysObject} that can handle data.
030 */
031public interface DataAwareAmetysObject extends AmetysObject, DataHolder
032{
033    /**
034     * Returns the {@link DataHolder} of this {@link AmetysObject}.
035     * @return the {@link DataHolder} of this {@link AmetysObject}
036     */
037    public DataHolder getDataHolder();
038    
039    public default boolean hasValue(String dataPath) throws IllegalArgumentException
040    {
041        return getDataHolder().hasValue(dataPath);
042    }
043
044    public default Collection<String> getDataNames()
045    {
046        return getDataHolder().getDataNames();
047    }
048    
049    public default void copyTo(ModifiableDataHolder dataHolder) throws UndefinedItemPathException, BadItemTypeException, UnknownTypeException, NotUniqueTypeException
050    {
051        getDataHolder().copyTo(dataHolder);
052    }
053}