001/* 002 * Copyright 2012-2017 the original author or authors. 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 017package org.springframework.boot.autoconfigure.condition; 018 019import java.lang.annotation.Documented; 020import java.lang.annotation.ElementType; 021import java.lang.annotation.Retention; 022import java.lang.annotation.RetentionPolicy; 023import java.lang.annotation.Target; 024 025import org.springframework.context.annotation.Conditional; 026 027/** 028 * {@link Conditional} that only matches when the specified classes are on the classpath. 029 * 030 * @author Phillip Webb 031 */ 032@Target({ ElementType.TYPE, ElementType.METHOD }) 033@Retention(RetentionPolicy.RUNTIME) 034@Documented 035@Conditional(OnClassCondition.class) 036public @interface ConditionalOnClass { 037 038 /** 039 * The classes that must be present. Since this annotation is parsed by loading class 040 * bytecode, it is safe to specify classes here that may ultimately not be on the 041 * classpath, only if this annotation is directly on the affected component and 042 * <b>not</b> if this annotation is used as a composed, meta-annotation. In order to 043 * use this annotation as a meta-annotation, only use the {@link #name} attribute. 044 * @return the classes that must be present 045 */ 046 Class<?>[] value() default {}; 047 048 /** 049 * The classes names that must be present. 050 * @return the class names that must be present. 051 */ 052 String[] name() default {}; 053 054}