当前位置: 首页>>代码示例>>Java>>正文


Java BeanUtils.getPropertyDescriptor方法代码示例

本文整理汇总了Java中org.springframework.beans.BeanUtils.getPropertyDescriptor方法的典型用法代码示例。如果您正苦于以下问题:Java BeanUtils.getPropertyDescriptor方法的具体用法?Java BeanUtils.getPropertyDescriptor怎么用?Java BeanUtils.getPropertyDescriptor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.beans.BeanUtils的用法示例。


在下文中一共展示了BeanUtils.getPropertyDescriptor方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: predicateOfField

import org.springframework.beans.BeanUtils; //导入方法依赖的package包/类
private Predicate<HealthCheck> predicateOfField(String field, String term) {
    PropertyDescriptor propertyDescriptor = BeanUtils.getPropertyDescriptor(HealthCheck.class, field);
    if (propertyDescriptor == null) {
        // The field is not found, so we just do as if everything matches
        // TODO - Maybe we could log that :)
        return hc -> true;
    } else if (String.class.isAssignableFrom(propertyDescriptor.getPropertyType())) {
        if (term.contains("*")) {
            // We have a regex here
            return hc -> invoke(hc, propertyDescriptor.getReadMethod(), String.class).matches(term.replace("*", ".*"));
        } else {
            return hc -> invoke(hc, propertyDescriptor.getReadMethod(), String.class).contains(term);
        }
    } else {
        if (term.contains("*")) {
            return hc -> invoke(hc, propertyDescriptor.getReadMethod(), Object.class).toString().matches(".*" + term.replace("*", ".*") + ".*");
        } else {
            return hc -> invoke(hc, propertyDescriptor.getReadMethod(), Object.class).toString().contains(term);
        }

    }
}
 
开发者ID:gilles-stragier,项目名称:quickmon,代码行数:23,代码来源:HealthChecksQueryNodeInterpreter.java

示例2: treeSorted

import org.springframework.beans.BeanUtils; //导入方法依赖的package包/类
public QueryResult<T> treeSorted(String keyField, String parentKeyField, Object rootValue) {
	try {
		List<T> list = getData();
		if (list.size() <= 0) {
			return this;
		}
		Class<?> itemClass = list.get(0).getClass();
		PropertyDescriptor keyProp = BeanUtils.getPropertyDescriptor(itemClass, keyField);
		PropertyDescriptor parentKeyProp = BeanUtils.getPropertyDescriptor(itemClass, parentKeyField);
		List<T> newList = new ArrayList<>(list.size());
		addTreeNode(newList, list, rootValue, keyProp, parentKeyProp);
		setData(newList);
	} catch (Exception e) {
		throw new RuntimeException(e);
	}
	return this;
}
 
开发者ID:szsucok,项目名称:sucok-framework,代码行数:18,代码来源:QueryResult.java

示例3: getValue

import org.springframework.beans.BeanUtils; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
private static Object getValue(String propertyName, Object obj) {
	if (obj instanceof Map) {
          return ((Map) obj).get(propertyName);
       } else if (obj instanceof Tuple) {
           return ((Tuple) obj).get(propertyName);
       } else if (obj != null) {
           PropertyDescriptor pd = BeanUtils.getPropertyDescriptor(obj.getClass(), propertyName);
           try {
              return pd.getReadMethod().invoke(obj, new Object[]{});
           } catch (Exception e) {
               e.printStackTrace();
           }
       }
	return null;
}
 
开发者ID:muxiangqiu,项目名称:linq,代码行数:17,代码来源:JpaUtil.java

示例4: AbstractProperty

import org.springframework.beans.BeanUtils; //导入方法依赖的package包/类
public AbstractProperty(EntityMetadata metadata, Field field) {
	this.metadata = metadata;
	String name = field.getName();
	Class<?> entityType = metadata.getEntityType();
	this.field = field;
	descriptor = BeanUtils.getPropertyDescriptor(entityType, name);
	if(descriptor == null && name.startsWith("is") && field.getType() == boolean.class){
		name = name.substring(2);
		descriptor = BeanUtils.getPropertyDescriptor(entityType, name);
	}
	if(descriptor == null){
		throw new RuntimeException("属性[" + name +"]不存在");
	}
	this.type = field.getType();
}
 
开发者ID:yaoakeji,项目名称:hibatis,代码行数:16,代码来源:AbstractProperty.java

示例5: getParameter

import org.springframework.beans.BeanUtils; //导入方法依赖的package包/类
/**
 * @param name
 * @return dummy
 */
public Object getParameter(String name) {
    PropertyDescriptor propertyDescriptor = BeanUtils.getPropertyDescriptor(this.getClass(), name);
    if (propertyDescriptor != null) {
        Object value = null;
        try {
            value = propertyDescriptor.getReadMethod().invoke(this, new Object[]{});//调用方法获取方法的返回值
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
        }
        return value;
    }
    return null;
}
 
开发者ID:FastBootWeixin,项目名称:FastBootWeixin,代码行数:18,代码来源:WxRequest.java

示例6: execute

import org.springframework.beans.BeanUtils; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
public ActionValue execute(Context context,Object matchedObject,List<Object> allMatchedObjects,Map<String,Object> variableMap) {
	Object targetFact=null;
	String propertyName=null;
	ValueCompute valueCompute=context.getValueCompute();
	Object obj=valueCompute.complexValueCompute(value, matchedObject, context,allMatchedObjects,variableMap);
	String label=null;
	if(type!=null && type.equals(LeftType.NamedReference)){
		String refName=referenceName;
		targetFact=variableMap.get(refName);
		if(targetFact==null){
			refName=refName.substring(1,refName.length());
			targetFact=variableMap.get(refName);
		}
		if(targetFact==null){
			throw new RuleException("Reference ["+referenceName+"] not define.");
		}
		propertyName=variableName;
		label=referenceName+"."+(variableLabel==null ? variableName : variableLabel);
	}else{
		String className=context.getVariableCategoryClass(variableCategory);
		if(className.equals(HashMap.class.getName())){
			targetFact=context.getWorkingMemory().getParameters();				
		}else{
			targetFact=valueCompute.findObject(className, matchedObject, context);				
		}
		if(targetFact==null){
			throw new RuleException("Class["+className+"] not found in workingmemory.");
		}
		if(datatype.equals(Datatype.Enum) && obj!=null && StringUtils.isNotBlank(obj.toString())){
			PropertyDescriptor pd=BeanUtils.getPropertyDescriptor(targetFact.getClass(), variableName);
			Class<Enum> targetClass=(Class<Enum>)pd.getPropertyType();
			obj=Enum.valueOf(targetClass, obj.toString());
		}else if(obj!=null){
			obj=datatype.convert(obj);
		}
		propertyName=variableName;
		label=variableCategory+"."+(variableLabel==null ? variableName : variableLabel);
	}
	Utils.setObjectProperty(targetFact, propertyName, obj);
	if(debug && Utils.isDebug()){
		String msg="###变量赋值:"+label+"="+obj;
		context.debugMsg(msg, MsgType.VarAssign, debug);
	}
	return null;
}
 
开发者ID:youseries,项目名称:urule,代码行数:47,代码来源:VariableAssignAction.java

示例7: CacheObject

import org.springframework.beans.BeanUtils; //导入方法依赖的package包/类
public CacheObject(Class<?> clazz)
{
	entity = isEntity(clazz);
	if( isProperty(clazz) )
	{
		for( PropertyDescriptor descriptor : BeanUtils.getPropertyDescriptors(clazz) )
		{
			Method readMethod = descriptor.getReadMethod();
			Method writeMethod = descriptor.getWriteMethod();
			if( readMethod != null && writeMethod != null )
			{
				if( readMethod.isAnnotationPresent(Id.class) )
				{
					id = new MethodProperty(descriptor);
				}
				Class<?> type = descriptor.getPropertyType();
				if( isComplexType(type) )
				{
					properties.add(new MethodProperty(descriptor));
				}
			}
		}
	}
	else
	{
		for( Field field : clazz.getDeclaredFields() )
		{
			boolean isStatic = Modifier.STATIC == (Modifier.STATIC & field.getModifiers());

			if( !isStatic && isComplexType(field.getType()) )
			{
				properties
					.add(new FieldProperty(field, BeanUtils.getPropertyDescriptor(clazz, field.getName())));
			}
			if( field.isAnnotationPresent(Id.class) )
			{
				id = new FieldProperty(field, BeanUtils.getPropertyDescriptor(clazz, field.getName()));
			}
		}
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:42,代码来源:InitialiserServiceImpl.java


注:本文中的org.springframework.beans.BeanUtils.getPropertyDescriptor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。