This project has retired. For details please refer to its Attic page.
Source code
001package org.apache.archiva.repository.features;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 *  http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022
023/**
024 *
025 * The repository feature holds information about specific features. The may not be available by all repository implementations.
026 * Features should be simple objects for storing additional data, the should not implement too much functionality.
027 * Additional functionality the uses the information in the feature objects should be implemented in the specific repository
028 * provider and repository implementations, or in the repository registry if it is generic.
029 *
030 * But features may throw events, if it's data is changed.
031 *
032 *
033 * This interface is to get access to a concrete feature by accessing the generic interface.
034 *
035 * @param <T> the concrete feature implementation.
036 *
037 * @author Martin Stockhammer <martin_s@apache.org>
038 * @since 3.0
039 */
040public interface RepositoryFeature<T extends RepositoryFeature<T>> {
041
042    /**
043     * Unique Identifier of this feature. Each feature implementation has its own unique identifier.
044     *
045     * @return the identifier string which should be unique for the implementation class.
046     */
047    default String getId() {
048        return this.getClass().getName();
049    }
050
051    /**
052     * Tells, if this instance is a feature of the given identifier.
053     *
054     * @param featureId the feature identifier string to check
055     * @return true, if this instance is a instance with the feature id, otherwise <code>false</code>
056     */
057    default boolean isFeature(String featureId) {
058        return this.getClass().getName().equals(featureId);
059    }
060
061    /**
062     * Tells, if the this instance is a feature of the given feature class.
063     *
064     * @param clazz The class to check against.
065     * @param <K> the concrete feature implementation.
066     * @return
067     */
068    default <K extends RepositoryFeature<K>> boolean isFeature(Class<K> clazz) {
069        return this.getClass().equals(clazz);
070    }
071
072    /**
073     * Returns the concrete feature instance.
074     * @return the feature instance.
075     */
076    T get();
077}