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.runtime.model; 017 018import java.util.Map; 019 020import org.apache.cocoon.ProcessingException; 021 022import org.ametys.runtime.util.ModifiableLabelable; 023 024/** 025 * Interface for view items 026 */ 027public interface ViewItem extends ModifiableLabelable 028{ 029 /** 030 * Converts the view item in a JSON map 031 * @param context the context of the definitions referenced in this view item and/or its children 032 * @return The view item as a JSON map 033 * @throws ProcessingException If an error occurs when converting the view item 034 */ 035 public Map<String, Object> toJSON(DefinitionContext context) throws ProcessingException; 036 037 /** 038 * Create an instance of {@link ViewItem} 039 * @return the created instance 040 */ 041 public ViewItem createInstance(); 042 043 /** 044 * Copy the current view item in the given one. 045 * If the view item is an accessor, its view items are copied only if they are not already present in the reference view 046 * @param item the copy 047 * @param referenceView the reference view 048 */ 049 public default void copyTo(ViewItem item, View referenceView) 050 { 051 copyTo(item); 052 } 053 054 /** 055 * Copy the current view item in the given one. 056 * If the view item is an accessor, its view items are not copied 057 * @param item the copy 058 */ 059 public void copyTo(ViewItem item); 060 061 /** 062 * Indicates whether some other object is "equal to" this one. 063 * @param obj the reference object with which to compare. 064 * @param checkDetails <code>true</code> to check the view item's details during comparison (label, description, ...) 065 * @return <code>true</code> if this object is the same as the given obj, <code>false</code> otherwise. 066 */ 067 public boolean equals(Object obj, boolean checkDetails); 068}