本文整理汇总了Java中org.dbflute.util.DfReflectionUtil类的典型用法代码示例。如果您正苦于以下问题:Java DfReflectionUtil类的具体用法?Java DfReflectionUtil怎么用?Java DfReflectionUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DfReflectionUtil类属于org.dbflute.util包,在下文中一共展示了DfReflectionUtil类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: throwListJsonParameterParseFailureException
import org.dbflute.util.DfReflectionUtil; //导入依赖的package包/类
protected void throwListJsonParameterParseFailureException(Object bean, String name, String json, Type propertyType,
RuntimeException e) {
final StringBuilder sb = new StringBuilder();
sb.append("Cannot parse list json of the request parameter.");
final List<Map<String, Object>> retryList = retryJsonListAsMapForDebug(json);
final List<JsonDebugChallenge> challengeList = new ArrayList<JsonDebugChallenge>();
final StringBuilder challengeSb = new StringBuilder();
if (!retryList.isEmpty()) {
final Class<?> elementType = DfReflectionUtil.getGenericFirstClass(propertyType);
if (elementType != null) { // just in case
int index = 0;
for (Map<String, Object> retryMap : retryList) {
challengeSb.append(LF).append(" (index: ").append(index).append(")");
final List<JsonDebugChallenge> nestedList = prepareJsonParameterDebugChallengeList(retryMap, elementType, json, index);
challengeList.addAll(nestedList);
nestedList.forEach(challenge -> challengeSb.append(challenge.toChallengeDisp()));
++index;
}
}
}
final String challengeDisp = challengeSb.toString();
buildClientErrorHeader(sb, "List JsonParameter Parse Failure", bean, name, json, propertyType, challengeDisp);
throwRequestJsonParseFailureException(sb.toString(), challengeList, e);
}
开发者ID:lastaflute,项目名称:lastaflute,代码行数:25,代码来源:ActionFormMapper.java
示例2: prepareOptionalGenericTypeMap
import org.dbflute.util.DfReflectionUtil; //导入依赖的package包/类
protected Map<Integer, Class<?>> prepareOptionalGenericTypeMap(Method executeMethod) {
final Parameter[] parameters = executeMethod.getParameters();
if (parameters.length == 0) {
return Collections.emptyMap();
}
final Map<Integer, Class<?>> optionalGenericTypeMap = new LinkedHashMap<Integer, Class<?>>(4);
int index = 0;
for (Parameter parameter : parameters) {
if (isOptionalParameterType(parameter.getType())) {
final Type paramedType = parameter.getParameterizedType();
final Class<?> genericType = DfReflectionUtil.getGenericFirstClass(paramedType);
checkExecuteMethodOptionalParameter(executeMethod, paramedType, genericType);
optionalGenericTypeMap.put(index, genericType);
}
++index;
}
return Collections.unmodifiableMap(optionalGenericTypeMap);
}
开发者ID:lastaflute,项目名称:lastaflute,代码行数:19,代码来源:ExecuteArgAnalyzer.java
示例3: doCheckGenericBeanValidationMismatch
import org.dbflute.util.DfReflectionUtil; //导入依赖的package包/类
protected void doCheckGenericBeanValidationMismatch(Field field) {
// #hope cannot check now: public List<ROOM> roomList;
final Class<?> genericType = getFieldGenericType(field); // only first generic #for_now
if (genericType == null) {
return;
}
if (mayBeNestedBeanType(genericType)) { // e.g. LandBean<PiariBean>
pathDeque.push("@generic");
doCheckNestedValidationMismatch(genericType);
pathDeque.pop();
} else if (Collection.class.isAssignableFrom(genericType)) {
final Type fieldGenericType = field.getGenericType();
if (fieldGenericType != null && fieldGenericType instanceof ParameterizedType) {
final Type[] typeArguments = ((ParameterizedType) fieldGenericType).getActualTypeArguments();
if (typeArguments != null && typeArguments.length > 0) {
final Class<?> elementType = DfReflectionUtil.getGenericFirstClass(typeArguments[0]);
if (elementType != null && mayBeNestedBeanType(elementType)) {
// e.g. public LandBean<List<PiariBean>> landBean;
pathDeque.push("@generic");
doCheckNestedValidationMismatch(elementType);
pathDeque.pop();
}
}
}
}
}
开发者ID:lastaflute,项目名称:lastaflute,代码行数:27,代码来源:ExecuteMethodValidatorChecker.java
示例4: checkJsonBeanValidator
import org.dbflute.util.DfReflectionUtil; //导入依赖的package包/类
protected void checkJsonBeanValidator() {
final Class<?> returnType = executeMethod.getReturnType();
if (!JsonResponse.class.isAssignableFrom(returnType)) {
return;
}
final Type genericReturnType = executeMethod.getGenericReturnType();
if (genericReturnType == null || !(genericReturnType instanceof ParameterizedType)) { // just in case
return;
}
final Class<?> jsonBeanType = DfReflectionUtil.getGenericFirstClass(genericReturnType);
if (jsonBeanType == null) { // just in case
return;
}
if (Collection.class.isAssignableFrom(jsonBeanType)) { // e.g. JsonResponse<List<SeaBean>>
final Type[] resopnseArgTypes = DfReflectionUtil.getGenericParameterTypes(genericReturnType);
if (resopnseArgTypes.length > 0) { // just in case
final Class<?> elementBeanType = DfReflectionUtil.getGenericFirstClass(resopnseArgTypes[0]);
if (elementBeanType != null && mayBeJsonBeanType(elementBeanType)) { // just in case
doCheckJsonBeanValidator(elementBeanType, Collections.emptyMap()); // can check JsonResponse<List<SeaBean>>
}
}
} else if (mayBeJsonBeanType(jsonBeanType)) { // e.g. JsonResponse<SeaBean>, JsonResponse<WholeBean<SeaBean>>
doCheckJsonBeanValidator(jsonBeanType, prepareJsonBeanGenericMap(genericReturnType, jsonBeanType));
}
}
开发者ID:lastaflute,项目名称:lastaflute,代码行数:26,代码来源:ExecuteMethodChecker.java
示例5: prepareJsonBeanGenericMap
import org.dbflute.util.DfReflectionUtil; //导入依赖的package包/类
protected Map<String, Class<?>> prepareJsonBeanGenericMap(Type genericReturnType, Class<?> jsonBeanType) {
// can check: JsonResponse<LandBean<PiariBean>> landBean;
final Type[] resopnseArgTypes = DfReflectionUtil.getGenericParameterTypes(genericReturnType);
if (resopnseArgTypes.length > 0) { // just in case
final Type firstGenericType = resopnseArgTypes[0];
final Class<?> elementBeanType = DfReflectionUtil.getGenericFirstClass(firstGenericType);
if (elementBeanType != null && mayBeJsonBeanType(elementBeanType)) { // just in case
final Map<String, Class<?>> genericMap = new LinkedHashMap<String, Class<?>>(1); // only first generic #for_now
final TypeVariable<?>[] typeParameters = jsonBeanType.getTypeParameters();
if (typeParameters != null && typeParameters.length > 0) { // just in case
genericMap.put(typeParameters[0].getName(), elementBeanType); // e.g. DATA = PiariBean.class
return genericMap;
}
}
}
return Collections.emptyMap();
}
开发者ID:lastaflute,项目名称:lastaflute,代码行数:18,代码来源:ExecuteMethodChecker.java
示例6: prepareOptionalGenericTypeMap
import org.dbflute.util.DfReflectionUtil; //导入依赖的package包/类
protected static Map<Integer, Class<?>> prepareOptionalGenericTypeMap(Method executeMethod) {
final Parameter[] parameters = executeMethod.getParameters();
if (parameters.length == 0) {
return Collections.emptyMap();
}
final Map<Integer, Class<?>> optionalGenericTypeMap = new LinkedHashMap<Integer, Class<?>>(4);
int index = 0;
for (Parameter parameter : parameters) {
if (isOptionalParameterType(parameter.getType())) {
final Type paramedType = parameter.getParameterizedType();
final Class<?> genericType = DfReflectionUtil.getGenericFirstClass(paramedType);
optionalGenericTypeMap.put(index, genericType);
}
++index;
}
return Collections.unmodifiableMap(optionalGenericTypeMap);
}
开发者ID:lastaflute,项目名称:lastaflute,代码行数:18,代码来源:LaActionExecuteUtil.java
示例7: setupTransactionViewListByReflection
import org.dbflute.util.DfReflectionUtil; //导入依赖的package包/类
protected void setupTransactionViewListByReflection(ConnectionPool pool, List<String> txViewList) {
final Field field = DfReflectionUtil.getWholeField(pool.getClass(), "txActivePool");
@SuppressWarnings("unchecked")
final Map<Transaction, ConnectionWrapper> txActivePool =
(Map<Transaction, ConnectionWrapper>) DfReflectionUtil.getValueForcedly(field, pool);
synchronized (pool) { // just in case
for (Entry<Transaction, ConnectionWrapper> entry : txActivePool.entrySet()) {
final Transaction tx = entry.getKey();
final ConnectionWrapper wrapper = entry.getValue();
final String romantic;
if (tx instanceof RomanticTransaction) {
romantic = ((RomanticTransaction) tx).toRomanticSnapshot(wrapper);
} else {
romantic = tx.toString();
}
txViewList.add(romantic);
}
}
}
开发者ID:lastaflute,项目名称:lastaflute,代码行数:20,代码来源:ConnectionPoolViewBuilder.java
示例8: nativeFindByCode
import org.dbflute.util.DfReflectionUtil; //导入依赖的package包/类
protected static OptionalThing<Classification> nativeFindByCode(Class<?> cdefType, Object code) {
assertArgumentNotNull("cdefType", cdefType);
assertArgumentNotNull("code", code);
final BeanDesc beanDesc = BeanDescFactory.getBeanDesc(cdefType);
final String methodName = "of";
final Method method;
try {
method = beanDesc.getMethod(methodName, new Class<?>[] { Object.class });
} catch (BeanMethodNotFoundException e) {
String msg = "Failed to get the method " + methodName + "() of the classification type: " + cdefType;
throw new ClassificationFindByCodeMethodNotFoundException(msg, e);
}
@SuppressWarnings("unchecked")
final OptionalThing<Classification> opt =
(OptionalThing<Classification>) DfReflectionUtil.invokeStatic(method, new Object[] { code });
return opt;
}
开发者ID:lastaflute,项目名称:lastaflute,代码行数:18,代码来源:LaClassificationUtil.java
示例9: nativeFindMeta
import org.dbflute.util.DfReflectionUtil; //导入依赖的package包/类
protected static OptionalThing<ClassificationMeta> nativeFindMeta(Class<?> defmetaType, String classificationName) { // old method
assertArgumentNotNull("defmetaType", defmetaType);
assertArgumentNotNull("classificationName", classificationName);
final BeanDesc beanDesc = BeanDescFactory.getBeanDesc(defmetaType);
final String methodName = "find";
final Method method;
try {
method = beanDesc.getMethod(methodName, new Class<?>[] { String.class });
} catch (BeanMethodNotFoundException e) {
String msg = "Failed to get the method " + methodName + "() of the def-meta type: " + defmetaType;
throw new ClassificationMetaFindMethodNotFoundException(msg, e);
}
@SuppressWarnings("unchecked")
OptionalThing<ClassificationMeta> opt =
(OptionalThing<ClassificationMeta>) DfReflectionUtil.invokeStatic(method, new Object[] { classificationName });
return opt;
}
开发者ID:lastaflute,项目名称:lastaflute,代码行数:18,代码来源:LaClassificationUtil.java
示例10: matches
import org.dbflute.util.DfReflectionUtil; //导入依赖的package包/类
/**
* Creates a new {@code T} instance by reflection and pass it to subsequent matcher.
*/
@SuppressWarnings("unchecked")
@Override
public boolean matches(Object item) {
if (item == null) {
return false;
}
T cb = (T) DfReflectionUtil.newInstance(clazz);
CBCall<T> callback = (CBCall<T>) item;
callback.callback(cb);
// store cb for mismatch
this.cb = cb;
return matcher.matches(cb);
}
开发者ID:taktos,项目名称:dbflute-hamcrest,代码行数:18,代码来源:BehaviorArgumentMatcher.java
示例11: getAllCB
import org.dbflute.util.DfReflectionUtil; //导入依赖的package包/类
/**
* Returns new {@code CB} instances that were applied lambda callback.
*
* @return new {@code CB} instances.
* @see ArgumentCaptor#getAllValues()
*/
public List<CB> getAllCB() {
List<CBCall> values = captor.getAllValues();
List<CB> cbs = new ArrayList<CB>(values.size());
for (CBCall callback : values) {
CB cb = (CB) DfReflectionUtil.newInstance(clazz);
callback.callback(cb);
cbs.add(cb);
}
return cbs;
}
开发者ID:taktos,项目名称:dbflute-hamcrest,代码行数:17,代码来源:BehaviorArgumentCaptor.java
示例12: resolveRelationName
import org.dbflute.util.DfReflectionUtil; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private String resolveRelationName(SqlClause sqlClause, String table) {
Method method = DfReflectionUtil.getAccessibleMethod(sqlClause.getClass(), "getSelectedRelationBasicMap", null);
Map<String, String> baseMap = (Map<String, String>) DfReflectionUtil.invokeForcedly(method, sqlClause, null);
for (Map.Entry<String, String> entry : baseMap.entrySet()) {
if (entry.getValue().equals(table)) {
return entry.getKey();
}
}
return null;
}
开发者ID:taktos,项目名称:dbflute-hamcrest,代码行数:12,代码来源:ShouldSelect.java
示例13: findListFormGenericType
import org.dbflute.util.DfReflectionUtil; //导入依赖的package包/类
protected Class<?> findListFormGenericType(Parameter parameter) {
if (List.class.equals(parameter.getType())) { // just List
final Type pt = parameter.getParameterizedType();
final Class<?> genericType = DfReflectionUtil.getGenericFirstClass(pt); // almost not null, already checked
return genericType != null && isBeanActionFormType(genericType) ? genericType : null; // e.g. List<SeaForm>
}
return null;
}
开发者ID:lastaflute,项目名称:lastaflute,代码行数:9,代码来源:ExecuteArgAnalyzer.java
示例14: digUpDbmsNativeProcessIdOf
import org.dbflute.util.DfReflectionUtil; //导入依赖的package包/类
protected Object digUpDbmsNativeProcessIdOf(Connection physicalConn) {
final Class<?> connType = physicalConn.getClass();
if (getMySQLConnectionClassFQCN().equals(connType.getName())) {
final Method method = DfReflectionUtil.getPublicMethod(connType, "getId", (Class<?>[]) null);
return DfReflectionUtil.invoke(method, physicalConn, (Object[]) null);
}
return null;
}
开发者ID:lastaflute,项目名称:lastaflute,代码行数:9,代码来源:TransactionRomanticSnapshotBuilder.java
示例15: switchFactories
import org.dbflute.util.DfReflectionUtil; //导入依赖的package包/类
protected void switchFactories(Gson newGson) {
final Field factoriesField = DfReflectionUtil.getWholeField(newGson.getClass(), "factories");
@SuppressWarnings("unchecked")
final List<Object> factories = (List<Object>) DfReflectionUtil.getValueForcedly(factoriesField, newGson);
final List<Object> filtered = new ArrayList<Object>();
for (Object factory : factories) {
if (factory instanceof ReflectiveTypeAdapterFactory) { // switched, only one time
filtered.add(createReflectiveTypeAdapterFactory(newGson, factory));
} else {
filtered.add(factory);
}
}
DfReflectionUtil.setValueForcedly(factoriesField, newGson, Collections.unmodifiableList(filtered));
}
开发者ID:lastaflute,项目名称:lastaflute,代码行数:15,代码来源:GsonJsonEngine.java
示例16: newEmptyInstance
import org.dbflute.util.DfReflectionUtil; //导入依赖的package包/类
@SuppressWarnings("unchecked")
protected <BEAN> BEAN newEmptyInstance(ParameterizedType parameterizedType) {
final Class<?> rawClass = DfReflectionUtil.getRawClass(parameterizedType);
if (rawClass == null) {
throw new IllegalStateException("Cannot get raw type from the parameterized type: " + parameterizedType);
}
return (BEAN) newEmptyInstance(rawClass);
}
开发者ID:lastaflute,项目名称:lastaflute,代码行数:9,代码来源:GsonJsonEngine.java
示例17: createDefaultSqlStringFilter
import org.dbflute.util.DfReflectionUtil; //导入依赖的package包/类
protected SqlStringFilter createDefaultSqlStringFilter(ConcurrentAsyncCall call) {
final Method entryMethod = ThreadCacheContext.findEntryMethod();
if (entryMethod != null) {
return newDefaultSqlStringFilter(call, entryMethod, "(via " + DfTypeUtil.toClassTitle(call) + ")");
}
try {
final Method callbackMethod = DfReflectionUtil.getPublicMethod(call.getClass(), "callback", null);
if (callbackMethod != null) {
return newDefaultSqlStringFilter(call, callbackMethod, null);
}
} catch (RuntimeException ignored) {}
return null;
}
开发者ID:lastaflute,项目名称:lastaflute,代码行数:14,代码来源:SimpleAsyncManager.java
示例18: injectSimply
import org.dbflute.util.DfReflectionUtil; //导入依赖的package包/类
/**
* @param target The target instance to which injecting. (NotNull)
*/
public static void injectSimply(Object target) {
if (target == null) {
throw new IllegalArgumentException("The argument 'target' should not be null.");
}
// no cache fields #for_now so don't use it at frequently-called object
for (Class<?> currentType = target.getClass(); !currentType.equals(Object.class); currentType = currentType.getSuperclass()) {
final Field[] fields = currentType.getDeclaredFields();
for (Field field : fields) {
if (field.getAnnotation(Resource.class) != null) { // type only #for_now
DfReflectionUtil.setValueForcedly(field, target, getComponent(field.getType()));
}
}
}
}
开发者ID:lastaflute,项目名称:lastaflute,代码行数:18,代码来源:ContainerUtil.java
示例19: nativeCodeOf
import org.dbflute.util.DfReflectionUtil; //导入依赖的package包/类
public static Object nativeCodeOf(Class<?> cdefType, Object code) { // old method
assertArgumentNotNull("cdefType", cdefType);
assertArgumentNotNull("code", code);
final BeanDesc beanDesc = BeanDescFactory.getBeanDesc(cdefType);
final String methodName = "codeOf";
final Method method;
try {
method = beanDesc.getMethod(methodName, new Class<?>[] { Object.class });
} catch (BeanMethodNotFoundException e) {
String msg = "Failed to get the method " + methodName + "() of the classification type: " + cdefType;
throw new ClassificationCodeOfMethodNotFoundException(msg, e);
}
return DfReflectionUtil.invokeStatic(method, new Object[] { code });
}
开发者ID:lastaflute,项目名称:lastaflute,代码行数:15,代码来源:LaClassificationUtil.java
示例20: nativeMetaOf
import org.dbflute.util.DfReflectionUtil; //导入依赖的package包/类
public static Object nativeMetaOf(Class<?> defmetaType, String classificationName) { // old method
assertArgumentNotNull("defmetaType", defmetaType);
assertArgumentNotNull("classificationName", classificationName);
final BeanDesc beanDesc = BeanDescFactory.getBeanDesc(defmetaType);
final String methodName = "meta";
final Method method;
try {
method = beanDesc.getMethod(methodName, new Class<?>[] { String.class });
} catch (BeanMethodNotFoundException e) {
String msg = "Failed to get the method " + methodName + "() of the def-meta type: " + defmetaType;
throw new ClassificationMetaOfMethodNotFoundException(msg, e);
}
return DfReflectionUtil.invokeStatic(method, new Object[] { classificationName });
}
开发者ID:lastaflute,项目名称:lastaflute,代码行数:15,代码来源:LaClassificationUtil.java
注:本文中的org.dbflute.util.DfReflectionUtil类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论