io.github.smart.cloud.starter.mock.condition.MockCondition Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of smart-cloud-starter-mock Show documentation
Show all versions of smart-cloud-starter-mock Show documentation
mock封装(mock工具类、常用mock策略、请求接口mock拦截器)
The newest version!
/*
* Copyright © 2019 collin ([email protected])
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.smart.cloud.starter.mock.condition;
import io.github.smart.cloud.starter.configure.constants.ConfigureConstant;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.env.Environment;
import org.springframework.core.type.AnnotatedTypeMetadata;
/**
* 判断mock配置是否生效
*
* @author collin
* @date 2019-04-27
*/
public class MockCondition implements Condition {
@Override
public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
Environment environment = context.getEnvironment();
Boolean mockApi = environment.getProperty(ConfigureConstant.MOCK_API_CONDITION_PROPERTY, Boolean.class);
Boolean mockMethod = environment.getProperty(ConfigureConstant.MOCK_METHOD_CONDITION_PROPERTY, Boolean.class);
return (mockApi != null && mockApi) || (mockMethod != null && mockMethod);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy