public final class SharedFunctions extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
BUFFER_BYTE_SIZE
I want a buffer that is an array with 1024 elements of bytes.
|
| Modifier | Constructor and Description |
|---|---|
private |
SharedFunctions()
Making the constructor private because the class only contains static methods.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
copyFile(org.apache.maven.plugin.logging.Log log,
File fromFile,
File toFile)
|
static void |
initDirectory(org.apache.maven.plugin.logging.Log log,
File workingDirectory)
Cleans and then initializes an empty directory that is given by the
workingDirectory
parameter. |
static <T> T |
requireNonNull(T obj)
Checks that the specified object reference is not
null. |
static <T> T |
requireNonNull(T obj,
String message)
Checks that the specified object reference is not
null and throws a customized MojoExecutionException if it is. |
static <T> T |
requireNonNull(T obj,
Supplier<String> messageSupplier)
Checks that the specified object reference is not
null and throws a customized MojoExecutionException if it is. |
static void |
setAuthentication(org.apache.maven.scm.provider.ScmProviderRepository providerRepository,
String distServer,
org.apache.maven.settings.Settings settings,
org.apache.maven.settings.crypto.SettingsDecrypter settingsDecrypter,
String username,
String password)
Set authentication information on the specified
ScmProviderRepository. |
public static final int BUFFER_BYTE_SIZE
private SharedFunctions()
public static void copyFile(org.apache.maven.plugin.logging.Log log,
File fromFile,
File toFile)
throws org.apache.maven.plugin.MojoExecutionException
log - the Log, the maven logger.fromFile - the File from which to copy.toFile - the File to which to copy into.org.apache.maven.plugin.MojoExecutionException - if an IOException or NullPointerException is caught.public static void initDirectory(org.apache.maven.plugin.logging.Log log,
File workingDirectory)
throws org.apache.maven.plugin.MojoExecutionException
workingDirectory
parameter.log - is the Maven log for output logging, particularly in regards to error management.workingDirectory - is a File that represents the directory to first attempt to delete then create.org.apache.maven.plugin.MojoExecutionException - when an IOException or NullPointerException is caught for the
purpose of bubbling the exception up to Maven properly.public static <T> T requireNonNull(T obj)
throws org.apache.maven.plugin.MojoExecutionException
null. This method is designed primarily for doing parameter validation in methods and
constructors, as demonstrated below:
public Foo(Bar bar) {
this.bar = SharedFunctions.requireNonNull(bar);
}
T - the type of the referenceobj - the object reference to check for nullityobj if not nullorg.apache.maven.plugin.MojoExecutionException - if obj is nullpublic static <T> T requireNonNull(T obj,
String message)
throws org.apache.maven.plugin.MojoExecutionException
null and throws a customized MojoExecutionException if it is. This method is designed
primarily for doing parameter validation in methods and constructors with multiple parameters, as demonstrated below:
public Foo(Bar bar, Baz baz) {
this.bar = SharedFunctions.requireNonNull(bar, "bar must not be null");
this.baz = SharedFunctions.requireNonNull(baz, "baz must not be null");
}
T - the type of the referenceobj - the object reference to check for nullitymessage - detail message to be used in the event that a NullPointerException is thrownobj if not nullorg.apache.maven.plugin.MojoExecutionException - if obj is nullpublic static <T> T requireNonNull(T obj,
Supplier<String> messageSupplier)
throws org.apache.maven.plugin.MojoExecutionException
null and throws a customized MojoExecutionException if it is.
Unlike the method requireNonNull(Object, String), this method allows creation of the message to be deferred until after the null check is made.
While this may confer a performance advantage in the non-null case, when deciding to call this method care should be taken that the costs of creating the
message supplier are less than the cost of just creating the string message directly.
T - the type of the referenceobj - the object reference to check for nullitymessageSupplier - supplier of the detail message to be used in the event that a NullPointerException is thrownobj if not nullorg.apache.maven.plugin.MojoExecutionException - if obj is nullpublic static void setAuthentication(org.apache.maven.scm.provider.ScmProviderRepository providerRepository,
String distServer,
org.apache.maven.settings.Settings settings,
org.apache.maven.settings.crypto.SettingsDecrypter settingsDecrypter,
String username,
String password)
ScmProviderRepository.providerRepository - target.distServer - temp.settings - temp.settingsDecrypter - temp.username - temp.password - temp.Copyright © 2018–2022 The Apache Software Foundation. All rights reserved.