001/** 002 * Copyright 2005-2016 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.rice.krad.datadictionary.impl; 017 018import java.lang.reflect.InvocationTargetException; 019 020import org.apache.commons.beanutils.BeanUtils; 021import org.kuali.rice.krad.datadictionary.FieldOverride; 022 023/** 024 * A Field Override used to replace value elements from a Data Dictionary bean. 025 * 026 * @author Kuali Rice Team (rice.collab@kuali.org) 027 * 028 */ 029public class FieldOverrideForValueReplaceImpl implements FieldOverride{ 030 031 private String propertyName; 032 private Object value; 033 034 public String getPropertyName() { 035 return propertyName; 036 } 037 038 public void setPropertyName(String propertyName) { 039 this.propertyName = propertyName; 040 } 041 042 public Object getValue() { 043 return value; 044 } 045 046 public void setValue(Object value) { 047 this.value = value; 048 } 049 050 public Object performFieldOverride(Object bean, Object property) { 051 try { 052 BeanUtils.setProperty(bean, this.getPropertyName(), this.getValue()); 053 } catch (IllegalAccessException e) { 054 throw new RuntimeException(e); 055 } catch (InvocationTargetException e) { 056 throw new RuntimeException(e); 057 } 058 059 return getValue(); 060 } 061}