001/**
002 * Copyright 2015 DuraSpace, Inc.
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 */
016package org.fcrepo.kernel.services;
017
018import javax.jcr.Node;
019import javax.jcr.Session;
020
021/**
022 * @author bbpennel
023 * @author barmintor
024 * @since Feb 21, 2014
025 */
026public interface Service<T> {
027    /**
028     * Test whether T exists at the given path in the
029     * repository
030     *
031     * @param path the path
032     * @param session the session
033     * @return whether T exists at the given path
034     */
035    public boolean exists(final Session session, final String path);
036    /**
037     * Retrieve an existing T instance by session and path
038     *
039     * @param path jcr path to the node
040     * @param session the session
041     * @return retrieved T
042     */
043    public T find(final Session session, final String path);
044    /**
045     * Retrieve a T instance by session and path
046     *
047     * @param session the session
048     * @param path jcr path to the node
049     * @return retrieved T
050     */
051    public T findOrCreate(final Session session, final String path);
052    /**
053     * Retrieve a T instance from a node
054     *
055     * @param node the node
056     * @return node as T
057     */
058    public T cast(Node node);
059}