001/*
002 *  Copyright 2019 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 org.ametys.plugins.repository.AmetysObject;
019import org.ametys.plugins.repository.data.holder.ModifiableModelAwareDataHolder;
020import org.ametys.plugins.repository.data.holder.group.impl.ModifiableModelAwareComposite;
021import org.ametys.plugins.repository.data.holder.group.impl.ModifiableModelAwareRepeater;
022import org.ametys.runtime.model.exception.BadDataPathCardinalityException;
023import org.ametys.runtime.model.exception.BadItemTypeException;
024import org.ametys.runtime.model.exception.UndefinedItemPathException;
025
026/**
027 * Model aware {@link AmetysObject} that can handle modifiable data.
028 */
029public interface ModifiableModelAwareDataAwareAmetysObject extends ModelAwareDataAwareAmetysObject, ModifiableModelAwareDataHolder
030{
031    @Override
032    public ModifiableModelAwareDataHolder getDataHolder();
033
034    @Override
035    public default ModifiableModelAwareComposite getComposite(String compositePath) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException
036    {
037        return getDataHolder().getComposite(compositePath);
038    }
039
040    @Override
041    public default ModifiableModelAwareRepeater getRepeater(String repeaterPath) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException
042    {
043        return getDataHolder().getRepeater(repeaterPath);
044    }
045
046    public default ModifiableModelAwareComposite getComposite(String compositePath, boolean createNew) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException
047    {
048        return getDataHolder().getComposite(compositePath, createNew);
049    }
050
051    public default ModifiableModelAwareRepeater getRepeater(String repeaterPath, boolean createNew) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException
052    {
053        return getDataHolder().getRepeater(repeaterPath, createNew);
054    }
055
056    public default void removeValue(String dataPath) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException
057    {
058        getDataHolder().removeValue(dataPath);
059    }
060
061    public default void setValue(String dataPath, Object value) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException
062    {
063        getDataHolder().setValue(dataPath, value);
064    }
065
066}