/** * This method will ensure that if the abstract modifier is set, that final is not set, and * vice-versa, as this is not supported either way. This method will not accept null. It will * not return null. * * @see NewJavaClassDataModelProvider#validate(String) * * @param prop * @return IStatus of whether abstract value is valid */ private IStatus validateModifier(String propertyName, boolean prop) { // Throw an error if both Abstract and Final are checked if (prop) { // Ensure final is not also checked if (propertyName.equals(MODIFIER_ABSTRACT) && getBooleanProperty(MODIFIER_FINAL)) { String msg = J2EECommonMessages.ERR_BOTH_FINAL_AND_ABSTRACT; return WTPCommonPlugin.createErrorStatus(msg); } // Ensure abstract is not also checked if (propertyName.equals(MODIFIER_FINAL) && getBooleanProperty(MODIFIER_ABSTRACT)) { String msg = J2EECommonMessages.ERR_BOTH_FINAL_AND_ABSTRACT; return WTPCommonPlugin.createErrorStatus(msg); } } // Abstract and final settings are valid return WTPCommonPlugin.OK_STATUS; }
/** * Subclasses may override this method to provide their own validation of any of the data * model's properties. This implementation ensures that a java class can be properly generated * from the values as specified. This method will not return null. This method will not accept * null as a parameter. * * @see org.eclipse.wst.common.frameworks.datamodel.IDataModelProvider#validate(java.lang.String) * * @param propertyName * @return IStatus of the validity of the specifiec property */ public IStatus validate(String propertyName) { IStatus result = super.validate(propertyName); if (result != null && !result.isOK()) return result; if (propertyName.equals(SOURCE_FOLDER)) return validateJavaSourceFolder(getStringProperty(propertyName)); if (propertyName.equals(JAVA_PACKAGE)) return validateJavaPackage(getStringProperty(propertyName)); if (propertyName.equals(CLASS_NAME)) { result = validateJavaClassName(getStringProperty(propertyName)); if (result.isOK()) result = canCreateTypeInClasspath(getStringProperty(CLASS_NAME)); } if (propertyName.equals(SUPERCLASS)) return validateSuperclass(getStringProperty(propertyName)); if (propertyName.equals(MODIFIER_ABSTRACT) || propertyName.equals(MODIFIER_FINAL)) return validateModifier(propertyName, getBooleanProperty(propertyName)); return result; }