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
020package org.apache.isis.core.metamodel.facetapi;
021
022import org.apache.isis.core.metamodel.facets.actions.invoke.ActionInvocationFacet;
023
024public interface Facet {
025
026    /**
027     * The {@link FacetHolder holder} of this facet.
028     * 
029     * @return
030     */
031    FacetHolder getFacetHolder();
032
033    /**
034     * Allows reparenting of Facet.
035     * 
036     * <p>
037     * Used by Facet decorators.
038     * 
039     * @param facetHolder
040     */
041    public void setFacetHolder(FacetHolder facetHolder);
042
043    /**
044     * Underlying {@link Facet} of the same {@link #facetType() type}, if any.
045     */
046    public Facet getUnderlyingFacet();
047
048    /**
049     * Sets underlying {@link Facet}, that is, creating a chain.
050     * 
051     * <p>
052     * Must be of the same {@link #facetType() type}.
053     */
054    public void setUnderlyingFacet(Facet underlyingFacet);
055
056    /**
057     * Determines the type of this facet to be stored under.
058     * 
059     * <p>
060     * The framework looks for {@link Facet}s of certain well-known facet types.
061     * Each facet implementation must specify which type of facet it corresponds
062     * to. This therefore allows the (rules of the) programming model to be
063     * varied without impacting the rest of the framework.
064     * 
065     * <p>
066     * For example, the <tt>ActionInvocationFacet</tt> specifies the facet to
067     * invoke an action. The typical implementation of this wraps a
068     * <tt>public</tt> method. However, a different facet factory could be
069     * installed that creates facet also of type {@link ActionInvocationFacet}
070     * but that have some other rule, such as requiring an <i>action</i> prefix,
071     * or that decorate the interaction by logging it, for example.
072     */
073    Class<? extends Facet> facetType();
074
075    /**
076     * Whether this facet implementation is derived (as opposed to explicit);
077     * used to determine precedence.
078     * 
079     * <p>
080     * For example, we might derive the typical length of a property based on
081     * its type; but if the typical length has been explicitly specified using
082     * an annotation then that should take precedence.
083     */
084    public boolean isDerived();
085
086    /**
087     * Whether this facet implementation is a no-op.
088     */
089    public boolean isNoop();
090
091    /**
092     * Whether this facet implementation should replace existing (none-noop)
093     * implementations.
094     */
095    public boolean alwaysReplace();
096
097}