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


Java PropertyDescriptor.getDisplayName方法代码示例

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


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

示例1: getAttributeDescription

import java.beans.PropertyDescriptor; //导入方法依赖的package包/类
/**
 * Creates a description for the attribute corresponding to this property
 * descriptor. Attempts to create the description using metadata from either
 * the getter or setter attributes, otherwise uses the property name.
 */
@Override
protected String getAttributeDescription(PropertyDescriptor propertyDescriptor, String beanKey) {
	Method readMethod = propertyDescriptor.getReadMethod();
	Method writeMethod = propertyDescriptor.getWriteMethod();

	ManagedAttribute getter =
			(readMethod != null ? this.attributeSource.getManagedAttribute(readMethod) : null);
	ManagedAttribute setter =
			(writeMethod != null ? this.attributeSource.getManagedAttribute(writeMethod) : null);

	if (getter != null && StringUtils.hasText(getter.getDescription())) {
		return getter.getDescription();
	}
	else if (setter != null && StringUtils.hasText(setter.getDescription())) {
		return setter.getDescription();
	}

	ManagedMetric metric = (readMethod != null ? this.attributeSource.getManagedMetric(readMethod) : null);
	if (metric != null && StringUtils.hasText(metric.getDescription())) {
		return metric.getDescription();
	}

	return propertyDescriptor.getDisplayName();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:30,代码来源:MetadataMBeanInfoAssembler.java

示例2: copyProperties

import java.beans.PropertyDescriptor; //导入方法依赖的package包/类
public static void copyProperties(Object fromObj, Object toObj) {
    Class<?> fromClass = fromObj.getClass();
    Class<?> toClass = toObj.getClass();

    try {
        BeanInfo fromBean = Introspector.getBeanInfo(fromClass);
        BeanInfo toBean = Introspector.getBeanInfo(toClass);

        PropertyDescriptor[] toPd = toBean.getPropertyDescriptors();
        List<PropertyDescriptor> fromPd = Arrays.asList(fromBean.getPropertyDescriptors());

        for (PropertyDescriptor propertyDescriptor : toPd) {
            propertyDescriptor.getDisplayName();
            PropertyDescriptor pd = fromPd.get(fromPd.indexOf(propertyDescriptor));
            if (pd.getDisplayName().equals(
                    propertyDescriptor.getDisplayName()) &&
                    !pd.getDisplayName().equals("class") &&
                    propertyDescriptor.getWriteMethod() != null) {
                propertyDescriptor.getWriteMethod().invoke(toObj, pd.getReadMethod().invoke(fromObj, null));
            }

        }
    } catch (IntrospectionException | InvocationTargetException | IllegalAccessException | IllegalArgumentException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:actiontech,项目名称:dble,代码行数:27,代码来源:ObjectUtil.java

示例3: inject

import java.beans.PropertyDescriptor; //导入方法依赖的package包/类
public void inject(Object bean, BeanAccess props)
{
    for (PropertyDescriptor pd : getPropertyDescriptors(bean.getClass()))
    {
        try
        {
            Method method = pd.getWriteMethod();
            String name = pd.getName();

            if ((method != null) && (props.propLength(name) != 0))
            {
                Object value;

                if (pd.getPropertyType().isArray())
                {
                    value = Array.newInstance(pd.getPropertyType().getComponentType(), props.propLength(name));
                    for (int i = 0; i < props.propLength(name); i++)
                    {
                        Array.set(value, i, parse(props.propGet(name, i), pd.getPropertyType().getComponentType()));
                    }
                }
                else
                {
                    value = parse(props.propGet(name), pd.getPropertyType());
                }

                method.invoke(bean, value);
            }
        }
        catch (Exception x)
        {
            throw new IllegalArgumentException("Failed to set property: " + pd.getDisplayName(), x);
        }
    }
}
 
开发者ID:JetBrains,项目名称:intellij-deps-ini4j,代码行数:36,代码来源:BeanTool.java

示例4: getAttributeDescription

import java.beans.PropertyDescriptor; //导入方法依赖的package包/类
/**
 * Get the description for a particular attribute.
 * <p>The default implementation returns a description for the operation
 * that is the name of corresponding {@code Method}.
 * @param propertyDescriptor the PropertyDescriptor for the attribute
 * @param beanKey the key associated with the MBean in the beans map
 * of the {@code MBeanExporter}
 * @return the description for the attribute
 */
protected String getAttributeDescription(PropertyDescriptor propertyDescriptor, String beanKey) {
	return propertyDescriptor.getDisplayName();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:13,代码来源:AbstractReflectiveMBeanInfoAssembler.java


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