util classes should be final with a private constructor

This commit is contained in:
Sebastian Sdorra
2013-02-11 15:28:14 +01:00
parent 961c6f7f02
commit 114834d257
22 changed files with 232 additions and 51 deletions

View File

@@ -44,7 +44,7 @@ import sonia.scm.util.ServiceUtil;
*
* @author Sebastian Sdorra
*/
public class SCMContext
public final class SCMContext
{
/** Default java package for finding extensions */
@@ -53,8 +53,8 @@ public class SCMContext
/** Name of the anonymous user */
public static final String USER_ANONYMOUS = "anonymous";
/**
* the anonymous user
/**
* the anonymous user
* @since 1.21
*/
public static final User ANONYMOUS = new User(USER_ANONYMOUS,
@@ -64,6 +64,14 @@ public class SCMContext
/** Singleton instance of {@link SCMContextProvider} */
private static volatile SCMContextProvider provider;
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*/
private SCMContext() {}
//~--- get methods ----------------------------------------------------------
/**

View File

@@ -30,6 +30,7 @@
*/
package sonia.scm.net;
//~--- non-JDK imports --------------------------------------------------------
@@ -50,7 +51,7 @@ import java.net.URL;
* @author Sebastian Sdorra
* @since 1.23
*/
public class Proxies
public final class Proxies
{
/**
@@ -58,6 +59,14 @@ public class Proxies
*/
private static final Logger logger = LoggerFactory.getLogger(Proxies.class);
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*/
private Proxies() {}
//~--- get methods ----------------------------------------------------------
/**

View File

@@ -30,6 +30,7 @@
*/
package sonia.scm.security;
/**
@@ -45,4 +46,12 @@ public final class Role
/** Field description */
public static final String USER = "user";
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*/
private Role() {}
}

View File

@@ -30,6 +30,7 @@
*/
package sonia.scm.security;
//~--- non-JDK imports --------------------------------------------------------
@@ -51,6 +52,14 @@ import javax.servlet.http.HttpServletRequest;
public final class Tokens
{
/**
* Constructs ...
*
*/
private Tokens() {}
//~--- methods --------------------------------------------------------------
/**
* Build an {@link AuthenticationToken} for use with
* {@link Subject#login(org.apache.shiro.authc.AuthenticationToken)}.

View File

@@ -30,6 +30,7 @@
*/
package sonia.scm.template;
//~--- non-JDK imports --------------------------------------------------------
@@ -52,7 +53,7 @@ import java.io.Writer;
* @author Sebastian Sdorra
* @since 1.22
*/
public class Templates
public final class Templates
{
/**
@@ -60,6 +61,14 @@ public class Templates
*/
private static final Logger logger = LoggerFactory.getLogger(Templates.class);
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*/
private Templates() {}
//~--- methods --------------------------------------------------------------
/**

View File

@@ -37,7 +37,7 @@ package sonia.scm.url;
* @since 1.9
* @author Sebastian Sdorra
*/
public class UrlProviderFactory
public final class UrlProviderFactory
{
/** Field description */
@@ -55,6 +55,14 @@ public class UrlProviderFactory
/** Field description */
private static final String EXTENSION_XML = ".xml";
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*/
private UrlProviderFactory() {}
//~--- methods --------------------------------------------------------------
/**

View File

@@ -46,18 +46,26 @@ import java.util.regex.Pattern;
*
* @author Sebastian Sdorra
*/
public class LinkTextParser
public final class LinkTextParser
{
/** Field description */
private static final Pattern REGEX_URL =
Pattern.compile(
"\\(?\\b((?:https?://|ftps?://|mailto:|www[.])[-A-Za-z0-9+&@#/%?=~_()|!:,.;]*[-A-Za-z0-9+&@#/%=~_()|])");
"\\(?\\b((?:https?://|ftps?://|mailto:|www[.])[-A-Za-z0-9+&@#/%?=~_()|!:,.;]*[-A-Za-z0-9+&@#/%=~_()|])");
/** Field description */
private static final String REPLACE_URL =
"<a target=\"_blank\" href=\"{1}\">{0}</a>";
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*/
private LinkTextParser() {}
//~--- methods --------------------------------------------------------------
/**
@@ -103,12 +111,12 @@ public class LinkTextParser
if (token.getReplacement() != null)
{
buffer.append(MessageFormat.format(REPLACE_URL, token.getValue(),
token.getReplacement()));
token.getReplacement()));
}
else
{
buffer.append(token.getValue().replace("<", "&lt;").replace(">",
"&gt;"));
"&gt;"));
}
}
@@ -122,7 +130,7 @@ public class LinkTextParser
*
*
* @version Enter version here..., 11/11/06
* @author Enter your name here...
* @author Enter your name here...
*/
private static class Token
{