View Javadoc

1   /*
2    * Copyright 2007-2008 the original author or authors.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5    * use this file except in compliance with the License. You may obtain a copy of
6    * the License at
7    * 
8    * http://www.apache.org/licenses/LICENSE-2.0
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, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations under
14   * the License.
15   */
16  package net.sf.morph.transform.copiers;
17  
18  import java.util.Locale;
19  
20  import net.sf.morph.transform.DecoratedConverter;
21  import net.sf.morph.transform.DecoratedCopier;
22  import net.sf.morph.transform.transformers.BaseTransformer;
23  import net.sf.morph.util.ClassUtils;
24  
25  /**
26   * No-op Copier / instantiation-only Converter.
27   *
28   * @author Matt Benson
29   * @since Morph 1.1
30   */
31  public class NOPCopier extends BaseTransformer implements DecoratedConverter,
32  		DecoratedCopier {
33  
34  	/**
35  	 * {@inheritDoc}
36  	 * @see net.sf.morph.transform.transformers.BaseTransformer#copyImpl(java.lang.Object, java.lang.Object, java.util.Locale, java.lang.Integer)
37  	 */
38  	protected void copyImpl(Object destination, Object source, Locale locale,
39  			Integer preferredTransformationType) throws Exception {
40  	}
41  
42  	/**
43  	 * {@inheritDoc}
44  	 * @see net.sf.morph.transform.transformers.BaseTransformer#setSourceClasses(java.lang.Class[])
45  	 */
46  	public synchronized void setSourceClasses(Class[] sourceClasses) {
47  		super.setSourceClasses(sourceClasses);
48  	}
49  
50  	/**
51  	 * {@inheritDoc}
52  	 * @see net.sf.morph.transform.transformers.BaseTransformer#getSourceClassesImpl()
53  	 */
54  	protected Class[] getSourceClassesImpl() throws Exception {
55  		return ClassUtils.getAllClasses();
56  	}
57  
58  	/**
59  	 * {@inheritDoc}
60  	 * @see net.sf.morph.transform.transformers.BaseTransformer#setDestinationClasses(java.lang.Class[])
61  	 */
62  	public synchronized void setDestinationClasses(Class[] destinationClasses) {
63  		super.setDestinationClasses(destinationClasses);
64  	}
65  
66  	/**
67  	 * {@inheritDoc}
68  	 * @see net.sf.morph.transform.transformers.BaseTransformer#getDestinationClassesImpl()
69  	 */
70  	protected Class[] getDestinationClassesImpl() throws Exception {
71  		return new Class[] { Object.class };
72  	}
73  
74  }