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
019import org.apache.wicket.Component;
020import org.apache.wicket.util.io.IClusterable;
021
022/**
023 * Implementations of this interface compare model object. The component is given so that a
024 * developer can choose what the previous object is The default implementation for form components
025 * is just component.getModelObject(); But developers can choose to keep the last rendered value for
026 * that component and compare this value with the newObject. So that it doesn't overwrite values for
027 * an object that was changed by another session if the current session didn't touch that specific
028 * value.
029 * 
030 * @author jcompagner
031 * @author Jonathan Locke
032 * 
033 */
034@FunctionalInterface
035public interface IModelComparator extends IClusterable
036{
037        /**
038         * A model comparator that always returns false
039         */
040        IModelComparator ALWAYS_FALSE = (IModelComparator) (component, newObject) -> false;
041
042        /**
043         * @param component
044         *            The component which received the new object
045         * @param newObject
046         *            The newObject
047         * @return True if the previous components object is the same as the newObject.
048         */
049        boolean compare(Component component, Object newObject);
050}