/** * Get representations for all of the Java properties on the supplied object. * * @param target the target on which the setter is to be called; may not be null * @return the map of all properties keyed by their name; never null * @throws NoSuchMethodException if a matching method is not found. * @throws SecurityException if access to the information is denied. * @throws IllegalAccessException if the setter method could not be accessed * @throws InvocationTargetException if there was an error invoking the setter method on the target * @throws IllegalArgumentException if 'target' is null, or if 'propertyName' is null or empty */ public Map<String, Property> getAllPropertiesByNameOn( Object target ) throws SecurityException, IllegalArgumentException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { String[] propertyNames = findGetterPropertyNames(); Map<String, Property> results = new HashMap<String, Property>(); for (String propertyName : propertyNames) { if ("class".equals(propertyName)) continue; Property prop = getProperty(target, propertyName); results.put(prop.getName(), prop); } return results; }
/** * Get representations for all of the Java properties on the supplied object. * * @param target the target on which the setter is to be called; may not be null * @return the map of all properties keyed by their name; never null * @throws NoSuchMethodException if a matching method is not found. * @throws SecurityException if access to the information is denied. * @throws IllegalAccessException if the setter method could not be accessed * @throws InvocationTargetException if there was an error invoking the setter method on the target * @throws IllegalArgumentException if 'target' is null, or if 'propertyName' is null or empty */ public Map<String, Property> getAllPropertiesByNameOn( Object target ) throws SecurityException, IllegalArgumentException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { String[] propertyNames = findGetterPropertyNames(); Map<String, Property> results = new HashMap<String, Property>(); for (String propertyName : propertyNames) { if ("class".equals(propertyName)) continue; Property prop = getProperty(target, propertyName); results.put(prop.getName(), prop); } return results; }
/** * Get representations for all of the Java properties on the supplied object. * * @param target the target on which the setter is to be called; may not be null * @return the map of all properties keyed by their name; never null * @throws NoSuchMethodException if a matching method is not found. * @throws SecurityException if access to the information is denied. * @throws IllegalAccessException if the setter method could not be accessed * @throws InvocationTargetException if there was an error invoking the setter method on the target * @throws IllegalArgumentException if 'target' is null, or if 'propertyName' is null or empty */ public Map<String, Property> getAllPropertiesByNameOn( Object target ) throws SecurityException, IllegalArgumentException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { String[] propertyNames = findGetterPropertyNames(); Map<String, Property> results = new HashMap<String, Property>(); for (String propertyName : propertyNames) { if ("class".equals(propertyName)) continue; Property prop = getProperty(target, propertyName); results.put(prop.getName(), prop); } return results; }
assertThat(property.getName(), is("status")); assertThat(property.getLabel(), is("Status")); assertThat(property.getType().equals(Status.class), is(true)); assertThat(property.isReadOnly(), is(true)); assertThat(property, is(findProperty(property.getName(), props))); assertValue(reflection, problem, property, status); assertThat(property.getName(), is("code")); assertThat(property.getLabel(), is("Code")); assertThat(property.getType().equals(Integer.TYPE), is(true)); assertThat(property.getName(), is("message")); assertThat(property.getLabel(), is("Message")); assertThat(property.getType().equals(I18n.class), is(true)); assertThat(property.getName(), is("messageString")); assertThat(property.getLabel(), is("Message String")); assertThat(property.getType().equals(String.class), is(true)); assertThat(property.getName(), is("parameters")); assertThat(property.getLabel(), is("Parameters")); assertThat(property.getType().equals(Object[].class), is(true)); assertThat(property.getName(), is("resource")); assertThat(property.getLabel(), is("Resource")); assertThat(property.getType().equals(String.class), is(true)); assertThat(property.getName(), is("location")); assertThat(property.getLabel(), is("Location"));
assertThat(property.getName(), is("identifier")); assertThat(property.getLabel(), is(CommonI18n.noMoreContent.text())); assertThat(property.getDescription(), is(CommonI18n.nullActivityMonitorTaskName.text())); assertThat(property.getType().equals(String.class), is(true)); assertThat(property.isReadOnly(), is(false)); assertThat(property, is(findProperty(property.getName(), props))); assertValue(reflection, structure, property, structure.getIdentifier()); assertThat(property.getName(), is("count")); assertThat(property.getLabel(), is("Count")); assertThat(property.getDescription(), is("This is the count")); assertThat(property.getName(), is("onFire")); assertThat(property.getLabel(), is("On Fire")); assertThat(property.getDescription(), is(""));
/** * Set the property on the supplied target object to the specified value. * * @param target the target on which the setter is to be called; may not be null * @param property the property that is to be set on the target * @param value the new value for the property * @throws NoSuchMethodException if a matching method is not found. * @throws SecurityException if access to the information is denied. * @throws IllegalAccessException if the setter method could not be accessed * @throws InvocationTargetException if there was an error invoking the setter method on the target * @throws IllegalArgumentException if 'target' is null, 'property' is null, or 'property.getName()' is null */ public void setProperty( Object target, Property property, Object value ) throws SecurityException, IllegalArgumentException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { CheckArg.isNotNull(target, "target"); CheckArg.isNotNull(property, "property"); CheckArg.isNotNull(property.getName(), "property.getName()"); invokeSetterMethodOnTarget(property.getName(), target, value); }
/** * Set the property on the supplied target object to the specified value. * * @param target the target on which the setter is to be called; may not be null * @param property the property that is to be set on the target * @param value the new value for the property * @throws NoSuchMethodException if a matching method is not found. * @throws SecurityException if access to the information is denied. * @throws IllegalAccessException if the setter method could not be accessed * @throws InvocationTargetException if there was an error invoking the setter method on the target * @throws IllegalArgumentException if 'target' is null, 'property' is null, or 'property.getName()' is null */ public void setProperty( Object target, Property property, Object value ) throws SecurityException, IllegalArgumentException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { CheckArg.isNotNull(target, "target"); CheckArg.isNotNull(property, "property"); CheckArg.isNotNull(property.getName(), "property.getName()"); invokeSetterMethodOnTarget(property.getName(), target, value); }
/** * Set the property on the supplied target object to the specified value. * * @param target the target on which the setter is to be called; may not be null * @param property the property that is to be set on the target * @param value the new value for the property * @throws NoSuchMethodException if a matching method is not found. * @throws SecurityException if access to the information is denied. * @throws IllegalAccessException if the setter method could not be accessed * @throws InvocationTargetException if there was an error invoking the setter method on the target * @throws IllegalArgumentException if 'target' is null, 'property' is null, or 'property.getName()' is null */ public void setProperty( Object target, Property property, Object value ) throws SecurityException, IllegalArgumentException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { CheckArg.isNotNull(target, "target"); CheckArg.isNotNull(property, "property"); CheckArg.isNotNull(property.getName(), "property.getName()"); invokeSetterMethodOnTarget(property.getName(), target, value); }
/** * Get current value for the property on the supplied target object. * * @param target the target on which the setter is to be called; may not be null * @param property the property that is to be set on the target * @return the current value for the property; may be null * @throws NoSuchMethodException if a matching method is not found. * @throws SecurityException if access to the information is denied. * @throws IllegalAccessException if the setter method could not be accessed * @throws InvocationTargetException if there was an error invoking the setter method on the target * @throws IllegalArgumentException if 'target' is null, 'property' is null, or 'property.getName()' is null */ public Object getProperty( Object target, Property property ) throws SecurityException, IllegalArgumentException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { CheckArg.isNotNull(target, "target"); CheckArg.isNotNull(property, "property"); CheckArg.isNotNull(property.getName(), "property.getName()"); return invokeGetterMethodOnTarget(property.getName(), target); }
/** * Get current value for the property on the supplied target object. * * @param target the target on which the setter is to be called; may not be null * @param property the property that is to be set on the target * @return the current value for the property; may be null * @throws NoSuchMethodException if a matching method is not found. * @throws SecurityException if access to the information is denied. * @throws IllegalAccessException if the setter method could not be accessed * @throws InvocationTargetException if there was an error invoking the setter method on the target * @throws IllegalArgumentException if 'target' is null, 'property' is null, or 'property.getName()' is null */ public Object getProperty( Object target, Property property ) throws SecurityException, IllegalArgumentException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { CheckArg.isNotNull(target, "target"); CheckArg.isNotNull(property, "property"); CheckArg.isNotNull(property.getName(), "property.getName()"); return invokeGetterMethodOnTarget(property.getName(), target); }
/** * Get current value for the property on the supplied target object. * * @param target the target on which the setter is to be called; may not be null * @param property the property that is to be set on the target * @return the current value for the property; may be null * @throws NoSuchMethodException if a matching method is not found. * @throws SecurityException if access to the information is denied. * @throws IllegalAccessException if the setter method could not be accessed * @throws InvocationTargetException if there was an error invoking the setter method on the target * @throws IllegalArgumentException if 'target' is null, 'property' is null, or 'property.getName()' is null */ public Object getProperty( Object target, Property property ) throws SecurityException, IllegalArgumentException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { CheckArg.isNotNull(target, "target"); CheckArg.isNotNull(property, "property"); CheckArg.isNotNull(property.getName(), "property.getName()"); return invokeGetterMethodOnTarget(property.getName(), target); }
protected Property findProperty( String propertyName, List<Property> properties ) { for (Property prop : properties) { if (prop.getName().equals(propertyName)) return prop; } return null; }