Line data Source code
1 : // Copyright (C) 2012 The Android Open Source Project 2 : // 3 : // Licensed under the Apache License, Version 2.0 (the "License"); 4 : // you may not use this file except in compliance with the License. 5 : // You may obtain a copy of the License at 6 : // 7 : // http://www.apache.org/licenses/LICENSE-2.0 8 : // 9 : // Unless required by applicable law or agreed to in writing, software 10 : // distributed under the License is distributed on an "AS IS" BASIS, 11 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 : // See the License for the specific language governing permissions and 13 : // limitations under the License. 14 : 15 : package com.google.gerrit.server.plugins; 16 : 17 : import com.google.gerrit.extensions.annotations.Export; 18 : import com.google.inject.internal.UniqueAnnotations; 19 : import java.lang.annotation.Annotation; 20 : 21 : public final class AutoRegisterUtil { 22 : 23 : public static Annotation calculateBindAnnotation(Class<Object> impl) { 24 0 : Annotation n = impl.getAnnotation(Export.class); 25 0 : if (n == null) { 26 0 : n = impl.getAnnotation(javax.inject.Named.class); 27 : } 28 0 : if (n == null) { 29 0 : n = impl.getAnnotation(com.google.inject.name.Named.class); 30 : } 31 0 : if (n == null) { 32 0 : n = UniqueAnnotations.create(); 33 : } 34 0 : return n; 35 : } 36 : 37 : private AutoRegisterUtil() { 38 : // hide default constructor 39 : } 40 : }