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.bo;
017
018import org.apache.commons.lang.builder.ReflectionToStringBuilder;
019import org.apache.commons.lang.builder.ToStringBuilder;
020import org.apache.commons.lang.builder.ToStringStyle;
021
022import java.lang.reflect.Field;
023import java.util.LinkedHashMap;
024
025/**
026 * @author Kuali Rice Team (rice.collab@kuali.org)
027 */
028public abstract class BusinessObjectBase implements BusinessObject {
029
030    /**
031     * Default constructor. Required to do some of the voodoo involved in letting the DataDictionary validate attributeNames for a
032     * given BusinessObject subclass.
033     */
034    public BusinessObjectBase() {
035    }
036
037    @Override
038        public String toString() {
039        class BusinessObjectToStringBuilder extends ReflectionToStringBuilder {
040            private BusinessObjectToStringBuilder(Object object) {
041                super(object);
042            }
043
044            public boolean accept(Field field) {
045                if (BusinessObject.class.isAssignableFrom(field.getType())) {
046                    return false;
047                }
048                return super.accept(field);
049            }
050        };
051        ReflectionToStringBuilder toStringBuilder = new BusinessObjectToStringBuilder(this);
052        return toStringBuilder.toString();
053    }
054
055}