All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.frankframework.util.StringUtil Maven / Gradle / Ivy

There is a newer version: 8.3.0
Show newest version
/*
   Copyright 2023-2024 WeAreFrank!

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/
package org.frankframework.util;

import java.util.Collection;
import java.util.ConcurrentModificationException;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import jakarta.annotation.Nonnull;
import jakarta.annotation.Nullable;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.apache.logging.log4j.LogManager;

public class StringUtil {

	private static final Pattern DEFAULT_SPLIT_PATTERN = Pattern.compile("\\s*,+\\s*");
	public static final ToStringStyle OMIT_PASSWORD_FIELDS_STYLE = new FieldNameSensitiveToStringStyle();

	/**
	 * Concatenates two strings, if specified, uses the separator in between two strings.
	 * Does not use any separators if both or one of the strings are empty.
	 *

* Example: *

	 *         String a = "We";
	 *         String b = "Frank";
	 *         String separator = "Are";
	 *         String res = StringUtil.concatStrings(a, separator, b);
	 *         System.out.println(res); // prints "WeAreFrank"
	 *     
*

* @param part1 First string * @param separator Specified separator * @param part2 Second string * @return the concatenated string */ public static String concatStrings(String part1, String separator, String part2) { return concat(separator, part1, part2); } public static String concat(String separator, String... parts) { int i=0; while(i=parts.length) { return null; } StringBuilder result= new StringBuilder(parts[i]); while(++i




© 2015 - 2025 Weber Informatics LLC | Privacy Policy