本文整理了Java中org.apache.commons.lang3.StringUtils.stripToNull()
方法的一些代码示例,展示了StringUtils.stripToNull()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StringUtils.stripToNull()
方法的具体详情如下:
包路径:org.apache.commons.lang3.StringUtils
类名称:StringUtils
方法名:stripToNull
[英]Strips whitespace from the start and end of a String returning null if the String is empty ("") after the strip.
This is similar to #trimToNull(String) but removes whitespace. Whitespace is defined by Character#isWhitespace(char).
StringUtils.stripToNull(null) = null
StringUtils.stripToNull("") = null
StringUtils.stripToNull(" ") = null
StringUtils.stripToNull("abc") = "abc"
StringUtils.stripToNull(" abc") = "abc"
StringUtils.stripToNull("abc ") = "abc"
StringUtils.stripToNull(" abc ") = "abc"
StringUtils.stripToNull(" ab c ") = "ab c"
[中]从字符串的开头和结尾删除空格,如果字符串在删除后为空(“”),则返回null。
这类似于#trimToNull(字符串),但删除了空格。空格由字符#isWhitespace(char)定义。
StringUtils.stripToNull(null) = null
StringUtils.stripToNull("") = null
StringUtils.stripToNull(" ") = null
StringUtils.stripToNull("abc") = "abc"
StringUtils.stripToNull(" abc") = "abc"
StringUtils.stripToNull("abc ") = "abc"
StringUtils.stripToNull(" abc ") = "abc"
StringUtils.stripToNull(" ab c ") = "ab c"
代码示例来源:origin: gocd/gocd
private void setPasswordIfNotBlank(String password) {
this.password = stripToNull(password);
this.encryptedPassword = stripToNull(encryptedPassword);
if (this.password == null) {
return;
}
try {
this.encryptedPassword = this.goCipher.encrypt(password);
} catch (Exception e) {
bomb("Password encryption failed. Please verify your cipher key.", e);
}
this.password = null;
}
代码示例来源:origin: gocd/gocd
private void setPasswordIfNotBlank(String password) {
this.password = StringUtils.stripToNull(password);
this.encryptedPassword = StringUtils.stripToNull(encryptedPassword);
if (this.password == null) {
return;
}
try {
this.encryptedPassword = this.goCipher.encrypt(password);
} catch (Exception e) {
bomb("Password encryption failed. Please verify your cipher key.", e);
}
this.password = null;
}
代码示例来源:origin: gocd/gocd
private void setPasswordIfNotBlank(String password) {
this.password = StringUtils.stripToNull(password);
this.encryptedPassword = StringUtils.stripToNull(encryptedPassword);
if (this.password == null) {
return;
}
try {
this.encryptedPassword = this.goCipher.encrypt(password);
} catch (Exception e) {
bomb("Password encryption failed. Please verify your cipher key.", e);
}
this.password = null;
}
代码示例来源:origin: gocd/gocd
private void setPasswordIfNotBlank(String password) {
this.password = StringUtils.stripToNull(password);
this.encryptedPassword = StringUtils.stripToNull(encryptedPassword);
if (this.password == null) {
return;
}
try {
this.encryptedPassword = this.goCipher.encrypt(password);
} catch (Exception e) {
bomb("Password encryption failed. Please verify your cipher key.", e);
}
this.password = null;
}
代码示例来源:origin: gocd/gocd
private void setPasswordIfNotBlank(String password) {
this.password = StringUtils.stripToNull(password);
this.encryptedPassword = StringUtils.stripToNull(encryptedPassword);
if (this.password == null) {
return;
}
try {
this.encryptedPassword = this.goCipher.encrypt(password);
} catch (Exception e) {
bomb("Password encryption failed. Please verify your cipher key.", e);
}
this.password = null;
}
代码示例来源:origin: gocd/gocd
private void setPasswordIfNotBlank(String password) {
this.password = StringUtils.stripToNull(password);
this.encryptedPassword = StringUtils.stripToNull(encryptedPassword);
if (this.password == null) {
return;
}
try {
this.encryptedPassword = this.goCipher.encrypt(password);
} catch (Exception e) {
bomb("Password encryption failed. Please verify your cipher key.", e);
}
this.password = null;
}
代码示例来源:origin: gocd/gocd
private void setPasswordIfNotBlank(String password) {
this.password = StringUtils.stripToNull(password);
this.encryptedPassword = StringUtils.stripToNull(encryptedPassword);
if (this.password == null) {
return;
}
try {
this.encryptedPassword = this.goCipher.encrypt(password);
} catch (Exception e) {
bomb("Password encryption failed. Please verify your cipher key.", e);
}
this.password = null;
}
代码示例来源:origin: gocd/gocd
private String postBackupScriptFile() {
BackupConfig backupConfig = backupConfig();
if (backupConfig != null) {
String postBackupScript = backupConfig.getPostBackupScript();
return StringUtils.stripToNull(postBackupScript);
}
return null;
}
代码示例来源:origin: gocd/gocd
@PostConstruct
public void ensureEncrypted() {
this.userName = StringUtils.stripToNull(this.userName);
setPasswordIfNotBlank(password);
if (encryptedPassword != null) {
setEncryptedPassword(goCipher.maybeReEncryptForPostConstructWithoutExceptions(encryptedPassword));
}
}
代码示例来源:origin: gocd/gocd
@PostConstruct
public void ensureEncrypted() {
this.username = StringUtils.stripToNull(username);
setPasswordIfNotBlank(password);
if (encryptedPassword != null) {
setEncryptedPassword(goCipher.maybeReEncryptForPostConstructWithoutExceptions(encryptedPassword));
}
}
代码示例来源:origin: gocd/gocd
@PostConstruct
public void ensureEncrypted() {
this.userName = StringUtils.stripToNull(this.userName);
setPasswordIfNotBlank(password);
if (encryptedPassword != null) {
setEncryptedPassword(goCipher.maybeReEncryptForPostConstructWithoutExceptions(encryptedPassword));
}
}
代码示例来源:origin: gocd/gocd
@PostConstruct
public void ensureEncrypted() {
this.userName = StringUtils.stripToNull(this.userName);
setPasswordIfNotBlank(password);
if (encryptedPassword != null) {
setEncryptedPassword(goCipher.maybeReEncryptForPostConstructWithoutExceptions(encryptedPassword));
}
}
代码示例来源:origin: gocd/gocd
@PostConstruct
@Override
public void ensureEncrypted() {
this.userName = stripToNull(this.userName);
setPasswordIfNotBlank(password);
if (encryptedPassword != null) {
setEncryptedPassword(goCipher.maybeReEncryptForPostConstructWithoutExceptions(encryptedPassword));
}
}
代码示例来源:origin: gocd/gocd
@PostConstruct
public void ensureEncrypted() {
this.userName = StringUtils.stripToNull(this.userName);
setPasswordIfNotBlank(password);
if (encryptedPassword != null) {
setEncryptedPassword(goCipher.maybeReEncryptForPostConstructWithoutExceptions(encryptedPassword));
}
}
代码示例来源:origin: gocd/gocd
@PostConstruct
@Override
public void ensureEncrypted() {
this.userName = StringUtils.stripToNull(this.userName);
setPasswordIfNotBlank(password);
if (encryptedPassword != null) {
setEncryptedPassword(goCipher.maybeReEncryptForPostConstructWithoutExceptions(encryptedPassword));
}
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testStripToNull_String() {
assertNull(StringUtils.stripToNull(null));
assertNull(StringUtils.stripToNull(""));
assertNull(StringUtils.stripToNull(" "));
assertNull(StringUtils.stripToNull(StringUtilsTest.WHITESPACE));
assertEquals("ab c", StringUtils.stripToNull(" ab c "));
assertEquals(StringUtilsTest.NON_WHITESPACE,
StringUtils.stripToNull(StringUtilsTest.WHITESPACE + StringUtilsTest.NON_WHITESPACE + StringUtilsTest.WHITESPACE));
}
代码示例来源:origin: jamesagnew/hapi-fhir
public void setResourceSource(String resourceSource) throws FailureException {
resourceSource = StringUtils.stripToNull(resourceSource);
if (null == resourceSource) {
this.resourceSource = DEFAULT_RESOURCE_SOURCE;
} else
if (ResourceSource.SPREADSHEET.name().equalsIgnoreCase(resourceSource)) {
this.resourceSource = ResourceSource.SPREADSHEET;
} else
if (ResourceSource.MODEL.name().equalsIgnoreCase(resourceSource)) {
this.resourceSource = ResourceSource.MODEL;
} else {
throw new FailureException("Unknown resource-source option: " + resourceSource);
}
}
代码示例来源:origin: apache/samza
/**
* Set the consumer group from the upstream Event Hubs entity that the consumer is part of. Defaults to the
* <code>$Default</code> group that is initially present in all Event Hubs entities (unless removed)
*
* @param consumerGroup the name of the consumer group upstream
* @return this input descriptor
*/
public EventHubsInputDescriptor<StreamMessageType> withConsumerGroup(String consumerGroup) {
this.consumerGroup = Optional.of(StringUtils.stripToNull(consumerGroup));
return this;
}
代码示例来源:origin: apache/samza
/**
* Group pattern used by directory partitioner for advanced partitioning.
* @param groupPattern group parttern for HDFS consumer inputs.
* @return this system descriptor
*/
public HdfsSystemDescriptor withConsumerGroupPattern(String groupPattern) {
this.consumerGroupPattern = Optional.of(StringUtils.stripToNull(groupPattern));
return this;
}
代码示例来源:origin: apache/samza
/**
* Proxy host to be used for this system.
* @param proxyHost Proxy host
* @return this system descriptor
*/
public KinesisSystemDescriptor withProxyHost(String proxyHost) {
this.proxyHost = Optional.of(StringUtils.stripToNull(proxyHost));
return this;
}
内容来源于网络,如有侵权,请联系作者删除!