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.holder.group; 017 018import java.util.Collection; 019import java.util.Map; 020import java.util.Optional; 021 022import org.xml.sax.ContentHandler; 023import org.xml.sax.SAXException; 024 025import org.ametys.plugins.repository.data.UnknownDataException; 026import org.ametys.plugins.repository.data.holder.ModelLessDataHolder; 027import org.ametys.plugins.repository.data.holder.ModifiableDataHolder; 028import org.ametys.plugins.repository.data.type.RepositoryModelItemType; 029import org.ametys.runtime.model.exception.BadDataPathCardinalityException; 030import org.ametys.runtime.model.exception.BadItemTypeException; 031import org.ametys.runtime.model.exception.NotUniqueTypeException; 032import org.ametys.runtime.model.exception.UndefinedItemPathException; 033import org.ametys.runtime.model.exception.UnknownTypeException; 034import org.ametys.runtime.model.type.DataContext; 035 036/** 037 * Interface for model less composites 038 */ 039public interface ModelLessComposite extends ModelLessDataHolder, Composite 040{ 041 @Override 042 public default ModelLessComposite getComposite(String compositePath) throws IllegalArgumentException, BadItemTypeException, BadDataPathCardinalityException 043 { 044 return getDefaultDataHolder().getComposite(compositePath); 045 } 046 047 @Override 048 public default <T> T getValue(String dataPath) throws IllegalArgumentException, UnknownTypeException, NotUniqueTypeException, BadDataPathCardinalityException 049 { 050 return getDefaultDataHolder().getValue(dataPath); 051 } 052 053 @Override 054 public default <T> T getValue(String dataPath, T defaultValue) throws IllegalArgumentException, UnknownTypeException, NotUniqueTypeException, BadDataPathCardinalityException 055 { 056 return getDefaultDataHolder().getValue(dataPath, defaultValue); 057 } 058 059 @Override 060 public default <T> T getValueOfType(String dataPath, String dataTypeId) throws IllegalArgumentException, UnknownTypeException, BadItemTypeException, BadDataPathCardinalityException 061 { 062 return getDefaultDataHolder().getValueOfType(dataPath, dataTypeId); 063 } 064 065 @Override 066 public default <T> T getValueOfType(String dataPath, String dataTypeId, T defaultValue) throws IllegalArgumentException, UnknownTypeException, BadItemTypeException, BadDataPathCardinalityException 067 { 068 return getDefaultDataHolder().getValueOfType(dataPath, dataTypeId, defaultValue); 069 } 070 071 @Override 072 public default boolean hasValue(String dataPath) throws IllegalArgumentException 073 { 074 return getDefaultDataHolder().hasValue(dataPath); 075 } 076 077 @Override 078 public default boolean hasValueOrEmpty(String dataPath) throws IllegalArgumentException 079 { 080 return getDefaultDataHolder().hasValueOrEmpty(dataPath); 081 } 082 083 @Override 084 public default boolean isMultiple(String dataPath) throws IllegalArgumentException, UnknownDataException, BadDataPathCardinalityException 085 { 086 return getDefaultDataHolder().isMultiple(dataPath); 087 } 088 089 @Override 090 public default RepositoryModelItemType getType(String dataPath) throws IllegalArgumentException, UnknownDataException, UnknownTypeException, NotUniqueTypeException, BadDataPathCardinalityException 091 { 092 return getDefaultDataHolder().getType(dataPath); 093 } 094 095 @Override 096 public default Collection<String> getDataNames() 097 { 098 return getDefaultDataHolder().getDataNames(); 099 } 100 101 @Override 102 public default void copyTo(ModifiableDataHolder dataHolder) throws UndefinedItemPathException, BadItemTypeException, UnknownTypeException, NotUniqueTypeException 103 { 104 getDefaultDataHolder().copyTo(dataHolder); 105 } 106 107 @Override 108 public default void dataToSAX(ContentHandler contentHandler, DataContext context) throws SAXException, UnknownTypeException, NotUniqueTypeException 109 { 110 getDefaultDataHolder().dataToSAX(contentHandler, context); 111 } 112 113 public default Map<String, Object> dataToJSON(DataContext context) throws UnknownTypeException, NotUniqueTypeException 114 { 115 return getDefaultDataHolder().dataToJSON(context); 116 } 117 118 @Override 119 public default Optional<? extends ModelLessDataHolder> getParentDataHolder() 120 { 121 return getDefaultDataHolder().getParentDataHolder(); 122 } 123 124 @Override 125 public default ModelLessDataHolder getRootDataHolder() 126 { 127 return getDefaultDataHolder().getRootDataHolder(); 128 } 129 130 @Override 131 public ModelLessDataHolder getDefaultDataHolder(); 132}