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.model; 017 018import org.ametys.runtime.model.DefinitionAndValue; 019import org.ametys.runtime.model.ModelItem; 020 021/** 022 * Pair of a value and its definition for a repeater entry 023 * @param <T> Type of the root object 024 */ 025public class RepeaterEntryDefinitionAndValue<T> extends CompositeDefinitionAndValue<T> 026{ 027 private RepeaterDefinition _repeaterDefinition; 028 029 /** 030 * Creates a repeater entry definition and value pair 031 * @param root the root object of this definition and value pair 032 * @param definition the definition 033 * @param value the value 034 * @param children the children of the definition and value pair 035 */ 036 public RepeaterEntryDefinitionAndValue(T root, ModelItem definition, Object value, DefinitionAndValue... children) 037 { 038 this(root, definition, value, null, children); 039 } 040 041 /** 042 * Creates a repeater entry definition and value pair 043 * @param root the root object of this definition and value pair 044 * @param definition the definition 045 * @param value the value 046 * @param parent the parent of the definition and value pair 047 * @param children the children of the definition and value pair 048 */ 049 public RepeaterEntryDefinitionAndValue(T root, ModelItem definition, Object value, DefinitionAndValue<T> parent, DefinitionAndValue... children) 050 { 051 super(root, definition, value, parent, children); 052 053 if (definition instanceof RepeaterDefinition) 054 { 055 _repeaterDefinition = (RepeaterDefinition) definition; 056 } 057 else 058 { 059 throw new IllegalArgumentException("The definition of a repeater entry definition and value pair must be a " + RepeaterDefinition.class.getName() + "."); 060 } 061 } 062 063 @Override 064 public RepeaterDefinition getDefinition() 065 { 066 return _repeaterDefinition; 067 } 068}