1 package org.ocltf.mapping; 2 3 import java.util.Collection; 4 import java.util.HashSet; 5 6 import org.apache.commons.lang.StringUtils; 7 import org.ocltf.templateobject.TemplateObjectException; 8 import org.ocltf.utils.ExceptionUtils; 9 10 /*** 11 * A single object instance which belongs to Mappings. 12 * 13 * @see org.ocltf.mapping.Mappings 14 */ 15 public class Mapping { 16 17 private Collection froms = new HashSet(); 18 19 private String to; 20 21 /*** 22 * Adds the <code>from</code> type to the mapping. 23 * 24 * @param from the type that we are mapping from. 25 */ 26 public void addFrom(String from) { 27 String methodName = "addFrom"; 28 ExceptionUtils.checkNull(methodName, "from", from); 29 froms.add(from); 30 } 31 32 /*** 33 * Return the Collection of froms. 34 * 35 * @return Collection 36 */ 37 public Collection getFroms() { 38 return froms; 39 } 40 41 /*** 42 * Returns the to type for this mapping. 43 * 44 * @return String the to type 45 */ 46 public String getTo() { 47 String methodName = "getTo"; 48 if (StringUtils.isEmpty(this.to)) { 49 throw new TemplateObjectException(methodName 50 + " - to can not be null or empty"); 51 } 52 return this.to; 53 } 54 55 /*** 56 * Sets the type for this mapping. 57 * @param to 58 */ 59 public void setTo(String to) { 60 this.to = to; 61 } 62 63 }