### getContentStart() Source: https://commons.apache.org/proper/commons-lang/apidocs/index-all.html Gets the content start text. ```APIDOC ## getContentStart() ### Description Gets the content start text. ### Method Method ### Class org.apache.commons.lang3.builder.StandardToStringStyle ``` ```APIDOC ## getContentStart() ### Description Gets the content start text. ### Method Method ### Class org.apache.commons.lang3.builder.ToStringStyle ``` -------------------------------- ### StandardToStringStyle.getArrayStart() Source: https://commons.apache.org/proper/commons-lang/apidocs/index-all.html Gets the array start text for StandardToStringStyle. ```APIDOC ## getArrayStart() ### Description Gets the array start text. ### Method Method ### Endpoint N/A ### Parameters None ### Request Example None ### Response #### Success Response (200) - **arrayStart** (String) - The array start text. ``` -------------------------------- ### getContentStart Source: https://commons.apache.org/proper/commons-lang/apidocs/src-html/org/apache/commons/lang3/builder/ToStringStyle.html Gets the content start text. ```APIDOC ## getContentStart ### Description Gets the content start text. ### Method Signature protected String getContentStart() ### Returns the current content start text. ``` -------------------------------- ### getArrayStart Source: https://commons.apache.org/proper/commons-lang/apidocs/src-html/org/apache/commons/lang3/builder/ToStringStyle.html Gets the array start text. ```APIDOC ## getArrayStart ### Description Gets the array start text. ### Method Signature protected String getArrayStart() ### Returns the current array start text. ``` -------------------------------- ### getSizeStartText Source: https://commons.apache.org/proper/commons-lang/apidocs/src-html/org/apache/commons/lang3/builder/ToStringStyle.html Gets the start text for size output. ```APIDOC ## getSizeStartText ### Description Gets the start text to output when a {@link Collection}, {@link Map} or array size is output. This is output before the size value. ### Method Signature protected String getSizeStartText() ### Returns the current start of size text. ``` -------------------------------- ### MultiBackgroundInitializer Usage Example Source: https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/concurrent/package-summary.html Shows how to add multiple BackgroundInitializer instances to a MultiBackgroundInitializer and start them concurrently. The 'url' key is used to retrieve the result from the URLLoader. ```java MultiBackgroundInitializer initializer = new MultiBackgroundInitializer(); initializer.addInitializer("url", new URLLoader(url)); ``` -------------------------------- ### start() Source: https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/concurrent/BackgroundInitializer.html Starts the background initialization process. This method can only be successfully called once. ```APIDOC ## start() ### Description Starts the background initialization. With this method the initializer becomes active and invokes the `AbstractConcurrentInitializer.initialize()` method in a background task. A `BackgroundInitializer` can be started exactly once. The return value of this method determines whether the start was successful: only the first invocation of this method returns **true** , following invocations will return **false** . ### Method public boolean start() ### Returns - **boolean**: a flag whether the initializer could be started successfully. ``` -------------------------------- ### start Source: https://commons.apache.org/proper/commons-lang/apidocs/src-html/org/apache/commons/lang3/concurrent/BackgroundInitializer.html Starts the background initialization. This method can be called exactly once. The return value indicates whether the start was successful. ```APIDOC ## start ### Description Starts the background initialization. With this method the initializer becomes active and invokes the {@link #initialize()} method in a background task. A {@link BackgroundInitializer} can be started exactly once. The return value of this method determines whether the start was successful: only the first invocation of this method returns true, following invocations will return false. ### Method public synchronized boolean start() ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **boolean** - A flag whether the initializer could be started successfully. #### Response Example None ``` -------------------------------- ### Using BackgroundInitializer to Load URL Content Source: https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/concurrent/package-summary.html Demonstrates how to create, start, and retrieve results from a URLLoader instance. Includes error handling for ConcurrentException during the get() call. ```java URL url = new URL("http://www.application-home-page.com/"); URLLoader loader = new URLLoader(url); loader.start(); // this starts the background initialization // do other stuff ... // now obtain the content of the URL String content; try { content = loader.get(); // this may block } catch (ConcurrentException cex) { content = "Error when loading URL " + url; } // display content ``` -------------------------------- ### Basic Usage of BackgroundInitializer Source: https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/concurrent/BackgroundInitializer.html Demonstrates the basic usage pattern of a concrete BackgroundInitializer subclass. After creating an instance and calling start(), other tasks can be performed while initialization runs in a parallel thread. The result can be accessed using get(), which blocks if initialization is not yet complete. ```java MyBackgroundInitializer initializer = new MyBackgroundInitializer(); initializer.start(); // Now do some other things. Initialization runs in a parallel thread ... // Wait for the end of initialization and access the result object Object result = initializer.get(); ``` -------------------------------- ### start Source: https://commons.apache.org/proper/commons-lang/apidocs/src-html/org/apache/commons/lang3/concurrent/BackgroundInitializer.Builder.html Starts the background initialization. This method invokes the initialize() method in a background task. A BackgroundInitializer can be started exactly once. The return value of this method determines whether the start was successful: only the first invocation of this method returns true, following invocations will return false. ```APIDOC ## start ### Description Starts the background initialization. With this method the initializer becomes active and invokes the {@link #initialize()} method in a background task. A {@link BackgroundInitializer} can be started exactly once. The return value of this method determines whether the start was successful: only the first invocation of this method returns true, following invocations will return false. ### Method public synchronized boolean start() ### Returns - **boolean** - a flag whether the initializer could be started successfully. ``` -------------------------------- ### Get Elapsed Time in Milliseconds Source: https://commons.apache.org/proper/commons-lang/apidocs/src-html/org/apache/commons/lang3/time/StopWatch.html Gets the total elapsed time in milliseconds. This is the time between the start and the current moment if running, or between start and stop if stopped. ```APIDOC ## getTime ### Description Gets the time on this StopWatch. This is either the time between the start and the moment this method is called, or the amount of time between start and stop. ### Method public long getTime() ### Returns long - the time in milliseconds. ### See Also {@link #getDuration()} ``` -------------------------------- ### getFuture() Source: https://commons.apache.org/proper/commons-lang/apidocs/src-html/org/apache/commons/lang3/concurrent/BackgroundInitializer.html Gets the Future object that was created when start() was called. Therefore this method can only be called after start(). ```APIDOC ## getFuture() ### Description Gets the {@link Future} object that was created when {@link #start()} was called. Therefore this method can only be called after {@code start()}. ### Method `public synchronized Future getFuture()` ### Parameters None ### Response #### Success Response - **Future** - the {@link Future} object wrapped by this initializer. #### Throws - **IllegalStateException** - if {@link #start()} has not been called. ``` -------------------------------- ### Create and Install BasicThreadFactory Source: https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/concurrent/BasicThreadFactory.html Demonstrates how to create a BasicThreadFactory with custom naming, daemon status, and priority, and then install it in an ExecutorService. ```java // Create a factory that produces daemon threads with a naming pattern and // a priority BasicThreadFactory factory = new BasicThreadFactory.Builder() .namingPattern("workerthread-%d") .daemon(true) .priority(Thread.MAX_PRIORITY) .build(); // Create an executor service for single-threaded execution ExecutorService exec = Executors.newSingleThreadExecutor(factory); ``` -------------------------------- ### Example Builder Implementation Source: https://commons.apache.org/proper/commons-lang/apidocs/src-html/org/apache/commons/lang3/builder/Builder.html An example demonstrating how to implement the Builder interface for constructing a Font object. ```APIDOC ## Example Builder Implementation ### Description This example shows a `FontBuilder` class that implements the `Builder` interface. It demonstrates how to configure a `Font` object through chained method calls and finally build the `Font` instance using the `build()` method. ### Code Example ```java class FontBuilder implements Builder { private Font font; public FontBuilder(String fontName) { this.font = new Font(fontName, Font.PLAIN, 12); } public FontBuilder bold() { this.font = this.font.deriveFont(Font.BOLD); return this; // Reference returned so calls can be chained } public FontBuilder size(float pointSize) { this.font = this.font.deriveFont(pointSize); return this; // Reference returned so calls can be chained } // Other Font construction methods public Font build() { return this.font; } } ``` ### Example Builder Usage ```java Font bold14ptSansSerifFont = new FontBuilder(Font.SANS_SERIF).bold() .size(14.0f) .build(); ``` ``` -------------------------------- ### getStartInstant Source: https://commons.apache.org/proper/commons-lang/apidocs/src-html/org/apache/commons/lang3/time/StopWatch.html Gets the Instant this StopWatch was started. ```APIDOC ## getStartInstant ### Description Gets the Instant this StopWatch was started, between the current time and midnight, January 1, 1970 UTC. ### Method public Instant getStartInstant() ### Returns The Instant this StopWatch was started, between the current time and midnight, January 1, 1970 UTC. @throws IllegalStateException if this StopWatch has not been started. @since 3.16.0 ``` -------------------------------- ### MultiBackgroundInitializer Usage Example Source: https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/concurrent/MultiBackgroundInitializer.html Demonstrates the typical usage scenario for MultiBackgroundInitializer, including adding initializers and retrieving results. ```APIDOC ## MultiBackgroundInitializer ### Description A specialized `BackgroundInitializer` implementation that can deal with multiple background initialization tasks. This class manages an arbitrary number of `BackgroundInitializer` objects, executes them, and waits until they are completely initialized. This is useful for applications that have to perform multiple initialization tasks that can run in parallel. ### Usage 1. Create a new instance of `MultiBackgroundInitializer`. Optionally pass in a pre-configured `ExecutorService`. 2. Create specialized `BackgroundInitializer` objects for the initialization tasks and add them using `addInitializer(String, BackgroundInitializer)`. 3. Call `BackgroundInitializer.start()` after all initializers have been added. 4. Call `BackgroundInitializer.get()` to access the result objects and exception information. ### Key Methods - `addInitializer(String name, BackgroundInitializer initializer)`: Adds a `BackgroundInitializer` to be managed. - `start()`: Starts the background initialization process for all added initializers. - `get()`: Retrieves the results of all background initializations. ### ExecutorService Management - If no external `ExecutorService` is provided, `MultiBackgroundInitializer` creates and destroys a temporary one. - An external `ExecutorService` can be provided via the constructor or `setExternalExecutor(ExecutorService)`. - **Important:** When using an external `ExecutorService`, ensure it has enough threads to avoid deadlocks. ``` -------------------------------- ### Get Substring from Start Index Source: https://commons.apache.org/proper/commons-lang/apidocs/src-html/org/apache/commons/lang3/StringUtils.html Extracts a substring from the specified start position. Handles negative start indices by counting from the end of the string. Returns an empty string if the start position is beyond the string length. ```java public static String substring(final String str, int start) { if (str == null) { return null; } // handle negatives, which means last n characters if (start < 0) { start = str.length() + start; // remember start is negative } if (start < 0) { start = 0; } if (start > str.length()) { return EMPTY; } return str.substring(start); } ``` -------------------------------- ### BackgroundInitializer Usage Example Source: https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/concurrent/BackgroundInitializer.html Demonstrates how to use a concrete subclass of BackgroundInitializer to perform background initialization and retrieve the result. ```APIDOC ## BackgroundInitializer Usage ### Description This example shows the typical usage pattern for `BackgroundInitializer`. A concrete subclass is instantiated, its `start()` method is called to begin the background initialization, and then `get()` is used to retrieve the result, blocking if necessary. ### Usage Pattern ```java // Assume MyBackgroundInitializer is a concrete subclass of BackgroundInitializer MyBackgroundInitializer initializer = new MyBackgroundInitializer(); initializer.start(); // Starts the background initialization // Application can perform other tasks here while initialization runs in parallel ... // When the result is needed, call get(). This will block if initialization is not yet complete. Object result = initializer.get(); ``` ### Key Methods - `start()`: Initiates the background initialization process. - `get()`: Returns the initialized object. Blocks until initialization is complete if it hasn't finished yet. ``` -------------------------------- ### BackgroundInitializer.Builder.get Source: https://commons.apache.org/proper/commons-lang/apidocs/index-all.html Gets a new instance of `BackgroundInitializer`. ```APIDOC ## BackgroundInitializer.Builder.get ### Description Gets a new instance of `BackgroundInitializer`. ### Method Instance ### Class org.apache.commons.lang3.concurrent.BackgroundInitializer.Builder ``` -------------------------------- ### Get Start Time (Deprecated) Source: https://commons.apache.org/proper/commons-lang/apidocs/src-html/org/apache/commons/lang3/time/StopWatch.html Retrieves the time in milliseconds when the StopWatch was started. This method is deprecated and users should prefer `getStartInstant()`. ```APIDOC ## getStartTime ### Description Gets the time this StopWatch was started in milliseconds, between the current time and midnight, January 1, 1970 UTC. ### Method public long getStartTime() ### Returns long - the time this StopWatch was started in milliseconds. ### Throws IllegalStateException - if this StopWatch has not been started. ### Since 2.4 ### Deprecated Use {@link #getStartInstant()}. ``` -------------------------------- ### Basic Tokenization Examples Source: https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/text/StrTokenizer.html Illustrates basic tokenization with different inputs and default CSV processing. Shows how quoted text is handled. ```java "a,b,c" - Three tokens "a","b","c" (comma delimiter) ``` ```java " a, b , c " - Three tokens "a","b","c" (default CSV processing trims whitespace) ``` ```java "a, ", b ,", c" - Three tokens "a, " , " b ", ", c" (quoted text untouched) ``` -------------------------------- ### getTime() Source: https://commons.apache.org/proper/commons-lang/apidocs/src-html/org/apache/commons/lang3/time/StopWatch.Split.html Gets the time on this StopWatch. This is either the time between the start and the moment this method is called, or the amount of time between start and stop. ```APIDOC ## getTime() ### Description Gets the time on this StopWatch. This is either the time between the start and the moment this method is called, or the amount of time between start and stop. ### @return long - the time in milliseconds. ### @see #getDuration() ``` -------------------------------- ### BackgroundInitializer.get Source: https://commons.apache.org/proper/commons-lang/apidocs/index-all.html Gets the result of the background initialization. ```APIDOC ## BackgroundInitializer.get ### Description Gets the result of the background initialization. ### Method Instance ### Class org.apache.commons.lang3.concurrent.BackgroundInitializer ``` -------------------------------- ### setUpToClass Source: https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/builder/ReflectionToStringBuilder.html Specifies the superclass up to which fields should be included in the string representation. This is useful for limiting the scope of the reflection. ```APIDOC ## setUpToClass ### Description Sets the last super class to stop appending fields for. ### Method public void setUpToClass(Class clazz) ### Parameters #### Path Parameters - **clazz** (Class) - Required - The last super class to stop appending fields for. ``` -------------------------------- ### CallableBackgroundInitializer Usage Example Source: https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/concurrent/CallableBackgroundInitializer.html Demonstrates a typical usage pattern for CallableBackgroundInitializer. ```APIDOC ## Usage Example ```java // a Callable that performs a complex computation Callable computationCallable = new MyComputationCallable(); // setup the background initializer CallableBackgroundInitializer initializer = new CallableBackgroundInitializer(computationCallable); initializer.start(); // Now do some other things. Initialization runs in a parallel thread ... // Wait for the end of initialization and access the result Integer result = initializer.get(); ``` ``` -------------------------------- ### prependIfMissing(CharSequence, CharSequence) Source: https://commons.apache.org/proper/commons-lang/apidocs/src-html/org/apache/commons/lang3/Strings.html Prepends a prefix to the start of a string if the string does not already start with the prefix. Handles null inputs and provides case-sensitive examples. ```APIDOC ## prependIfMissing(CharSequence, CharSequence) ### Description Prepends the prefix to the start of the string if the string does not already start with any of the prefixes. Handles null inputs and provides case-sensitive examples. Case-sensitive examples: Strings.CS.prependIfMissing(null, null) = null Strings.CS.prependIfMissing("abc", null) = "abc" Strings.CS.prependIfMissing("", "xyz") = "xyz" Strings.CS.prependIfMissing("abc", "xyz") = "xyzabc" Strings.CS.prependIfMissing("xyzabc", "xyz") = "xyzabc" Strings.CS.prependIfMissing("XYZabc", "xyz") = "xyzXYZabc" Case-insensitive examples: Strings.CI.prependIfMissing(null, null) = null Strings.CI.prependIfMissing("abc", null) = "abc" Strings.CI.prependIfMissing("", "xyz") = "xyz" Strings.CI.prependIfMissing("abc", "xyz") = "xyzabc" ### Parameters #### Path Parameters - **str** (CharSequence) - the String to check, may be null - **prefix** (CharSequence) - the prefix to check for and prepend, may be null ### Returns - **CharSequence** - the {@code CharSequence}, {@code null} if null input ``` -------------------------------- ### Case-Sensitive Starts With Any Check Source: https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/Strings.html Tests if a CharSequence starts with any of the provided prefixes using case-sensitive comparison. Includes examples with nulls and empty strings in prefixes. ```java Strings.CS.startsWithAny(null, null) = false Strings.CS.startsWithAny(null, new String[] {"abc"}) = false Strings.CS.startsWithAny("abcxyz", null) = false Strings.CS.startsWithAny("abcxyz", new String[] {""}) = true Strings.CS.startsWithAny("abcxyz", new String[] {"abc"}) = true Strings.CS.startsWithAny("abcxyz", new String[] {null, "xyz", "abc"}) = true Strings.CS.startsWithAny("abcxyz", null, "xyz", "ABCX") = false Strings.CS.startsWithAny("ABCXYZ", null, "xyz", "abc") = false ``` -------------------------------- ### Example FontBuilder Implementation Source: https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/builder/Builder.html Demonstrates a concrete implementation of the Builder interface for constructing Font objects. It includes methods for chaining configurations like setting bold and size. ```java class FontBuilder implements Builder { private Font font; public FontBuilder(String fontName) { this.font = new Font(fontName, Font.PLAIN, 12); } public FontBuilder bold() { this.font = this.font.deriveFont(Font.BOLD); return this; // Reference returned so calls can be chained } public FontBuilder size(float pointSize) { this.font = this.font.deriveFont(pointSize); return this; // Reference returned so calls can be chained } // Other Font construction methods public Font build() { return this.font; } } ``` -------------------------------- ### getVariablePrefixMatcher() Source: https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/text/StrSubstitutor.html Gets the matcher for the variable prefix, which identifies the start of a variable. ```APIDOC ## getVariablePrefixMatcher ### Description Gets the variable prefix matcher currently in use. The variable prefix is the character or characters that identify the start of a variable. This prefix is expressed in terms of a matcher allowing advanced prefix matches. ### Method Signature public StrMatcher getVariablePrefixMatcher() ### Returns the prefix matcher in use. ``` -------------------------------- ### Basic Usage of CallableBackgroundInitializer Source: https://commons.apache.org/proper/commons-lang/apidocs/src-html/org/apache/commons/lang3/concurrent/CallableBackgroundInitializer.html Demonstrates a typical usage pattern: creating an initializer with a Callable, starting the background execution, and later retrieving the result. ```java Callable computationCallable = new MyComputationCallable(); CallableBackgroundInitializer initializer = new CallableBackgroundInitializer(computationCallable); initializer.start(); // Now do some other things. Initialization runs in a parallel thread ... // Wait for the end of initialization and access the result Integer result = initializer.get(); ``` -------------------------------- ### Get Substring with Start and End Indices Source: https://commons.apache.org/proper/commons-lang/apidocs/src-html/org/apache/commons/lang3/StringUtils.html Extracts a substring between the specified start and end indices. Handles negative indices by counting from the end of the string. Returns an empty string if the start index is greater than the end index. ```java public static String substring(final String str, int start, int end) { if (str == null) { return null; } // handle negatives if (end < 0) { end = str.length() + end; // remember end is negative } if (start < 0) { start = str.length() + start; // remember start is negative } // check length next if (end > str.length()) { end = str.length(); } // if start is greater than end, return "" if (start > end) { return EMPTY; } if (start < 0) { start = 0; } if (end < 0) { end = 0; } return str.substring(start, end); } ``` -------------------------------- ### StringUtils lastIndexOfIgnoreCase (with start position) Example Source: https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/StringUtils.html Performs a case-insensitive search for the last occurrence of a CharSequence within another CharSequence, starting the search from a specified position backwards. Handles null inputs and negative start positions. ```java StringUtils.lastIndexOfIgnoreCase(null, *, *) = -1 StringUtils.lastIndexOfIgnoreCase(*, null, *) = -1 StringUtils.lastIndexOfIgnoreCase("aabaabaa", "A", 8) = 7 StringUtils.lastIndexOfIgnoreCase("aabaabaa", "B", 8) = 5 StringUtils.lastIndexOfIgnoreCase("aabaabaa", "AB", 8) = 4 StringUtils.lastIndexOfIgnoreCase("aabaabaa", "B", 9) = 5 StringUtils.lastIndexOfIgnoreCase("aabaabaa", "B", -1) = -1 StringUtils.lastIndexOfIgnoreCase("aabaabaa", "A", 0) = 0 StringUtils.lastIndexOfIgnoreCase("aabaabaa", "B", 0) = -1 ``` -------------------------------- ### MultiBackgroundInitializer Usage Source: https://commons.apache.org/proper/commons-lang/apidocs/src-html/org/apache/commons/lang3/concurrent/MultiBackgroundInitializer.html Demonstrates the typical usage scenario for MultiBackgroundInitializer, including adding initializers, starting the process, and retrieving results. ```APIDOC ## MultiBackgroundInitializer Usage ### Description This outlines the standard workflow for using the `MultiBackgroundInitializer` class to manage and execute multiple background initialization tasks concurrently. ### Steps: 1. Create a new instance of `MultiBackgroundInitializer`. You can optionally provide an `ExecutorService` or let the class manage one internally. 2. Add individual `BackgroundInitializer` instances for each task using the `addInitializer(String name, BackgroundInitializer initializer)` method. 3. Call the `start()` method to begin the background initialization process. 4. Once initialization is complete, call the `get()` method to retrieve an object that provides access to all results and any exceptions that occurred during initialization. ### Example Scenario: ```java // 1. Create an instance (letting it manage its own ExecutorService) MultiBackgroundInitializer initializer = new MultiBackgroundInitializer(); // 2. Add initializers for different tasks initializer.addInitializer("task1", new MyTask1Initializer()); initializer.addInitializer("task2", new MyTask2Initializer()); // 3. Start the initialization process try { initializer.start(); // Wait for completion (implicitly handled by get() or can be done explicitly) // 4. Get the results ConcurrentInitializer.InitializationResults results = initializer.get(); MyResultType1 result1 = (MyResultType1) results.getResult("task1"); MyResultType2 result2 = (MyResultType2) results.getResult("task2"); // Use the results... } catch (ConcurrentException e) { // Handle exceptions that occurred during initialization // e.getInitializerMessage() provides details about which initializer failed // e.getCause() provides the underlying exception } ``` ### Notes: - If an external `ExecutorService` is provided, ensure it has enough threads to avoid deadlocks. A single-threaded executor can lead to the main task waiting indefinitely. - The `get()` method will block until all initializers have completed or an exception occurs. ``` -------------------------------- ### Methods Source: https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/concurrent/MultiBackgroundInitializer.html Methods available for managing background initializers. ```APIDOC ## addInitializer(String name, BackgroundInitializer backgroundInitializer) ### Description Adds a new `BackgroundInitializer` to this object. When this `MultiBackgroundInitializer` is started, the given initializer will be processed. This method must not be called after `BackgroundInitializer.start()` has been invoked. ### Method Signature `void addInitializer(String name, BackgroundInitializer backgroundInitializer)` ### Parameters * `name` (String) - the name of the initializer (must not be **null**). * `backgroundInitializer` (BackgroundInitializer) - the `BackgroundInitializer` to add (must not be **null**). ### Throws * `NullPointerException` - if either `name` or `backgroundInitializer` is `null`. * `IllegalStateException` - if `start()` has already been called. ``` ```APIDOC ## close() ### Description Calls the closer of all child `BackgroundInitializer` objects. ### Method Signature `void close()` ### Overrides `close` in class `AbstractConcurrentInitializer` ### Throws * `ConcurrentException` - throws an `ConcurrentException` that will have all other exceptions as suppressed exceptions. `ConcurrentException` thrown by children will be unwrapped. ### Since 3.14.0 ``` ```APIDOC ## getTaskCount() ### Description Gets the number of tasks needed for executing all child `BackgroundInitializer` objects in parallel. This implementation sums up the required tasks for all child initializers (which is necessary if one of the child initializers is itself a `MultiBackgroundInitializer`). Then it adds 1 for the control task that waits for the completion of the children. ### Method Signature `protected int getTaskCount()` ### Overrides `getTaskCount` in class `BackgroundInitializer` ### Returns the number of tasks required for background processing. ``` ```APIDOC ## initialize() ### Description Creates the results object. This implementation starts all child `BackgroundInitializer` objects. Then it collects their results and creates a `MultiBackgroundInitializer.MultiBackgroundInitializerResults` object with this data. If a child initializer throws a checked exception, it is added to the results object. Unchecked exceptions are propagated. ### Method Signature `protected MultiBackgroundInitializer.MultiBackgroundInitializerResults initialize()` ### Overrides `initialize` in class `AbstractConcurrentInitializer` ### Returns the results object. ### Throws * `Exception` - if an error occurs. ``` ```APIDOC ## isInitialized() ### Description Tests whether this all child `BackgroundInitializer` objects are initialized. Once initialized, always returns true. ### Method Signature `public boolean isInitialized()` ### Overrides `isInitialized` in class `BackgroundInitializer` ### Returns Whether all child `BackgroundInitializer` objects instance are initialized. Once initialized, always returns true. If there are no child `BackgroundInitializer` objects return false. ### Since 3.14.0 ``` -------------------------------- ### getSummaryObjectStartText() Source: https://commons.apache.org/proper/commons-lang/apidocs/index-all.html Gets the start text to output when an Object is output in summary mode. ```APIDOC ## getSummaryObjectStartText() ### Description Gets the start text to output when an `Object` is output in summary mode. ### Method Method ### Class org.apache.commons.lang3.builder.StandardToStringStyle, org.apache.commons.lang3.builder.ToStringStyle ``` -------------------------------- ### prependIfMissing(CharSequence, CharSequence, CharSequence...) Source: https://commons.apache.org/proper/commons-lang/apidocs/src-html/org/apache/commons/lang3/Strings.html Prepends a prefix to the start of a string if the string does not already start with any of the provided prefixes. Handles null inputs and provides case-sensitive examples. ```APIDOC ## prependIfMissing(CharSequence, CharSequence, CharSequence...) ### Description Prepends a prefix to the start of a string if the string does not already start with any of the provided prefixes. Handles null inputs and provides case-sensitive examples. Case-sensitive examples: Strings.CS.prependIfMissing(null, null, null) = null Strings.CS.prependIfMissing("abc", null, null) = "abc" Strings.CS.prependIfMissing("", "xyz", null) = "xyz" Strings.CS.prependIfMissing("abc", "xyz", new CharSequence[]{null}) = "xyzabc" Strings.CS.prependIfMissing("abc", "xyz", "") = "abc" Strings.CS.prependIfMissing("abc", "xyz", "mno") = "xyzabc" Strings.CS.prependIfMissing("xyzabc", "xyz", "mno") = "xyzabc" Strings.CS.prependIfMissing("mnoabc", "xyz", "mno") = "mnoabc" Strings.CS.prependIfMissing("XYZabc", "xyz", "mno") = "xyzXYZabc" Strings.CS.prependIfMissing("MNOabc", "xyz", "mno") = "xyzMNOabc" ### Parameters #### Path Parameters - **str** (CharSequence) - the String to check, may be null - **prefix** (CharSequence) - the prefix to check for and prepend, may be null - **prefixes** (CharSequence...) - the prefixes to check for and prepend, may be null ### Returns - **CharSequence** - the {@code CharSequence}, {@code null} if null input ``` -------------------------------- ### getSplitNanoTime() Source: https://commons.apache.org/proper/commons-lang/apidocs/src-html/org/apache/commons/lang3/time/StopWatch.Split.html Gets the split time in nanoseconds. This is the time elapsed from the start until the last split. ```APIDOC ## getSplitNanoTime() ### Description Gets the split time in nanoseconds. This is the time between start and latest split. ### Method public long getSplitNanoTime() ### Returns long - the split time in nanoseconds. ### Throws IllegalStateException - if this StopWatch has not yet been split. ``` -------------------------------- ### Example Usage of EventListenerSupport Source: https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/event/EventListenerSupport.html Demonstrates how to use EventListenerSupport to manage ActionListener instances. This example shows the creation of an EventListenerSupport object and how to fire an ActionEvent to all registered listeners. ```java public class MyActionEventSource { private EventListenerSupport actionListeners = EventListenerSupport.create(ActionListener.class); public void someMethodThatFiresAction() { ActionEvent e = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "something"); actionListeners.fire().actionPerformed(e); } } ``` -------------------------------- ### substring(String str, int start) Source: https://commons.apache.org/proper/commons-lang/apidocs/src-html/org/apache/commons/lang3/StringUtils.html Gets a substring from the specified String avoiding exceptions. A negative start position can be used to start/end n characters from the end of the String. The returned substring starts with the character in the start position and ends at the end of the String. All position counting is zero-based. Negative start positions can be used to specify offsets relative to the end of the String. ```APIDOC ## substring(String str, int start) ### Description Gets a substring from the specified String avoiding exceptions. A negative start position can be used to start/end n characters from the end of the String. The returned substring starts with the character in the start position and ends at the end of the String. All position counting is zero-based. Negative start positions can be used to specify offsets relative to the end of the String. ### Method public static String substring(final String str, int start) ### Parameters #### Path Parameters - **str** (String) - The String to get the substring from, may be null. - **start** (int) - The position to start from, negative means count back from the end of the String by this many characters. ### Response #### Success Response (200) - **substring** (String) - substring from start position, {@code null} if null String input. ### Examples ```java StringUtils.substring(null, *) = null StringUtils.substring("", 0) = "" StringUtils.substring("abc", 0) = "abc" StringUtils.substring("abc", 2) = "c" StringUtils.substring("abc", 4) = "" StringUtils.substring("abc", -2) = "bc" StringUtils.substring("abc", -4) = "abc" ``` ``` -------------------------------- ### AtomicInitializer Construction Source: https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/concurrent/AtomicInitializer.html Demonstrates how to construct a new AtomicInitializer instance. ```APIDOC ## Constructor ### Description Constructs a new instance of `AtomicInitializer`. ### Signature `AtomicInitializer()` ``` -------------------------------- ### getSplitDuration() Source: https://commons.apache.org/proper/commons-lang/apidocs/src-html/org/apache/commons/lang3/time/StopWatch.Split.html Gets the split Duration on this StopWatch. This is the duration between the start time and the most recent split time. ```APIDOC ## getSplitDuration() ### Description Gets the split Duration on this StopWatch. This is the Duration between start and latest split. ### Method public Duration getSplitDuration() ### Returns Duration - the split Duration. ### Throws IllegalStateException - if this StopWatch has not yet been split. ``` -------------------------------- ### Basic Background Initialization Usage Source: https://commons.apache.org/proper/commons-lang/apidocs/src-html/org/apache/commons/lang3/concurrent/BackgroundInitializer.Builder.html Demonstrates the basic usage of BackgroundInitializer. Start the initializer in a background thread and later retrieve the result, blocking if necessary. ```java MyBackgroundInitializer initializer = new MyBackgroundInitializer(); initializer.start(); // Now do some other things. Initialization runs in a parallel thread ... // Wait for the end of initialization and access the result object Object result = initializer.get(); ``` -------------------------------- ### getDuration() Source: https://commons.apache.org/proper/commons-lang/apidocs/src-html/org/apache/commons/lang3/time/StopWatch.Split.html Gets the Duration on this StopWatch. This represents the time elapsed since the StopWatch was started or resumed. ```APIDOC ## getDuration() ### Description Gets the Duration on this StopWatch. This is either the Duration between the start and the moment this method is called, or the Duration between start and stop. ### Method public Duration getDuration() ### Returns Duration - the Duration. ``` -------------------------------- ### DiffResult getRight() Example Source: https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/builder/DiffResult.html Gets the right object that was compared. This is the object that was compared against the left object. ```java public T getRight() Gets the object the left object has been compared to. Returns: the right object of the diff Since: 3.10 ``` -------------------------------- ### BackgroundInitializer.builder() Source: https://commons.apache.org/proper/commons-lang/apidocs/src-html/org/apache/commons/lang3/concurrent/BackgroundInitializer.html Creates a new builder. ```APIDOC ## builder() ### Description Creates a new builder. ### Method Signature `public static Builder, T> builder()` ### Returns * a new builder. ### Since 3.14.0 ``` -------------------------------- ### DiffResult getLeft() Example Source: https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/builder/DiffResult.html Gets the left object that was compared. This is the object against which the right object was compared. ```java public T getLeft() Gets the object the right object has been compared to. Returns: the left object of the diff Since: 3.10 ``` -------------------------------- ### setUpToClass Source: https://commons.apache.org/proper/commons-lang/apidocs/src-html/org/apache/commons/lang3/builder/ReflectionToStringBuilder.html Sets the last superclass to stop appending fields for. ```APIDOC ## setUpToClass ### Description Sets the last superclass to stop appending fields for. ### Method Signature ```java public void setUpToClass(final Class clazz) ``` ### Parameters * **clazz** (Class) - The last superclass to stop appending fields for. ### Throws * **IllegalArgumentException** - If the specified class is not a superclass of the object. ``` -------------------------------- ### Example Builder Usage Source: https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/builder/Builder.html Shows how to use the FontBuilder to create a configured Font object by chaining method calls. This illustrates the fluent interface pattern recommended for builders. ```java Font bold14ptSansSerifFont = new FontBuilder(Font.SANS_SERIF).bold() .size(14.0f) .build(); ``` -------------------------------- ### substring(String str, int start) Source: https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/StringUtils.html Gets a substring from the specified String avoiding exceptions. A negative start position can be used to start `n` characters from the end of the String. A `null` String will return `null`. An empty ("" ) String will return "". ```APIDOC ## substring(String str, int start) ### Description Gets a substring from the specified String avoiding exceptions. A negative start position can be used to start `n` characters from the end of the String. A `null` String will return `null`. An empty ("" ) String will return "". ### Parameters * `str` - the String to get the substring from, may be null. * `start` - the position to start from, negative means count back from the end of the String by this many characters. ### Returns substring from start position, `null` if null String input. ### Examples ```java StringUtils.substring(null, *) = null StringUtils.substring("", *) = "" StringUtils.substring("abc", 0) = "abc" StringUtils.substring("abc", 2) = "c" StringUtils.substring("abc", 4) = "" StringUtils.substring("abc", -2) = "bc" StringUtils.substring("abc", -4) = "abc" ``` ``` -------------------------------- ### getStartInstant() Source: https://commons.apache.org/proper/commons-lang/apidocs/src-html/org/apache/commons/lang3/time/StopWatch.Split.html Gets the Instant this StopWatch was started. This provides the exact point in time when the StopWatch began its operation. ```APIDOC ## getStartInstant() ### Description Gets the Instant this StopWatch was started, between the current time and midnight, January 1, 1970 UTC. ### Method public Instant getStartInstant() ### Returns Instant - the Instant this StopWatch was started, between the current time and midnight, January 1, 1970 UTC. ### Throws IllegalStateException - if this StopWatch has not been started. ``` -------------------------------- ### substring(String str, int start, int end) Source: https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/StringUtils.html Gets a substring from the specified String avoiding exceptions. A negative start position can be used to start/end `n` characters from the end of the String. The returned substring starts with the character in the `start` position and ends before the `end` position. All position counting is zero-based -- i.e., to start at the beginning of the string use `start = 0`. Negative start and end positions can be used to specify offsets relative to the end of the String. If `start` is not strictly to the left of `end`, "" is returned. ```APIDOC ## substring(String str, int start, int end) ### Description Gets a substring from the specified String avoiding exceptions. A negative start position can be used to start/end `n` characters from the end of the String. The returned substring starts with the character in the `start` position and ends before the `end` position. All position counting is zero-based -- i.e., to start at the beginning of the string use `start = 0`. Negative start and end positions can be used to specify offsets relative to the end of the String. If `start` is not strictly to the left of `end`, "" is returned. ### Parameters * `str` - the String to get the substring from, may be null. * `start` - the position to start from, negative means count back from the end of the String by this many characters. * `end` - the position to end at (exclusive), negative means count back from the end of the String by this many characters. ### Returns substring from start position to end position, `null` if null String input. ### Examples ```java StringUtils.substring(null, *, *) = null StringUtils.substring("", * , *) = "" StringUtils.substring("abc", 0, 2) = "ab" StringUtils.substring("abc", 2, 0) = "" StringUtils.substring("abc", 2, 4) = "c" StringUtils.substring("abc", 4, 6) = "" StringUtils.substring("abc", 2, 2) = "" StringUtils.substring("abc", -2, -1) = "b" StringUtils.substring("abc", -4, 2) = "ab" ``` ``` -------------------------------- ### Locale String Conversion Examples Source: https://commons.apache.org/proper/commons-lang/apidocs/src-html/org/apache/commons/lang3/LocaleUtils.html Demonstrates various string formats that can be converted to Locale objects. ```java LocaleUtils.toLocale("") = new Locale("", "") LocaleUtils.toLocale("en") = new Locale("en", "") LocaleUtils.toLocale("en_GB") = new Locale("en", "GB") LocaleUtils.toLocale("en-GB") = new Locale("en", "GB") LocaleUtils.toLocale("en_001") = new Locale("en", "001") LocaleUtils.toLocale("en_GB_xxx") = new Locale("en", "GB", "xxx") (#) LocaleUtils.toLocale("US") = new Locale("", "US") // Because "US" is Locale.getISOCountries() ``` -------------------------------- ### getTime(TimeUnit timeUnit) Source: https://commons.apache.org/proper/commons-lang/apidocs/src-html/org/apache/commons/lang3/time/StopWatch.Split.html Gets the time in the specified TimeUnit. This is either the time between the start and the moment this method is called, or the amount of time between start and stop. The resulting time will be expressed in the desired TimeUnit with any remainder rounded down. ```APIDOC ## getTime(TimeUnit timeUnit) ### Description Gets the time in the specified TimeUnit. This is either the time between the start and the moment this method is called, or the amount of time between start and stop. The resulting time will be expressed in the desired TimeUnit with any remainder rounded down. ### @param timeUnit the unit of time, not null. ### @return long - the time in the specified TimeUnit, rounded down. ### @since 3.5 ``` -------------------------------- ### DiffResult getNumberOfDiffs() Example Source: https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/builder/DiffResult.html Gets the total number of differences found between the two objects. Returns 0 if the objects are identical. ```java public int getNumberOfDiffs() Gets the number of differences between the two objects. Returns: the number of differences ``` -------------------------------- ### MultiBackgroundInitializer Usage Source: https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/concurrent/package-summary.html Demonstrates how to add child initializers to a MultiBackgroundInitializer, start the initialization process, and retrieve results by their assigned names. ```java initializer.addInitializer("jpa", new JPAEMFInitializer()); initializer.addInitializer("config", new ConfigurationInitializer()); initializer.start(); // start background processing // do other interesting things in parallel ... // evaluate the results of background initialization MultiBackgroundInitializer.MultiBackgroundInitializerResults results = initializer.get(); String urlContent = (String) results.getResultObject("url"); EntityManagerFactory emf = (EntityManagerFactory) results.getResultObject("jpa"); ... ``` -------------------------------- ### DiffResult getDiffs() Example Source: https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/builder/DiffResult.html Gets an unmodifiable list of Diff objects. The list may be empty if there were no differences between the objects being compared. ```java public List> getDiffs() Gets an unmodifiable list of `Diff`s. The list may be empty if there were no differences between the objects. Returns: an unmodifiable list of `Diff`s ``` -------------------------------- ### Get Available Locales Set Source: https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/LocaleUtils.html Obtains an unmodifiable set of installed locales. This method is a more efficient wrapper around Locale.getAvailableLocales(). ```java public static Set availableLocaleSet() ``` -------------------------------- ### getActiveExecutor() Source: https://commons.apache.org/proper/commons-lang/apidocs/src-html/org/apache/commons/lang3/concurrent/BackgroundInitializer.html Gets the ExecutorService that is actually used for executing the background task. This method can be called after start() (before start() it returns null). If an external executor was set, this is also the active executor. Otherwise this method returns the temporary executor that was created by this object. ```APIDOC ## getActiveExecutor() ### Description Gets the {@link ExecutorService} that is actually used for executing the background task. This method can be called after {@link #start()} (before {@code start()} it returns null). If an external executor was set, this is also the active executor. Otherwise this method returns the temporary executor that was created by this object. ### Method `protected final synchronized ExecutorService getActiveExecutor()` ### Parameters None ### Response #### Success Response - **ExecutorService** - the {@link ExecutorService} for executing the background task. ``` -------------------------------- ### Try-with-resources with FileInputStream Source: https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/Functions.html Demonstrates a simple try-with-resources implementation for objects that do not implement AutoCloseable. This example shows how to use it with a FileInputStream, ensuring the stream is closed afterwards. ```java final FileInputStream fis = new FileInputStream("my.file"); Functions.tryWithResources(useInputStream(fis), null, () -> fis.close()); ``` -------------------------------- ### Get Available Locales List Source: https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/LocaleUtils.html Obtains an unmodifiable and sorted list of installed locales. This method is a more efficient wrapper around Locale.getAvailableLocales(). ```java public static List availableLocaleList() ``` -------------------------------- ### Usage Example Source: https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/exception/ContextedRuntimeException.html Demonstrates how to use ContextedRuntimeException to add contextual information to an exception. ```APIDOC ```java try { // ... some operation that might fail } catch (Exception e) { throw new ContextedRuntimeException("Error posting account transaction", e) .addContextValue("Account Number", accountNumber) .addContextValue("Amount Posted", amountPosted) .addContextValue("Previous Balance", previousBalance); } ``` Alternatively, to improve diagnose data at a higher level: ```java try { // ... some operation that might fail } catch (ContextedRuntimeException e) { throw e.setContextValue("Transaction Id", transactionId); } catch (Exception e) { if (e instanceof ExceptionContext) { e.setContextValue("Transaction Id", transactionId); } throw e; } ``` ``` -------------------------------- ### SystemUtils Constructor Source: https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/SystemUtils.html Provides information about the SystemUtils constructor. ```APIDOC ## SystemUtils Constructor ### Constructor - `SystemUtils()`: SystemUtils instances shouldn't be constructed in standard programming. ``` -------------------------------- ### Example of Getting List Size with Read Lock Source: https://commons.apache.org/proper/commons-lang/apidocs/src-html/org/apache/commons/lang3/concurrent/locks/LockingVisitors.ReadWriteLockVisitor.Builder.html Demonstrates how to use applyReadLocked to safely retrieve the size of a list while holding a read lock. ```java private Lock> listLock; public int getCurrentListSize() { final Integer sizeInteger = listLock.applyReadLocked(list -> Integer.valueOf(list.size)); return sizeInteger.intValue(); } ``` -------------------------------- ### Starts With Method Implementation Source: https://commons.apache.org/proper/commons-lang/apidocs/src-html/org/apache/commons/lang3/Strings.html The implementation of the startsWith method, which handles null checks and delegates to CharSequenceUtils for region matching. ```java public boolean startsWith(final CharSequence str, final CharSequence prefix) { if (str == null || prefix == null) { return str == prefix; } final int preLen = prefix.length(); if (preLen > str.length()) { return false; } return CharSequenceUtils.regionMatches(str, ignoreCase, 0, prefix, 0, preLen); } ``` -------------------------------- ### AtomicInitializer.Builder.get Source: https://commons.apache.org/proper/commons-lang/apidocs/index-all.html Gets a new instance of `AtomicInitializer`. ```APIDOC ## AtomicInitializer.Builder.get ### Description Gets a new instance of `AtomicInitializer`. ### Method Instance ### Class org.apache.commons.lang3.concurrent.AtomicInitializer.Builder ``` -------------------------------- ### get() Source: https://commons.apache.org/proper/commons-lang/apidocs/src-html/org/apache/commons/lang3/concurrent/BackgroundInitializer.html Gets the result of the background initialization. This method blocks until initialization is complete. If the background processing caused a runtime exception, it is directly thrown by this method. Checked exceptions, including InterruptedException are wrapped in a ConcurrentException. Calling this method before start() was called causes an IllegalStateException exception to be thrown. ```APIDOC ## get() ### Description Gets the result of the background initialization. This method blocks until initialization is complete. If the background processing caused a runtime exception, it is directly thrown by this method. Checked exceptions, including {@link InterruptedException} are wrapped in a {@link ConcurrentException}. Calling this method before {@link #start()} was called causes an {@link IllegalStateException} exception to be thrown. ### Method `T get()` ### Parameters None ### Response #### Success Response - **T** - the object produced by this initializer. #### Throws - **ConcurrentException** - if a checked exception occurred during background processing. - **IllegalStateException** - if {@link #start()} has not been called. ```