Java Code Examples for org.springframework.util.StringUtils#trimAllWhitespace()
The following examples show how to use
org.springframework.util.StringUtils#trimAllWhitespace() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultProcessEngineConfiguration.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
private void setProcessEngineName(SpringProcessEngineConfiguration configuration) { String processEngineName = StringUtils.trimAllWhitespace(camundaBpmProperties.getProcessEngineName()); if (!StringUtils.isEmpty(processEngineName) && !processEngineName.contains("-")) { if (camundaBpmProperties.getGenerateUniqueProcessEngineName()) { if (!processEngineName.equals(ProcessEngines.NAME_DEFAULT)) { throw new RuntimeException(String.format("A unique processEngineName cannot be generated " + "if a custom processEngineName is already set: %s", processEngineName)); } processEngineName = CamundaBpmProperties.getUniqueName(camundaBpmProperties.UNIQUE_ENGINE_NAME_PREFIX); } configuration.setProcessEngineName(processEngineName); } else { logger.warn("Ignoring invalid processEngineName='{}' - must not be null, blank or contain hyphen", camundaBpmProperties.getProcessEngineName()); } }
Example 2
Source File: EmailGenerator.java From spring-boot-data-geode with Apache License 2.0 | 5 votes |
public static String generate(String name, String email) { Assert.hasText(name, "Name is required"); if (!StringUtils.hasText(email)) { name = name.toLowerCase(); name = StringUtils.trimAllWhitespace(name); email = String.format("%1$s%2$s", name, AT_EMAIL_ADDRESSES.get(index.nextInt(AT_EMAIL_ADDRESSES.size()))); } return email; }
Example 3
Source File: ConditionPropertySource.java From Milkomeda with MIT License | 5 votes |
private boolean getBoolValue(String range) { range = StringUtils.trimAllWhitespace(range); String[] parts = StringUtils.commaDelimitedListToStringArray(range); if (parts.length != 2) { throw new IllegalArgumentException("Condition.bool set args error."); } return parts[0].equals(parts[1]); }
Example 4
Source File: AbstractModelConverter.java From citrus-admin with Apache License 2.0 | 4 votes |
/** * Build Java code snippet from given model and identifier. * @param model * @param id * @return */ public String getJavaConfig(T model, String id) { StringBuilder builder = new StringBuilder(); String methodName; String beanId = StringUtils.hasText(id) ? id : StringUtils.uncapitalize(model.getClass().getSimpleName()); Matcher matcher = invalidMethodNamePattern.matcher(beanId); if (matcher.find()) { methodName = StringUtils.trimAllWhitespace(beanId.replaceAll("\\.", "").replaceAll("-", "")); builder.append(String.format("%n\t@Bean(\"%s\")%n", beanId)); } else { methodName = beanId; builder.append(String.format("%n\t@Bean%n")); } builder.append(String.format("\tpublic %s %s() {%n", getSourceModelClass().getSimpleName(), methodName)); builder.append(String.format("\t\t%s %s = new %s();%n", getSourceModelClass().getSimpleName(), methodName, getSourceModelClass().getSimpleName())); ReflectionUtils.doWithMethods(model.getClass(), method -> { Object object = ReflectionUtils.invokeMethod(method, model); if (object != null) { Optional<AbstractModelConverter.MethodCallDecorator> decorator = decorators.stream().filter(d -> d.supports(getSetterMethod(method.getName()))).findAny(); if (decorator.isPresent()) { if (decorator.get().allowMethodCall(object)) { builder.append(decorator.get().decorate(methodName, String.format("\t\t%s.%s(%s);%n", methodName, decorator.get().decorateMethodName(), decorator.get().decorateArgument(object)), object)); } } else if (object instanceof String) { builder.append(String.format("\t\t%s.%s(\"%s\");%n", methodName, getSetterMethod(method.getName()), object)); } else { builder.append(String.format("\t\t%s.%s(%s);%n", methodName, getSetterMethod(method.getName()), object)); } } }, method -> (method.getName().startsWith("get") || method.getName().startsWith("is")) && !method.getName().equals("getClass") && !method.getName().equals("getId") && method.getParameterCount() == 0); builder.append(String.format("\t\treturn %s;%n", methodName)); builder.append(String.format("\t}%n")); return builder.toString(); }
Example 5
Source File: JsonCacheDataImporterExporterIntegrationTests.java From spring-boot-data-geode with Apache License 2.0 | 3 votes |
@Test public void exportFromExampleRegionToJson() { try { System.setProperty(EXPORT_ENABLED_PROPERTY, Boolean.TRUE.toString()); StringWriter writer = new StringWriter(); writerSupplier = () -> writer; Region<Long, Customer> example = getExampleRegion(newApplicationContext(withResource("data-example.json"))); assertExampleRegion(example); assertThat(example).isEmpty(); Customer playDoe = Customer.newCustomer(42L, "Play Doe"); example.put(playDoe.getId(), playDoe); assertThat(example).hasSize(1); assertThat(example.get(42L)).isEqualTo(playDoe); closeApplicationContext(); String actualJson = StringUtils.trimAllWhitespace(writer.toString()); String expectedJson = String.format("[{\"@type\":\"%s\",\"id\":42,\"name\":\"PlayDoe\"}]", playDoe.getClass().getName()); assertThat(actualJson).isEqualTo(expectedJson); } finally { System.clearProperty(EXPORT_ENABLED_PROPERTY); } }
Example 6
Source File: ClusterAwareConfiguration.java From spring-boot-data-geode with Apache License 2.0 | 3 votes |
private String[] trim(String[] array) { array = ArrayUtils.nullSafeArray(array, String.class); for (int index = 0; index < array.length; index++) { array[index] = StringUtils.trimAllWhitespace(array[index]); } return array; }
Example 7
Source File: FieldRetrievingFactoryBean.java From spring-analysis-note with MIT License | 2 votes |
/** * Set a fully qualified static field name to retrieve, * e.g. "example.MyExampleClass.MY_EXAMPLE_FIELD". * Convenient alternative to specifying targetClass and targetField. * @see #setTargetClass * @see #setTargetField */ public void setStaticField(String staticField) { this.staticField = StringUtils.trimAllWhitespace(staticField); }
Example 8
Source File: PropertyPathFactoryBean.java From java-technology-stack with MIT License | 2 votes |
/** * Specify the name of a target bean to apply the property path to. * Alternatively, specify a target object directly. * @param targetBeanName the bean name to be looked up in the * containing bean factory (e.g. "testBean") * @see #setTargetObject */ public void setTargetBeanName(String targetBeanName) { this.targetBeanName = StringUtils.trimAllWhitespace(targetBeanName); }
Example 9
Source File: PropertyPathFactoryBean.java From java-technology-stack with MIT License | 2 votes |
/** * Specify the property path to apply to the target. * @param propertyPath the property path, potentially nested * (e.g. "age" or "spouse.age") */ public void setPropertyPath(String propertyPath) { this.propertyPath = StringUtils.trimAllWhitespace(propertyPath); }
Example 10
Source File: PropertyPathFactoryBean.java From java-technology-stack with MIT License | 2 votes |
/** * The bean name of this PropertyPathFactoryBean will be interpreted * as "beanName.property" pattern, if neither "targetObject" nor * "targetBeanName" nor "propertyPath" have been specified. * This allows for concise bean definitions with just an id/name. */ @Override public void setBeanName(String beanName) { this.beanName = StringUtils.trimAllWhitespace(BeanFactoryUtils.originalBeanName(beanName)); }
Example 11
Source File: FieldRetrievingFactoryBean.java From blog_demos with Apache License 2.0 | 2 votes |
/** * Set the name of the field to be retrieved. * Refers to either a static field or a non-static field, * depending on a target object being set. * @see #setTargetClass * @see #setTargetObject */ public void setTargetField(String targetField) { this.targetField = StringUtils.trimAllWhitespace(targetField); }
Example 12
Source File: FieldRetrievingFactoryBean.java From java-technology-stack with MIT License | 2 votes |
/** * Set a fully qualified static field name to retrieve, * e.g. "example.MyExampleClass.MY_EXAMPLE_FIELD". * Convenient alternative to specifying targetClass and targetField. * @see #setTargetClass * @see #setTargetField */ public void setStaticField(String staticField) { this.staticField = StringUtils.trimAllWhitespace(staticField); }
Example 13
Source File: FieldRetrievingFactoryBean.java From java-technology-stack with MIT License | 2 votes |
/** * The bean name of this FieldRetrievingFactoryBean will be interpreted * as "staticField" pattern, if neither "targetClass" nor "targetObject" * nor "targetField" have been specified. * This allows for concise bean definitions with just an id/name. */ @Override public void setBeanName(String beanName) { this.beanName = StringUtils.trimAllWhitespace(BeanFactoryUtils.originalBeanName(beanName)); }
Example 14
Source File: FieldRetrievingFactoryBean.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Set a fully qualified static field name to retrieve, * e.g. "example.MyExampleClass.MY_EXAMPLE_FIELD". * Convenient alternative to specifying targetClass and targetField. * @see #setTargetClass * @see #setTargetField */ public void setStaticField(String staticField) { this.staticField = StringUtils.trimAllWhitespace(staticField); }
Example 15
Source File: FieldRetrievingFactoryBean.java From spring-analysis-note with MIT License | 2 votes |
/** * Set the name of the field to be retrieved. * Refers to either a static field or a non-static field, * depending on a target object being set. * @see #setTargetClass * @see #setTargetObject */ public void setTargetField(@Nullable String targetField) { this.targetField = (targetField != null ? StringUtils.trimAllWhitespace(targetField) : null); }
Example 16
Source File: FieldRetrievingFactoryBean.java From spring4-understanding with Apache License 2.0 | 2 votes |
/** * Set the name of the field to be retrieved. * Refers to either a static field or a non-static field, * depending on a target object being set. * @see #setTargetClass * @see #setTargetObject */ public void setTargetField(String targetField) { this.targetField = StringUtils.trimAllWhitespace(targetField); }
Example 17
Source File: PropertyPathFactoryBean.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Specify the name of a target bean to apply the property path to. * Alternatively, specify a target object directly. * @param targetBeanName the bean name to be looked up in the * containing bean factory (e.g. "testBean") * @see #setTargetObject */ public void setTargetBeanName(String targetBeanName) { this.targetBeanName = StringUtils.trimAllWhitespace(targetBeanName); }
Example 18
Source File: PropertyPathFactoryBean.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Specify the property path to apply to the target. * @param propertyPath the property path, potentially nested * (e.g. "age" or "spouse.age") */ public void setPropertyPath(String propertyPath) { this.propertyPath = StringUtils.trimAllWhitespace(propertyPath); }
Example 19
Source File: FieldRetrievingFactoryBean.java From spring4-understanding with Apache License 2.0 | 2 votes |
/** * The bean name of this FieldRetrievingFactoryBean will be interpreted * as "staticField" pattern, if neither "targetClass" nor "targetObject" * nor "targetField" have been specified. * This allows for concise bean definitions with just an id/name. */ @Override public void setBeanName(String beanName) { this.beanName = StringUtils.trimAllWhitespace(BeanFactoryUtils.originalBeanName(beanName)); }
Example 20
Source File: PropertyPathFactoryBean.java From spring4-understanding with Apache License 2.0 | 2 votes |
/** * Specify the name of a target bean to apply the property path to. * Alternatively, specify a target object directly. * @param targetBeanName the bean name to be looked up in the * containing bean factory (e.g. "testBean") * @see #setTargetObject */ public void setTargetBeanName(String targetBeanName) { this.targetBeanName = StringUtils.trimAllWhitespace(targetBeanName); }