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.facets.object.title;
021
022import org.apache.isis.applib.profiles.Localization;
023import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
024import org.apache.isis.core.metamodel.facetapi.Facet;
025import org.apache.isis.core.metamodel.facets.object.icon.IconFacet;
026import org.apache.isis.core.metamodel.facets.object.plural.PluralFacet;
027
028/**
029 * Mechanism for obtaining the title of an instance of a class, used to label
030 * the instance in the viewer (usually alongside an icon representation).
031 * 
032 * <p>
033 * In the standard Apache Isis Programming Model, typically corresponds to a
034 * method named <tt>title</tt>.
035 * 
036 * @see IconFacet
037 * @see PluralFacet
038 */
039public interface TitleFacet extends Facet {
040
041    /**
042     * Provide a title for the target object, with respect to the specified {@link Localization}.
043     */
044    String title(final ObjectAdapter targetAdapter, Localization localization);
045
046    /**
047     * Provide a title for the target object, in the context of the context object, with respect to the specified {@link Localization}.
048     * 
049     * <p>
050     * For example, if the title is of an object within a parented collection, then the
051     * context object would be the parent.  Thus, the title might be shortened so that it does not
052     * needlessly incorporate the title of the parent (context) object.
053     */
054    String title(final ObjectAdapter contextAdapter, final ObjectAdapter targetAdapter, Localization localization);
055
056}