public static class UniqueNameGenerationHelper.NameGenerationOptions extends Object
public int getMaxLength()
public int getStartIndex()
public UnaryOperator<String> getSanitizer()
public BiFunction<String,Integer,String> getInterpolator()
public int getMaxAttempts()
public UniqueNameGenerationHelper.NameGenerationOptions maxLength(int maxLength)
maxLength - Maximum length that is allowed for the name. The generated name is truncated to fit this length.public UniqueNameGenerationHelper.NameGenerationOptions maxAttempts(int maxAttempts)
maxAttempts - Maximum number of generated names that are tried (against getValidityCheck()).public UniqueNameGenerationHelper.NameGenerationOptions startIndex(int startIndex)
startIndex - The initial index used for generating new names. Defaults to 1, so the first generated
name ends on Copy_1.public UniqueNameGenerationHelper.NameGenerationOptions validityCheck(Predicate<String> validityCheck)
validityCheck - A predicate that checks whether a given generated name is allowed, eg. whether a project
with that name exists already. It must return true if the given new name is valid, false
otherwise.public UniqueNameGenerationHelper.NameGenerationOptions sanitizer(UnaryOperator<String> sanitizer)
sanitizer - An operator that takes a generated name and sanitizes it, eg. replaces characters that are not
allowed for that name, such as whitespaces with underscores.public UniqueNameGenerationHelper.NameGenerationOptions interpolator(BiFunction<String,Integer,String> interpolator)
interpolator - Function that receives the name and the current index and creates the derived name with the
index, eg myfile (copy 2).public UniqueNameGenerationHelper.NameGenerationOptions copySuffix(String copySuffix)
MyEntity_Copy_4copySuffix - Suffix added to the original name, eg. .public UniqueNameGenerationHelper.NameGenerationOptions copyWithSpace(String copyName)
MyEntity (Copy 4)copyName - Localized name for 'Copy'.public UniqueNameGenerationHelper.NameGenerationOptions replace(String disallowedCharactersRegex, char replacementCharacter)
disallowedCharactersRegex - Characters that are not allowed in the name and should be replaced.replacementCharacter - Character that replaces the disallowed characters.public static UniqueNameGenerationHelper.NameGenerationOptions create()
Copyright © 2021 XIMA MEDIA GmbH. All rights reserved.