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


Java PropertyDescriptor.isBound方法代码示例

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


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

示例1: equals

import java.beans.PropertyDescriptor; //导入方法依赖的package包/类
/**
 * Compare the given {@link PropertyDescriptor} against the given {@link Object} and
 * return {@code true} if they are objects are equivalent, i.e. both are {@code
 * PropertyDescriptor}s whose read method, write method, property types, property
 * editor and flags are equivalent.
 * @see PropertyDescriptor#equals(Object)
 */
public static boolean equals(PropertyDescriptor pd1, Object obj) {
	if (pd1 == obj) {
		return true;
	}
	if (obj != null && obj instanceof PropertyDescriptor) {
		PropertyDescriptor pd2 = (PropertyDescriptor) obj;
		if (!compareMethods(pd1.getReadMethod(), pd2.getReadMethod())) {
			return false;
		}
		if (!compareMethods(pd1.getWriteMethod(), pd2.getWriteMethod())) {
			return false;
		}
		if (pd1.getPropertyType() == pd2.getPropertyType() &&
				pd1.getPropertyEditorClass() == pd2.getPropertyEditorClass() &&
				pd1.isBound() == pd2.isBound() && pd1.isConstrained() == pd2.isConstrained()) {
			return true;
		}
	}
	return false;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:28,代码来源:ExtendedBeanInfo.java

示例2: main

import java.beans.PropertyDescriptor; //导入方法依赖的package包/类
public static void main(String[] args) throws IntrospectionException {
    if (!BeanUtils.findPropertyDescriptor(MyBean.class, "test").isBound()) {
        throw new Error("a simple property is not bound");
    }
    if (!BeanUtils.findPropertyDescriptor(MyBean.class, "list").isBound()) {
        throw new Error("a generic property is not bound");
    }
    if (!BeanUtils.findPropertyDescriptor(MyBean.class, "readOnly").isBound()) {
        throw new Error("a read-only property is not bound");
    }
    PropertyDescriptor[] pds = Introspector.getBeanInfo(MyBean.class, BaseBean.class).getPropertyDescriptors();
    for (PropertyDescriptor pd : pds) {
        if (pd.getName().equals("test") && pd.isBound()) {
            throw new Error("a simple property is bound without superclass");
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:18,代码来源:Test7192955.java

示例3: test

import java.beans.PropertyDescriptor; //导入方法依赖的package包/类
private static void test(Class<?> cls, boolean isBound, boolean isExpert,
                         boolean isHidden, boolean isPref, boolean isReq,
                         boolean isVS) {
    PropertyDescriptor pd = BeanUtils.getPropertyDescriptor(cls, "value");
    if (pd.isBound() != isBound) {
        throw new RuntimeException("isBound should be: " + isBound);
    }
    if (pd.isExpert() != isExpert || getValue(pd, "expert") != isExpert) {
        throw new RuntimeException("isExpert should be:" + isExpert);
    }
    if (pd.isHidden() != isHidden || getValue(pd, "hidden") != isHidden) {
        throw new RuntimeException("isHidden should be: " + isHidden);
    }
    if (pd.isPreferred() != isPref) {
        throw new RuntimeException("isPreferred should be: " + isPref);
    }
    if (getValue(pd, "required") != isReq) {
        throw new RuntimeException("required should be: " + isReq);
    }
    if (getValue(pd, "visualUpdate") != isVS) {
        throw new RuntimeException("required should be: " + isVS);
    }
    if (pd.getValue("enumerationValues") == null) {
        throw new RuntimeException("enumerationValues should be empty array");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:TestBooleanBeanProperties.java

示例4: compare

import java.beans.PropertyDescriptor; //导入方法依赖的package包/类
private static boolean compare(PropertyDescriptor pd1, PropertyDescriptor pd2) {
    if (!compare(pd1.getReadMethod(), pd2.getReadMethod())) {
        System.out.println("read methods not equal");
        return false;
    }
    if (!compare(pd1.getWriteMethod(), pd2.getWriteMethod())) {
        System.out.println("write methods not equal");
        return false;
    }
    if (pd1.getPropertyType() != pd2.getPropertyType()) {
        System.out.println("property type not equal");
        return false;
    }
    if (pd1.getPropertyEditorClass() != pd2.getPropertyEditorClass()) {
        System.out.println("property editor class not equal");
        return false;
    }
    if (pd1.isBound() != pd2.isBound()) {
        System.out.println("bound value not equal");
        return false;
    }
    if (pd1.isConstrained() != pd2.isConstrained()) {
        System.out.println("constrained value not equal");
        return false;
    }
    return true;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:28,代码来源:Test4634390.java

示例5: main

import java.beans.PropertyDescriptor; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    Class<?>[] types =
            {B.class, BL.class, BLF.class, E.class, H.class, P.class,
             VU.class, D.class, EVD.class, EVE.class, EV.class, EVL.class,
             EVX.class, R.class};
    for (Class<?> type : types) {
        PropertyDescriptor pd = BeanUtils.getPropertyDescriptor(type, "value");
        if (((B.class == type) || (BLF.class == type)) && pd.isBound()) {
            BeanUtils.reportPropertyDescriptor(pd);
            throw new Error("not bound");
        }
        if ((BL.class == type) == !pd.isBound()) {
            BeanUtils.reportPropertyDescriptor(pd);
            throw new Error("bound");
        }
        if ((E.class == type) == !pd.isExpert()) {
            BeanUtils.reportPropertyDescriptor(pd);
            throw new Error("expert");
        }
        if ((H.class == type) == !pd.isHidden()) {
            BeanUtils.reportPropertyDescriptor(pd);
            throw new Error("hidden");
        }
        if ((P.class == type) == !pd.isPreferred()) {
            BeanUtils.reportPropertyDescriptor(pd);
            throw new Error("preferred");
        }
        if ((R.class == type) == !Boolean.TRUE.equals(pd.getValue("required"))) {
            BeanUtils.reportPropertyDescriptor(pd);
            throw new Error("required");
        }
        if ((D.class == type) == !"getter".equals(pd.getShortDescription())) {
            BeanUtils.reportPropertyDescriptor(pd);
            throw new Error("shortDescription");
        }
        if ((VU.class == type) == !Boolean.TRUE.equals(pd.getValue("visualUpdate"))) {
            BeanUtils.reportPropertyDescriptor(pd);
            throw new Error("visualUpdate");
        }
        if ((EV.class == type) == !isEV(pd, "LEFT", 2, "javax.swing.SwingConstants.LEFT", "RIGHT", 4, "javax.swing.SwingConstants.RIGHT")) {
            BeanUtils.reportPropertyDescriptor(pd);
            throw new Error("enumerationValues from another package");
        }
        if ((EVL.class == type) == !isEV(pd, "ZERO", 0, "ZERO", "ONE", 1, "ONE")) {
            BeanUtils.reportPropertyDescriptor(pd);
            throw new Error("enumerationValues from another package");
        }
        if ((EVX.class == type) == !isEV(pd, "ZERO", 0, "X.ZERO", "ONE", 1, "X.ONE")) {
            BeanUtils.reportPropertyDescriptor(pd);
            throw new Error("enumerationValues from another package");
        }
        if (EVD.class == type && !isEV(pd)) {
            BeanUtils.reportPropertyDescriptor(pd);
            throw new Error("EV:"+ pd.getValue("enumerationValues"));
        }
        if (EVE.class == type && !isEV(pd)) {
            BeanUtils.reportPropertyDescriptor(pd);
            throw new Error("EV:"+ pd.getValue("enumerationValues"));
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:62,代码来源:TestBeanProperty.java


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