This project has retired. For details please refer to its Attic page.
RepositoryFeature xref
View Javadoc
1   package org.apache.archiva.repository.features;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *  http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  
23  /**
24   *
25   * The repository feature holds information about specific features. The may not be available by all repository implementations.
26   * Features should be simple objects for storing additional data, the should not implement too much functionality.
27   * Additional functionality the uses the information in the feature objects should be implemented in the specific repository
28   * provider and repository implementations, or in the repository registry if it is generic.
29   *
30   * But features may throw events, if it's data is changed.
31   *
32   *
33   * This interface is to get access to a concrete feature by accessing the generic interface.
34   *
35   * @param <T> the concrete feature implementation.
36   *
37   * @author Martin Stockhammer <martin_s@apache.org>
38   * @since 3.0
39   */
40  public interface RepositoryFeature<T extends RepositoryFeature<T>> {
41  
42      /**
43       * Unique Identifier of this feature. Each feature implementation has its own unique identifier.
44       *
45       * @return the identifier string which should be unique for the implementation class.
46       */
47      default String getId() {
48          return this.getClass().getName();
49      }
50  
51      /**
52       * Tells, if this instance is a feature of the given identifier.
53       *
54       * @param featureId the feature identifier string to check
55       * @return true, if this instance is a instance with the feature id, otherwise <code>false</code>
56       */
57      default boolean isFeature(String featureId) {
58          return this.getClass().getName().equals(featureId);
59      }
60  
61      /**
62       * Tells, if the this instance is a feature of the given feature class.
63       *
64       * @param clazz The class to check against.
65       * @param <K> the concrete feature implementation.
66       * @return
67       */
68      default <K extends RepositoryFeature<K>> boolean isFeature(Class<K> clazz) {
69          return this.getClass().equals(clazz);
70      }
71  
72      /**
73       * Returns the concrete feature instance.
74       * @return the feature instance.
75       */
76      T get();
77  }