@Override public IStatus validate(final Object value) { final String s = (String) value; final ICodeGeneratorsRegistry registry = RedhawkCodegenActivator.getCodeGeneratorsRegistry(); final ICodeGeneratorDescriptor[] generators = registry.findCodegenByLanguage(CodegenUtil.JAVA); if (generators.length > 0) { final String version = generators[0].getLanguageVersion(); return JavaConventions.validatePackageName(s, version, version); } return new Status( IStatus.WARNING, "gov.redhawk.codegen.validation", "Unable to validate package name"); }
@Override public IStatus validate(final IValidationContext ctx) { final EObject target = ctx.getTarget(); IStatus retVal = null; if (target instanceof ImplementationSettings) { final ImplementationSettings implSettings = (ImplementationSettings) target; if (implSettings.getGeneratorId().contains("java")) { final ICodeGeneratorsRegistry registry = RedhawkCodegenActivator.getCodeGeneratorsRegistry(); ICodeGeneratorDescriptor generator = registry.findCodegen(implSettings.getGeneratorId()); if (generator == null) { return ctx.createSuccessStatus(); } final String version = registry.findCodegen(implSettings.getGeneratorId()).getLanguageVersion(); IStatus status = null; for (final Property prop : implSettings.getProperties()) { if (JavaGeneratorProperties.PROP_PACKAGE.equals(prop.getId())) { status = JavaConventions.validatePackageName(prop.getValue(), version, version); break; } } if (status == null) { retVal = new EnhancedConstraintStatus( (ConstraintStatus) ctx.createFailureStatus("Invalid Package"), CodegenPackage.Literals.IMPLEMENTATION_SETTINGS__PROPERTIES); } else if (status.getSeverity() >= IStatus.ERROR) { retVal = new EnhancedConstraintStatus( (ConstraintStatus) ctx.createFailureStatus(status.getMessage()), CodegenPackage.Literals.IMPLEMENTATION_SETTINGS__PROPERTIES); } } } return (retVal == null) ? ctx.createSuccessStatus() : retVal; // SUPPRESS CHECKSTYLE AvoidInline }