| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| FieldOverrideForValueReplaceImpl | 
  | 
  | 1.8;1.8 | 
| 1 |  /* | |
| 2 |   * Copyright 2007-2010 The Kuali Foundation | |
| 3 |   * | |
| 4 |   * Licensed under the Educational Community License, Version 2.0 (the "License"); | |
| 5 |   * you may not use this file except in compliance with the License. | |
| 6 |   * You may obtain a copy of the License at | |
| 7 |   * | |
| 8 |   * http://www.opensource.org/licenses/ecl2.php | |
| 9 |   * | |
| 10 |   * Unless required by applicable law or agreed to in writing, software | |
| 11 |   * distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 |   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 |   * See the License for the specific language governing permissions and | |
| 14 |   * limitations under the License. | |
| 15 |   */ | |
| 16 |  package org.kuali.rice.kns.datadictionary.impl; | |
| 17 | ||
| 18 |  import java.lang.reflect.InvocationTargetException; | |
| 19 | ||
| 20 |  import org.apache.commons.beanutils.BeanUtils; | |
| 21 |  import org.kuali.rice.kns.datadictionary.FieldOverride; | |
| 22 | ||
| 23 |  /** | |
| 24 |   * A Field Override used to replace value elements from a Data Dictionary bean.  | |
| 25 |   *  | |
| 26 |   * @author Kuali Rice Team (rice.collab@kuali.org) | |
| 27 |   *  | |
| 28 |   */ | |
| 29 | 0 |  public class FieldOverrideForValueReplaceImpl implements FieldOverride{ | 
| 30 | ||
| 31 |          private String propertyName; | |
| 32 |          private Object value; | |
| 33 | ||
| 34 |          public String getPropertyName() { | |
| 35 | 0 |                  return propertyName; | 
| 36 | }  | |
| 37 | ||
| 38 | public void setPropertyName(String propertyName) {  | |
| 39 | 0 |                  this.propertyName = propertyName; | 
| 40 | 0 |          } | 
| 41 | ||
| 42 |          public Object getValue() { | |
| 43 | 0 |                  return value; | 
| 44 | }  | |
| 45 | ||
| 46 | public void setValue(Object value) {  | |
| 47 | 0 |                  this.value = value; | 
| 48 | 0 |          } | 
| 49 | ||
| 50 |          public Object performFieldOverride(Object bean, Object property) { | |
| 51 |                  try { | |
| 52 | 0 |                          BeanUtils.setProperty(bean, this.getPropertyName(), this.getValue()); | 
| 53 | 0 |                  } catch (IllegalAccessException e) { | 
| 54 | 0 |                          throw new RuntimeException(e); | 
| 55 | 0 |                  } catch (InvocationTargetException e) { | 
| 56 | 0 |                          throw new RuntimeException(e); | 
| 57 | 0 |                  } | 
| 58 | ||
| 59 | 0 |                  return getValue(); | 
| 60 | }  | |
| 61 | }  |