本文整理了Java中org.apache.commons.lang3.StringUtils.joinWith()
方法的一些代码示例,展示了StringUtils.joinWith()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StringUtils.joinWith()
方法的具体详情如下:
包路径:org.apache.commons.lang3.StringUtils
类名称:StringUtils
方法名:joinWith
[英]Joins the elements of the provided varargs into a single String containing the provided elements.
No delimiter is added before or after the list. null elements and separator are treated as empty Strings ("").
StringUtils.joinWith(",", {"a", "b"}) = "a,b"
StringUtils.joinWith(",", {"a", "b",""}) = "a,b,"
StringUtils.joinWith(",", {"a", null, "b"}) = "a,,b"
StringUtils.joinWith(null, {"a", "b"}) = "ab"
[中]将提供的varargs的元素联接到包含提供的元素的单个字符串中。
列表前后不添加分隔符。空元素和分隔符被视为空字符串(“”)。
StringUtils.joinWith(",", {"a", "b"}) = "a,b"
StringUtils.joinWith(",", {"a", "b",""}) = "a,b,"
StringUtils.joinWith(",", {"a", null, "b"}) = "a,,b"
StringUtils.joinWith(null, {"a", "b"}) = "ab"
代码示例来源:origin: gocd/gocd
private String calcEtag(Username username, List<GoDashboardPipelineGroup> pipelineGroups, List<GoDashboardEnvironment> environments) {
final String pipelineSegment = pipelineGroups.stream().
map(GoDashboardPipelineGroup::etag).collect(Collectors.joining(SEP_CHAR));
final String environmentSegment = environments.stream().
map(GoDashboardEnvironment::etag).collect(Collectors.joining(SEP_CHAR));
return DigestUtils.md5Hex(StringUtils.joinWith(SEP_CHAR, username.getUsername(), pipelineSegment, environmentSegment));
}
代码示例来源:origin: gocd/gocd
private String calcEtag(Username username, List<GoDashboardPipelineGroup> pipelineGroups, List<GoDashboardEnvironment> environments) {
final String pipelineSegment = pipelineGroups.stream().
map(GoDashboardPipelineGroup::etag).collect(Collectors.joining(SEP_CHAR));
final String environmentSegment = environments.stream().
map(GoDashboardEnvironment::etag).collect(Collectors.joining(SEP_CHAR));
return DigestUtils.md5Hex(StringUtils.joinWith(SEP_CHAR, username.getUsername(), pipelineSegment, environmentSegment));
}
代码示例来源:origin: gocd/gocd
private String calcPipelinesDataEtag(Username username, List<PipelineConfigs> pipelineConfigs) {
final HashMap<String, List<CaseInsensitiveString>> pipelinesDataSegment = new HashMap<>();
for (PipelineConfigs group : pipelineConfigs) {
final List<PipelineConfig> pipelines = group.getPipelines();
if (!pipelines.isEmpty()) {
List<CaseInsensitiveString> pipelineNames = pipelines.stream().map(PipelineConfig::name).collect(Collectors.toList());
pipelinesDataSegment.put(group.getGroup(), pipelineNames);
}
}
return DigestUtils.md5Hex(StringUtils.joinWith("/", username.getUsername(), pipelinesDataSegment));
}
}
代码示例来源:origin: uber-common/jvm-profiler
public static String getSparkEnvAppId() {
// Do not use "org.apache.spark.SparkEnv" directly because the maven shade plugin will convert
// the class name to ja_shaded.org.apache.spark.SparkEnv due to relocation.
String className = org.apache.commons.lang3.StringUtils.joinWith(
".",
"org",
"apache",
"spark",
"SparkEnv");
try {
Object result = ReflectionUtils.executeStaticMethods(
className,
"get.conf.getSparkEnvAppId");
if (result == null) {
return null;
}
return result.toString();
} catch (Throwable e) {
return null;
}
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test(expected = IllegalArgumentException.class)
public void testJoinWithThrowsException() {
StringUtils.joinWith(",", (Object[]) null);
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testJoinWith() {
assertEquals("", StringUtils.joinWith(",")); // empty array
assertEquals("", StringUtils.joinWith(",", (Object[]) NULL_ARRAY_LIST));
assertEquals("null", StringUtils.joinWith(",", NULL_TO_STRING_LIST)); //toString method prints 'null'
assertEquals("a,b,c", StringUtils.joinWith(",", "a", "b", "c"));
assertEquals(",a,", StringUtils.joinWith(",", null, "a", ""));
assertEquals("ab", StringUtils.joinWith(null, "a", "b"));
}
代码示例来源:origin: net.guerlab.spring/guerlab-spring-commons
private static String getMessage(Collection<String> displayMessageList) {
if (CollectionUtil.isEmpty(displayMessageList)) {
return "";
}
return StringUtils.joinWith("\n", displayMessageList.toArray());
}
代码示例来源:origin: net.guerlab/guerlab-spring-commons
private static String getMessage(List<String> displayMessageList) {
if (CollectionUtil.isEmpty(displayMessageList)) {
return "";
}
return StringUtils.joinWith("\n", displayMessageList.toArray());
}
代码示例来源:origin: awhitford/lombok.maven
@Override
protected String getSourcePath() {
return StringUtils.joinWith(File.pathSeparator,
StringUtils.join(this.project.getCompileSourceRoots(), File.pathSeparatorChar),
StringUtils.join(this.project.getTestCompileSourceRoots(), File.pathSeparatorChar)
);
}
代码示例来源:origin: org.projectlombok/lombok-maven-plugin
@Override
protected String getSourcePath() {
return StringUtils.joinWith(File.pathSeparator,
StringUtils.join(this.project.getCompileSourceRoots(), File.pathSeparatorChar),
StringUtils.join(this.project.getTestCompileSourceRoots(), File.pathSeparatorChar)
);
}
代码示例来源:origin: BriData/DBus
private void adapt() {
List<String> wk = new ArrayList<>();
JSONObject ret = new JSONObject();
JSONObject fbData = JSON.parseObject(value);
for(String key : fbData.keySet()) {
if(fbData.get(key) instanceof JSONObject) {
JSONObject subJbValue = ((JSONObject) fbData.get(key));
for(String jbKey : subJbValue.keySet()) {
ret.put(StringUtils.joinWith(".", key, jbKey), subJbValue.get(jbKey));
}
} else {
ret.put(key, fbData.get(key));
}
}
wk.add(ret.toJSONString());
it = wk.iterator();
}
代码示例来源:origin: alien4cloud/alien4cloud
private static void injectSourcePropertiesAsInputs(PaaSNodeTemplate source, Map<String, Interface> interfaces) {
// input name: SOURCE_<propertyName>
injectPropertiesAsInputs(ToscaFunctionConstants.SOURCE, null, source.getTemplate().getProperties(), interfaces,
baseName -> StringUtils.joinWith(AlienUtils.DEFAULT_PREFIX_SEPARATOR, ToscaFunctionConstants.SOURCE, baseName));
}
代码示例来源:origin: alien4cloud/alien4cloud
private static void injectCapabilitiesProperties(NodeTemplate template, Map<String, Interface> interfaces) {
if (template.getCapabilities() == null) {
return;
}
template.getCapabilities().forEach((capabilityName, capability) -> {
// input name: CAPABILITIES_<capabilityName>_<propertyName>
injectPropertiesAsInputs(ToscaFunctionConstants.SELF, capabilityName, capability.getProperties(), interfaces,
baseName -> StringUtils.joinWith(AlienUtils.DEFAULT_PREFIX_SEPARATOR, ToscaFunctionConstants.SELF, CAPABILITIES, capabilityName, baseName));
});
}
代码示例来源:origin: alien4cloud/alien4cloud
private static void injectTargetPropertiesAsInputs(PaaSNodeTemplate target, Map<String, Interface> interfaces) {
// input name: TARGET_<propertyName>
injectPropertiesAsInputs(ToscaFunctionConstants.TARGET, null, target.getTemplate().getProperties(), interfaces,
baseName -> StringUtils.joinWith(AlienUtils.DEFAULT_PREFIX_SEPARATOR, ToscaFunctionConstants.TARGET, baseName));
}
代码示例来源:origin: alien4cloud/alien4cloud
private static void injectTargetedCapabilityProperties(PaaSNodeTemplate target, String capabilityName, Map<String, Interface> interfaces) {
if (target.getTemplate().getCapabilities() != null && target.getTemplate().getCapabilities().containsKey(capabilityName)) {
Capability capability = target.getTemplate().getCapabilities().get(capabilityName);
// input name: TARGET_CAPABILITIES_<capabilityName>_<propertyName>
injectPropertiesAsInputs(ToscaFunctionConstants.TARGET, capabilityName, capability.getProperties(), interfaces, baseName -> StringUtils
.joinWith(AlienUtils.DEFAULT_PREFIX_SEPARATOR, ToscaFunctionConstants.TARGET, CAPABILITIES, capabilityName, baseName));
}
}
代码示例来源:origin: alien4cloud/alien4cloud
baseName -> StringUtils.joinWith(AlienUtils.DEFAULT_PREFIX_SEPARATOR, ToscaFunctionConstants.SELF, baseName));
代码示例来源:origin: alien4cloud/alien4cloud
/**
* Inject node template and capabilities properties as input parameters for all its interfaces operations <br>
* The injected input names are uppercased and is in form:
* <ul>
* <li>{@code SELF_<PROPERTY_NAME>} for node property
* <li>{@code SELF_CAPABILITIES_<CAPABILITY_NAME>_<PROPERTY_NAME>} for capability property
* </ul>
* In case of name conflict, the overriding order is: (--> = overrides)
*
* <pre>
* declared input --> node property input --> capability property input
* </pre>
*
* @param paaSTemplate The {@link PaaSNodeTemplate} to process
*/
public static void processNodeTemplateProperties(PaaSNodeTemplate paaSTemplate) {
NodeTemplate template = paaSTemplate.getTemplate();
// inject nodetemplate properties
if (MapUtils.isNotEmpty(template.getProperties())) {
injectPropertiesAsInputs(ToscaFunctionConstants.SELF, null, template.getProperties(), paaSTemplate.getInterfaces(),
baseName -> StringUtils.joinWith(AlienUtils.DEFAULT_PREFIX_SEPARATOR, ToscaFunctionConstants.SELF, baseName));
}
// inject capabilities properties
injectCapabilitiesProperties(template, paaSTemplate.getInterfaces());
}
内容来源于网络,如有侵权,请联系作者删除!