1 19 20 package org.apache.cayenne.project.validator; 21 22 import java.util.Iterator ; 23 24 import org.apache.cayenne.access.DataDomain; 25 import org.apache.cayenne.project.Project; 26 import org.apache.cayenne.project.ProjectPath; 27 import org.apache.cayenne.util.Util; 28 29 32 public class DomainValidator extends TreeNodeValidator { 33 36 public DomainValidator() { 37 super(); 38 } 39 40 public void validateObject(ProjectPath path, Validator validator) { 41 42 DataDomain domain = (DataDomain) path.getObject(); 44 String name = domain.getName(); 45 if (Util.isEmptyString(name)) { 46 validator.registerError("Unnamed DataDomain.", path); 47 48 return; 50 } 51 52 Project project = (Project) path.getObjectParent(); 53 if (project == null) { 54 return; 55 } 56 57 Iterator it = project.getChildren().iterator(); 59 while (it.hasNext()) { 60 DataDomain dom = (DataDomain) it.next(); 61 if (dom == domain) { 62 continue; 63 } 64 65 if (name.equals(dom.getName())) { 66 validator.registerError("Duplicate DataDomain name: " + name + ".", path); 67 return; 68 } 69 } 70 } 71 } 72 | Popular Tags |