001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.wicket.model;
018
019/**
020 * A marker interface that represents a model that serves as a wrapper for another. Typically, these
021 * models are produced by the following methods:
022 * {@link IComponentAssignedModel#wrapOnAssignment(org.apache.wicket.Component)} and
023 * {@link IComponentInheritedModel#wrapOnInheritance(org.apache.wicket.Component)}
024 * 
025 * The wrapped model will be called detach on when the component is detached when the wrap model is
026 * created by an {@link IComponentAssignedModel}
027 * 
028 * @author jcompagner
029 * @author Igor Vaynberg (ivaynberg)
030 * @param <T>
031 *            The model object type
032 */
033public interface IWrapModel<T> extends IModel<T>
034{
035        /**
036         * Gets the wrapped model.
037         * 
038         * @return The wrapped model
039         */
040        IModel<?> getWrappedModel();
041
042        /**
043         * Calls getWrappedModel().detach();
044         *
045         * @see org.apache.wicket.model.IDetachable#detach()
046         */
047        @Override
048        default void detach()
049        {
050                getWrappedModel().detach();
051        }
052
053        @Override
054        default void setObject(T object)
055        {
056        }
057
058        @Override
059        default T getObject()
060        {
061                return null;
062        }
063
064}