001/* 002 * Copyright 2011-2012 The Kuali Foundation Licensed under the 003 * Educational Community License, Version 2.0 (the "License"); you may 004 * not use this file except in compliance with the License. You may 005 * obtain a copy of the License at 006 * 007 * http://www.osedu.org/licenses/ECL-2.0 008 * 009 * Unless required by applicable law or agreed to in writing, 010 * software distributed under the License is distributed on an "AS IS" 011 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 012 * or implied. See the License for the specific language governing 013 * permissions and limitations under the License. 014 */ 015package org.kuali.mobility.academics.util; 016 017import org.apache.commons.collections.Transformer; 018import org.kuali.mobility.academics.entity.Subject; 019import org.kuali.mobility.academics.entity.SubjectImpl; 020 021/** 022 * 023 * @author Joe Swanson <joseswan@umich.edu> 024 */ 025public class SubjectTransform implements Transformer { 026 027 @Override 028 public SubjectImpl transform( Object obj ) { 029 SubjectImpl proxy = null; 030 031 if( obj instanceof SubjectImpl ) { 032 proxy = (SubjectImpl)obj; 033 } else if( obj instanceof Subject ) { 034 proxy = new SubjectImpl(); 035 proxy.setId( ((Subject)obj).getId() ); 036 proxy.setDescription( ((Subject)obj).getDescription() ); 037 proxy.setShortDescription( ((Subject)obj).getShortDescription() ); 038 } 039 return proxy; 040 } 041 042}