001/*
002 * (C) Copyright 2006-2012 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Bogdan Stefanescu
018 *     Florent Guillaume
019 */
020package org.nuxeo.ecm.core.schema;
021
022import org.nuxeo.ecm.core.schema.types.CompositeType;
023
024import java.util.Set;
025
026/**
027 * Document types are composite types made of several schemas.
028 * <p>
029 * Sample document types are Workspace, Section, Domain,... The list of builtin document type is visible at
030 * NXCore/OSGI-INF/CoreExtensions.xml.
031 */
032public interface DocumentType extends CompositeType {
033
034    /**
035     * Gets the prefetch info, or null if no prefetch is defined.
036     * <p>
037     * If the prefetch info is not null, the caller should use it when instantiating a document to preload the fields
038     * defined by the prefetch info.
039     * <p>
040     * If no prefetch is specified by the document type, the caller is free to use a default prefetch info or no
041     * prefetch at all.
042     *
043     * @return the prefetch info or null
044     */
045    PrefetchInfo getPrefetchInfo();
046
047    /**
048     * Tests whether this type describes a document (not a folder!) or not.
049     *
050     * @return true if the type describes a document folder, otherwise returns false
051     */
052    boolean isFile();
053
054    /**
055     * Tests whether this type describes a folder or not.
056     *
057     * @return true if the type describes a folder, otherwise returns false
058     */
059    boolean isFolder();
060
061    /**
062     * Tests whether this type describe an ordered folder or not.
063     *
064     * @return true if the type describes an ordered folder, otherwise returns false
065     */
066    boolean isOrdered();
067
068    /**
069     * Gets all the facets of this document type.
070     * <p>
071     * Facets inherited from parents are taken into account.
072     *
073     * @return the facets
074     */
075    Set<String> getFacets();
076
077    /**
078     * Returns {@code true} if this document type has the given {@code facetName} facet, {@code false otherwise}.
079     *
080     * @since 5.7
081     */
082    boolean hasFacet(String facetName);
083
084}