/** * 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(); }
/** * 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(); }
@SuppressWarnings("unused") protected String getAttributeDescription(PropertyDescriptor propertyDescriptor) { return propertyDescriptor.getDisplayName(); }
private static Set<String> propertyNamesFrom(PropertyDescriptor[] descriptors) { HashSet<String> result = new HashSet<String>(); for (PropertyDescriptor propertyDescriptor : descriptors) { result.add(propertyDescriptor.getDisplayName()); } return result; }
public PropertyMatcher(PropertyDescriptor descriptor, Object expectedObject) { this.propertyName = descriptor.getDisplayName(); this.readMethod = descriptor.getReadMethod(); this.matcher = equalTo(readProperty(readMethod, expectedObject)); }
private static boolean isIgnored(List<String> ignoredFields, PropertyDescriptor propertyDescriptor) { return ! ignoredFields.contains(propertyDescriptor.getDisplayName()); }
public PropertyMatcher(PropertyDescriptor descriptor, Object expectedObject) { this.propertyName = descriptor.getDisplayName(); this.readMethod = descriptor.getReadMethod(); this.matcher = equalTo(readProperty(readMethod, expectedObject)); }
private static Set<String> propertyNamesFrom(PropertyDescriptor[] descriptors, List<String> ignoredFields) { HashSet<String> result = new HashSet<>(); for (PropertyDescriptor propertyDescriptor : descriptors) { if (isIgnored(ignoredFields, propertyDescriptor)) { result.add(propertyDescriptor.getDisplayName()); } } return result; }
public void injectMembers(I instance) { for (Map.Entry<PropertyDescriptor, Key<?>> dependency : propertyDependencies.entrySet()) { try { final Injector injector = injectorProvider.get(); Object value = injector.getInstance(getMappedKey(injector, dependency.getValue())); dependency.getKey().getWriteMethod().invoke(instance, value); } catch (ConfigurationException e) { // This is ok, it simply means that we can't fulfill this dependency. // Is there a better way to do this? } catch (InvocationTargetException e) { throw new RuntimeException("Couldn't set property " + dependency.getKey().getDisplayName(), e); } catch (IllegalAccessException e) { throw new RuntimeException("We shouldn't have ever reached this point, we don't try to inject to non-accessible methods.", e); } } } });
/** * 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 ? obtainAttributeSource().getManagedAttribute(readMethod) : null); ManagedAttribute setter = (writeMethod != null ? obtainAttributeSource().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 ? obtainAttributeSource().getManagedMetric(readMethod) : null); if (metric != null && StringUtils.hasText(metric.getDescription())) { return metric.getDescription(); } return propertyDescriptor.getDisplayName(); }
/** * 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 ? obtainAttributeSource().getManagedAttribute(readMethod) : null); ManagedAttribute setter = (writeMethod != null ? obtainAttributeSource().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 ? obtainAttributeSource().getManagedMetric(readMethod) : null); if (metric != null && StringUtils.hasText(metric.getDescription())) { return metric.getDescription(); } return propertyDescriptor.getDisplayName(); }
/** * See {@link java.beans.FeatureDescriptor}. */ public static void copyNonMethodProperties(PropertyDescriptor source, PropertyDescriptor target) { target.setExpert(source.isExpert()); target.setHidden(source.isHidden()); target.setPreferred(source.isPreferred()); target.setName(source.getName()); target.setShortDescription(source.getShortDescription()); target.setDisplayName(source.getDisplayName()); // Copy all attributes (emulating behavior of private FeatureDescriptor#addTable) Enumeration<String> keys = source.attributeNames(); while (keys.hasMoreElements()) { String key = keys.nextElement(); target.setValue(key, source.getValue(key)); } // See java.beans.PropertyDescriptor#PropertyDescriptor(PropertyDescriptor) target.setPropertyEditorClass(source.getPropertyEditorClass()); target.setBound(source.isBound()); target.setConstrained(source.isConstrained()); }
/** * See {@link java.beans.FeatureDescriptor}. */ public static void copyNonMethodProperties(PropertyDescriptor source, PropertyDescriptor target) { target.setExpert(source.isExpert()); target.setHidden(source.isHidden()); target.setPreferred(source.isPreferred()); target.setName(source.getName()); target.setShortDescription(source.getShortDescription()); target.setDisplayName(source.getDisplayName()); // Copy all attributes (emulating behavior of private FeatureDescriptor#addTable) Enumeration<String> keys = source.attributeNames(); while (keys.hasMoreElements()) { String key = keys.nextElement(); target.setValue(key, source.getValue(key)); } // See java.beans.PropertyDescriptor#PropertyDescriptor(PropertyDescriptor) target.setPropertyEditorClass(source.getPropertyEditorClass()); target.setBound(source.isBound()); target.setConstrained(source.isConstrained()); }
private static Set<String> propertyNamesFrom(PropertyDescriptor[] descriptors) { HashSet<String> result = new HashSet<String>(); for (PropertyDescriptor propertyDescriptor : descriptors) { result.add(propertyDescriptor.getDisplayName()); } return result; }
public PropertyMatcher(PropertyDescriptor descriptor, Object expectedObject) { this.propertyName = descriptor.getDisplayName(); this.readMethod = descriptor.getReadMethod(); this.matcher = equalTo(readProperty(readMethod, expectedObject)); }
protected PropertyDescriptor createPropertyDescriptor( String name, Class cls, ResourceBundle resourceBundle) throws IntrospectionException { PropertyDescriptor pd = new PropertyDescriptor(name, cls); String s = resourceBundle.getString(pd.getName() + ".DisplayName"); if ((s == null) || (s == "")) { s = pd.getDisplayName(); } pd.setDisplayName(s); s = resourceBundle.getString(pd.getName() + ".Description"); if ((s == null) || (s == "")) { s = pd.getShortDescription(); } pd.setShortDescription(s); return pd; }
parameter.setName(propertyDescriptor.getDisplayName());
public FeatureDescriptor next() { PropertyDescriptor property = properties[next++]; FeatureDescriptor feature = new FeatureDescriptor(); feature.setDisplayName(property.getDisplayName()); feature.setName(property.getName()); feature.setShortDescription(property.getShortDescription()); feature.setExpert(property.isExpert()); feature.setHidden(property.isHidden()); feature.setPreferred(property.isPreferred()); feature.setValue(TYPE, property.getPropertyType()); feature.setValue(RESOLVABLE_AT_DESIGN_TIME, true); return feature; }
public FeatureDescriptor next() { PropertyDescriptor property = properties[next++]; FeatureDescriptor feature = new FeatureDescriptor(); feature.setDisplayName(property.getDisplayName()); feature.setName(property.getName()); feature.setShortDescription(property.getShortDescription()); feature.setExpert(property.isExpert()); feature.setHidden(property.isHidden()); feature.setPreferred(property.isPreferred()); feature.setValue(TYPE, property.getPropertyType()); feature.setValue(RESOLVABLE_AT_DESIGN_TIME, true); return feature; }
); support.setName(p.getName()); support.setDisplayName(p.getDisplayName()); support.setShortDescription(p.getShortDescription()); support.setPropertyEditorClass(p.getPropertyEditorClass());