예제 #1
0
  /**
   * Creates {@code PropertyDescriptor} from the specified property info.
   *
   * @param entry the pair of values, where the {@code key} is the base name of the property (the
   *     rest of the method name) and the {@code value} is the automatically generated property info
   * @param bound the flag indicating whether it is possible to treat this property as a bound
   *     property
   * @since 9
   */
  PropertyDescriptor(Entry<String, PropertyInfo> entry, boolean bound) {
    String base = entry.getKey();
    PropertyInfo info = entry.getValue();
    setName(Introspector.decapitalize(base));
    setReadMethod0(info.getReadMethod());
    setWriteMethod0(info.getWriteMethod());
    setPropertyType(info.getPropertyType());
    setConstrained(info.isConstrained());
    setBound(bound && info.is(PropertyInfo.Name.bound));

    boolean isExpert = info.is(PropertyInfo.Name.expert);
    setValue(PropertyInfo.Name.expert.name(), isExpert); // compatibility
    setExpert(isExpert);

    boolean isHidden = info.is(PropertyInfo.Name.hidden);
    setValue(PropertyInfo.Name.hidden.name(), isHidden); // compatibility
    setHidden(isHidden);

    setPreferred(info.is(PropertyInfo.Name.preferred));

    boolean isRequired = info.is(PropertyInfo.Name.required);
    setValue(PropertyInfo.Name.required.name(), isRequired);

    boolean visual = info.is(PropertyInfo.Name.visualUpdate);
    setValue(PropertyInfo.Name.visualUpdate.name(), visual);

    Object description = info.get(PropertyInfo.Name.description);
    if (description != null) {
      setShortDescription(description.toString());
    }
    Object values = info.get(PropertyInfo.Name.enumerationValues);
    if (values != null) {
      setValue(PropertyInfo.Name.enumerationValues.name(), values);
    }
    this.baseName = base;
  }
예제 #2
0
 /**
  * Sets the method that should be used to write the property value.
  *
  * @param writeMethod The new write method.
  * @throws IntrospectionException if the write method is invalid
  * @since 1.2
  */
 public synchronized void setWriteMethod(Method writeMethod) throws IntrospectionException {
   // Set the property type - which validates the method
   setPropertyType(findPropertyType(getReadMethod(), writeMethod));
   setWriteMethod0(writeMethod);
 }