Example #1
0
 /**
  * Sets the fields specified by this {@code Parameters} on the specified {@link Connections}
  * object.
  *
  * @param cn
  */
 public void apply(Object cn) {
   BeanUtil beanUtil = BeanUtil.getInstance();
   Set<KEY> presentKeys = paramMap.keySet();
   synchronized (paramMap) {
     for (KEY key : presentKeys) {
       beanUtil.setSimpleProperty(cn, key.fieldName, getParameterByKey(key));
     }
   }
 }
Example #2
0
 /**
  * Convenience method to log difference this {@code Parameters} and specified {@link Connections}
  * object.
  *
  * @param cn
  * @return true if find it different
  */
 public boolean logDiff(Object cn) {
   if (cn == null) {
     throw new IllegalArgumentException("cn Object is required and can not be null");
   }
   boolean result = false;
   BeanUtil beanUtil = BeanUtil.getInstance();
   BeanUtil.PropertyInfo[] properties = beanUtil.getPropertiesInfoForBean(cn.getClass());
   for (int i = 0; i < properties.length; i++) {
     BeanUtil.PropertyInfo property = properties[i];
     String fieldName = property.getName();
     KEY propKey = KEY.getKeyByFieldName(property.getName());
     if (propKey != null) {
       Object paramValue = this.getParameterByKey(propKey);
       Object cnValue = beanUtil.getSimpleProperty(cn, fieldName);
       if ((paramValue != null && !paramValue.equals(cnValue))
           || (paramValue == null && cnValue != null)) {
         result = true;
         System.out.println(
             "Property:" + fieldName + " is different - CN:" + cnValue + " | PARAM:" + paramValue);
       }
     }
   }
   return result;
 }