net.hasor.dataql.UdfSourceAssembly Maven / Gradle / Ivy
/*
* Copyright 2008-2009 the original author or authors.
*
* 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 net.hasor.dataql;
import net.hasor.core.provider.InstanceProvider;
import net.hasor.core.provider.SingleProvider;
import net.hasor.dataql.domain.DataModel;
import net.hasor.utils.BeanUtils;
import net.hasor.utils.ExceptionUtils;
import net.hasor.utils.StringUtils;
import net.hasor.utils.convert.ConverterUtils;
import java.lang.annotation.*;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Predicate;
import java.util.function.Supplier;
/**
* UDF UdfSource 的装配接口
* @author 赵永春 ([email protected])
* @version : 2019-12-11
*/
public interface UdfSourceAssembly extends UdfSource {
public default Supplier> getSupplier(Class> targetType, Finder finder) {
return () -> this;// the Supplier return self.
}
public default Predicate getPredicate(Class> targetType) {
return method -> {
// ignore all method form Object\UdfSource\UdfSourceAssembly
boolean testA = method.getDeclaringClass() != Object.class;
boolean testB = method.getDeclaringClass() != UdfSource.class;
boolean testC = method.getDeclaringClass() != UdfSourceAssembly.class;
return testA && testB && testC;
};
}
/** 获取所有参数 */
@FunctionalInterface
public interface UdfParams {
public Object[] allParams();
}
/** 函数名 */
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.TYPE, ElementType.METHOD })
public @interface UdfName {
public String value();
}
@Override
public default Supplier
© 2015 - 2024 Weber Informatics LLC | Privacy Policy