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.spec;
021
022import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
023import org.apache.isis.core.metamodel.facetapi.FeatureType;
024import org.apache.isis.core.metamodel.facetapi.IdentifiedHolder;
025import org.apache.isis.core.metamodel.spec.feature.ObjectActionParameter;
026import org.apache.isis.core.metamodel.spec.feature.ObjectFeature;
027import org.apache.isis.core.metamodel.spec.feature.ObjectMember;
028import org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation;
029
030/**
031 * Base interface for elements of the metamodel.
032 * 
033 * <p>
034 * The most significant subinterfaces of this are {@link ObjectSpecification}
035 * and {@link ObjectFeature} (which brings in {@link ObjectMember} and
036 * {@link ObjectActionParameter}.
037 * 
038 * <p>
039 * Introduces so that viewers can deal with abstract Instances of said.
040 * 
041 */
042public interface Specification extends IdentifiedHolder {
043
044    FeatureType getFeatureType();
045
046    /**
047     * Returns a description of how the member is used - this complements the
048     * help text.
049     * 
050     * @see #getHelp()
051     */
052    String getDescription();
053
054    /**
055     * Return an {@link Instance} of this {@link Specification} with respect to
056     * the provided {@link ObjectAdapter}.
057     * 
058     * <p>
059     * For example, if the {@link Specification} is a
060     * {@link OneToOneAssociation}, then is an {@link Instance} implementation
061     * representing the { {@link ObjectAdapter}/ {@link OneToOneAssociation}
062     * tuple.
063     * 
064     * <p>
065     * Implementations are expected to use a double-dispatch back to the
066     * provided {@link ObjectAdapter} (passing themselves as a parameter), using
067     * {@link ObjectAdapter#getInstance(Specification)}.
068     * 
069     * <p>
070     * Note: this method may throw an {@link UnsupportedOperationException}; see
071     * {@link ObjectAdapter#getInstance(Specification)} for details.
072     */
073    Instance getInstance(final ObjectAdapter adapter);
074
075}