Java Code Examples for org.apache.commons.beanutils.BeanUtilsBean#setProperty()

The following examples show how to use org.apache.commons.beanutils.BeanUtilsBean#setProperty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PersistentListener.java    From spring-microservice-boilerplate with MIT License 5 votes vote down vote up
@PrePersist
public void onCreate(Object object) {
  final String ID = "id";
  final String CREATED_AT = "createdAt";
  final String LAST_MODIFIED_AT = "lastModifiedAt";
  BeanUtilsBean beanUtilsBean = BeanUtilsBean2.getInstance();
  try {
    if (Objects.equals(beanUtilsBean.getProperty(object, ID), CommonsConstant.ZERO)) {
      beanUtilsBean.setProperty(object, CREATED_AT, System.currentTimeMillis());
      beanUtilsBean.setProperty(object, LAST_MODIFIED_AT, System.currentTimeMillis());
    }
  } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException ignore) {}
}
 
Example 2
Source File: ValidFlagListener.java    From spring-microservice-boilerplate with MIT License 5 votes vote down vote up
@PrePersist
public void onCreate(Object object) {
  final String ID = "id";
  final String VALID_FLAG = "validFlag";
  BeanUtilsBean beanUtilsBean = BeanUtilsBean2.getInstance();
  try {
    if (Objects.equals(beanUtilsBean.getProperty(object, ID), CommonsConstant.ZERO)) {
      beanUtilsBean.setProperty(object, VALID_FLAG, ValidFlag.VALID);
    }
  } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException ignore) {}
}