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;
021
022import java.lang.reflect.Method;
023import java.util.List;
024
025import org.apache.isis.core.metamodel.facetapi.MethodRemover;
026import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
027import org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation;
028
029/**
030 * A {@link FacetFactory} implementation that is able to identify a property or
031 * collection.
032 * 
033 * <p>
034 * For example, a <i>getter</i> method is most commonly used to represent either
035 * a property (value or reference) or a collection, with the return type
036 * indicating which.
037 * 
038 * <p>
039 * Used by the Java5 Reflector's <tt>ProgrammingModel</tt> to determine which
040 * facet factories to ask whether a {@link Method} represents a property or a
041 * collection.
042 * 
043 */
044public interface PropertyOrCollectionIdentifyingFacetFactory extends FacetFactory {
045
046    /**
047     * Whether (this facet is able to determine that) the supplied
048     * {@link Method} possibly represents the accessor of either a
049     * {@link ValueAssociation value property}, {@link OneToOneAssociation
050     * reference property} or a {@link OneToManyAssociation collection}.
051     * 
052     * <p>
053     * For example, if a method name has a prefix of <tt>get</tt> or
054     * alternatively has a prefix of <tt>is</tt> and returns a <tt>boolean</tt>,
055     * then it would be a candidate.
056     */
057    public boolean isPropertyOrCollectionAccessorCandidate(Method method);
058
059    /**
060     * Whether (this facet is able to determine that) the supplied
061     * {@link Method} represents <i>either</i> a {@link ValueAssociation value
062     * property} or a {@link OneToOneAssociation reference property}.
063     */
064    public boolean isPropertyAccessor(Method method);
065
066    /**
067     * Whether (this facet is able to determine that) the supplied
068     * {@link Method} represents a {@link OneToManyAssociation collection}.
069     */
070    public boolean isCollectionAccessor(Method method);
071
072    /**
073     * Use the provided {@link MethodRemover} to remove all reference property
074     * accessors, and append them to the supplied methodList.
075     */
076    public void findAndRemovePropertyAccessors(MethodRemover methodRemover, List<Method> methodListToAppendTo);
077
078    /**
079     * Use the provided {@link MethodRemover} to remove all collection
080     * accessors, and append them to the supplied methodList.
081     */
082    public void findAndRemoveCollectionAccessors(MethodRemover methodRemover, List<Method> methodListToAppendTo);
083}