public static boolean blankAttribute(Element element, String attribute) { return StringUtils.isBlank(element.getAttribute(attribute)); }
public static String getNameOrId(Element element) { String id = element.getAttribute(ATTRIBUTE_ID); String name = element.getAttribute(ATTRIBUTE_NAME); if (StringUtils.isBlank(id)) { if (StringUtils.isBlank(name)) { return ""; } else { return name; } } else { if (!StringUtils.isBlank(name) && !name.equals(id)) { logger.warn("Id (" + id + ") and name (" + name + ") differ for " + elementToString(element)); } return id; } }
public MediaTypeModelProperty(String mimeType, boolean strict) { mediaType = isBlank(mimeType) ? null : MediaType.parse(mimeType); this.strict = strict; }
private Document createAppDocument(ArtifactDeclaration artifact) throws ParserConfigurationException { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); DocumentBuilder docBuilder = factory.newDocumentBuilder(); Document doc = docBuilder.newDocument(); Element mule = doc.createElement(CORE_PREFIX); doc.appendChild(mule); artifact.getCustomConfigurationParameters().forEach(p -> mule.setAttribute(p.getName(), p.getValue().toString())); if (isBlank(mule.getAttribute(XSI_SCHEMA_LOCATION))) { mule.setAttributeNS(XMLNS_W3_URL, XMLNS, CORE_NAMESPACE); mule.setAttributeNS(XSI_W3_URL, XSI_SCHEMA_LOCATION, CORE_NAMESPACE + " " + MULE_SCHEMA_LOCATION); } return doc; }
private Optional<MetadataCacheId> resolveConfigId(DslElementModel<?> elementModel) { // TODO Migrate to Stereotypes when config-ref is part of model Optional<ComponentConfiguration> configuration = elementModel.getConfiguration(); if (configuration.isPresent()) { String configRef = configuration.get().getParameters().get(CONFIG_ATTRIBUTE_NAME); if (!isBlank(configRef)) { return getHashedGlobal(configRef); } } return empty(); }
private void validateNotReservedCharacterInName(ExtensionModel extensionModel, String nameAttributeValue, ProblemsReporter problemsReporter) { try { verifyStringDoesNotContainsReservedCharacters(nameAttributeValue); } catch (IllegalArgumentException e) { problemsReporter .addError(new Problem(extensionModel, format(ILLEGAL_GLOBAL_ELEMENT_NAME_FORMAT_MESSAGE, nameAttributeValue, StringUtils.isBlank(e.getMessage()) ? "" : e.getMessage()))); } }
private static boolean isValidStereotype(StereotypeDefinition stereotypeDefinition, String namespace) { if (isBlank(stereotypeDefinition.getNamespace())) { return true; } return namespace.equals(stereotypeDefinition.getNamespace()) || NAMESPACE.equals(stereotypeDefinition.getNamespace()); }
/** * {@inheritDoc} */ @Override public Optional<ConfigurationProvider> getConfigurationProvider(String configurationProviderName) { checkArgument(!StringUtils.isBlank(configurationProviderName), "cannot get configuration from a blank provider name"); return extensionRegistry.getConfigurationProvider(configurationProviderName); }
Annotation createDocAnnotation(String content) { if (StringUtils.isBlank(content)) { return null; } Annotation annotation = new Annotation(); Documentation doc = new Documentation(); doc.getContent().add(content); annotation.getAppinfoOrDocumentation().add(doc); return annotation; }
@Override public void verify() { if (!handledException) { fail("Handler could not check any exception log because no exception was raised"); } String errorMessage = errors.toString(); if (!StringUtils.isBlank(errorMessage)) { fail(errorMessage); } if (!exceptionLogged && !succeedIfNoLog) { fail("Could not check exception because it was never logged"); } }
private Optional<MetadataCacheId> getHashedGlobal(String name) { if (!isBlank(name)) { return locator.get(Location.builder().globalName(name).build()) .map(global -> getIdForComponentMetadata(global).orElse(null)); } return empty(); }
/** * @return A {@link Map} of default java package names that the extension should export and indicates which * are the classes that makes the package to be exported. */ public Map<String, Collection<String>> getDetailedExportedPackages() { collectDefault(); collectManuallyExportedPackages(); HashMultimap<String, String> exportedPackages = HashMultimap.create(); exportedClasses.stream() .map(clazz -> new Pair<>(packageFinder.packageFor(clazz).orElse(""), clazz)) .filter(pair -> !isBlank(pair.getFirst())) .filter(pair -> filteredPackages.stream().noneMatch(filteredPackage -> pair.getFirst().startsWith(filteredPackage))) .forEach(pair -> exportedPackages.put(pair.getFirst(), pair.getSecond())); return exportedPackages.asMap(); }
/** * Configures the service provider * * @param className service provider class name. Non blank. * @return the same builder instance */ public ServiceFileBuilder withServiceProviderClass(String className) { checkImmutable(); checkArgument(!isBlank(className), "Property value cannot be blank"); serviceProviderClassName = className; return this; }
public ServiceFileBuilder forContract(String contractClassName) { checkImmutable(); checkArgument(!isBlank(contractClassName), "Property value cannot be blank"); this.contractClassName = contractClassName; return this; }
@Override protected DefaultMuleConfiguration createMuleConfiguration() { final DefaultMuleConfiguration configuration = new DefaultMuleConfiguration(true); initializeFromProperties(configuration); configuration.setId(policyName); final String encoding = defaultEncoding; if (!isBlank(encoding)) { configuration.setDefaultEncoding(encoding); } return configuration; } }
@Override protected DefaultMuleConfiguration createMuleConfiguration() { final DefaultMuleConfiguration configuration = new DefaultMuleConfiguration(true); initializeFromProperties(configuration); configuration.setId(appName); final String encoding = defaultEncoding; if (!isBlank(encoding)) { configuration.setDefaultEncoding(encoding); } return configuration; } }
@Stereotype(ReferableOperationStereotypeDefinition.class) public void withFlowReference(@Config DrStrange dr, @Optional @FlowReference String flowRef, @ComponentId String name) { if (!StringUtils.isBlank(flowRef)) { if (!locator.find(Location.builder().globalName(flowRef).build()).isPresent()) { throw new IllegalArgumentException("The referenced flow does not exist in this application"); } } }
private DeprecationModel createDeprecationModel(Deprecated deprecationAnnotation) { return new ImmutableDeprecationModel(deprecationAnnotation.message(), deprecationAnnotation.since(), isBlank(deprecationAnnotation.toRemoveIn()) ? null : deprecationAnnotation.toRemoveIn()); }
/** * {@inheritDoc} */ @Override public void contribute(ExtensionParameter parameter, ParameterDeclarer declarer, ParameterDeclarationContext declarationContext) { getInfrastructureType(parameter.getType()).ifPresent(infrastructureType -> { if (!isBlank(infrastructureType.getName())) { declarer.withModelProperty(new InfrastructureParameterModelProperty(infrastructureType.getSequence())); declarer.withExpressionSupport(NOT_SUPPORTED); getQName(infrastructureType.getName()).ifPresent(declarer::withModelProperty); getDslConfiguration(infrastructureType.getName()).ifPresent(declarer::withDsl); } }); } }
private LazyServiceAssembly(String name, Supplier<ClassLoader> classLoader, Supplier<ServiceProvider> serviceProvider, Class<? extends Service> satisfiedContract) { checkArgument(!isBlank(name), "name cannot be blank"); checkArgument(classLoader != null, "Classloader cannot be null"); checkArgument(serviceProvider != null, "ServiceProvider supplier cannot be null"); checkArgument(satisfiedContract != null, "satisfied contract cannot be null"); this.name = name; this.classLoader = lazy(classLoader); this.serviceProvider = lazy(serviceProvider); this.serviceContract = satisfiedContract; }