001    /*
002     *  Licensed to the Apache Software Foundation (ASF) under one
003     *  or more contributor license agreements.  See the NOTICE file
004     *  distributed with this work for additional information
005     *  regarding copyright ownership.  The ASF licenses this file
006     *  to you under the Apache License, Version 2.0 (the
007     *  "License"); you may not use this file except in compliance
008     *  with the License.  You may obtain a copy of the License at
009     *
010     *        http://www.apache.org/licenses/LICENSE-2.0
011     *
012     *  Unless required by applicable law or agreed to in writing,
013     *  software distributed under the License is distributed on an
014     *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015     *  KIND, either express or implied.  See the License for the
016     *  specific language governing permissions and limitations
017     *  under the License.
018     */
019    
020    package org.apache.isis.core.progmodel.facets.object.validate;
021    
022    import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
023    import org.apache.isis.core.metamodel.facetapi.Facet;
024    import org.apache.isis.core.metamodel.facets.object.callbacks.PersistingCallbackFacet;
025    import org.apache.isis.core.metamodel.facets.object.callbacks.UpdatingCallbackFacet;
026    import org.apache.isis.core.metamodel.interactions.ValidatingInteractionAdvisor;
027    
028    /**
029     * Mechanism for determining whether this object is in a valid state, for example so that it can be persisted or
030     * updated.
031     * 
032     * <p>
033     * Even though all the properties of an object may themselves be valid, there could be inter-property dependencies which
034     * are invalid. For example <tt>fromDate</tt> > <tt>toDate</tt> would probably represent an invalid state.
035     * 
036     * <p>
037     * In the standard Apache Isis Programming Model, typically corresponds to the <tt>validate</tt> method.
038     * 
039     * @see PersistingCallbackFacet
040     * @see UpdatingCallbackFacet
041     */
042    public interface ValidateObjectFacet extends Facet, ValidatingInteractionAdvisor {
043    
044        /**
045         * The reason the object is invalid.
046         * 
047         * <p>
048         * . If the object is actually valid, should return <tt>null</tt>.
049         */
050        public String invalidReason(ObjectAdapter adapter);
051    
052    }