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 ScmClient
public final class ScmClient
{
/** Field description */
@@ -53,6 +53,14 @@ public class ScmClient
/** the logger for ScmClient */
private static final Logger logger = LoggerFactory.getLogger(ScmClient.class);
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*/
private ScmClient() {}
//~--- methods --------------------------------------------------------------
/**
@@ -68,8 +76,8 @@ public class ScmClient
* @throws ScmClientException
*/
public static ScmClientSession createSession(String url, String username,
String password)
throws ScmClientException
String password)
throws ScmClientException
{
return getProvider().createSession(url, username, password);
}
@@ -85,7 +93,7 @@ public class ScmClient
* @throws ScmClientException
*/
public static ScmClientSession createSession(String url)
throws ScmClientException
throws ScmClientException
{
return getProvider().createSession(url, null, null);
}
@@ -119,7 +127,7 @@ public class ScmClient
else if (logger.isInfoEnabled())
{
logger.info("create ScmClient with provider {}",
provider.getClass().getName());
provider.getClass().getName());
}
return provider;

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
{

View File

@@ -30,6 +30,7 @@
*/
package sonia.scm.plugin;
//~--- non-JDK imports --------------------------------------------------------
@@ -45,7 +46,7 @@ import java.io.File;
*
* @author Sebastian Sdorra
*/
public class BaseDirectory
public final class BaseDirectory
{
/** Field description */
@@ -66,7 +67,7 @@ public class BaseDirectory
* Constructs ...
*
*/
public BaseDirectory()
private BaseDirectory()
{
baseDirectory = findBaseDirectory();
}

View File

@@ -30,15 +30,24 @@
*/
package sonia.scm.plugin;
/**
*
* @author Sebastian Sdorra
*/
public class Roles
public final class Roles
{
/** Field description */
public static final String ADMIN = "admin";
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*/
private Roles() {}
}

View File

@@ -30,6 +30,7 @@
*/
package sonia.scm.plugin.scanner;
//~--- non-JDK imports --------------------------------------------------------
@@ -48,7 +49,7 @@ import java.io.File;
*
* @author Sebastian Sdorra
*/
public class PluginScanners
public final class PluginScanners
{
/**
@@ -57,6 +58,14 @@ public class PluginScanners
private static final Logger logger =
LoggerFactory.getLogger(PluginScanners.class);
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*/
private PluginScanners() {}
//~--- methods --------------------------------------------------------------
/**

View File

@@ -30,6 +30,7 @@
*/
package sonia.scm.repository;
//~--- non-JDK imports --------------------------------------------------------
@@ -46,9 +47,17 @@ import java.util.Scanner;
*
* @author Sebastian Sdorra
*/
public class GitSubModuleParser
public final class GitSubModuleParser
{
/**
* Constructs ...
*
*/
private GitSubModuleParser() {}
//~--- methods --------------------------------------------------------------
/**
* //~--- methods --------------------------------------------------------------
*

View File

@@ -41,9 +41,17 @@ import sonia.scm.util.SystemUtil;
*
* @author Sebastian Sdorra
*/
public class HgInstallerFactory
public final class HgInstallerFactory
{
/**
* Constructs ...
*
*/
private HgInstallerFactory() {}
//~--- methods --------------------------------------------------------------
/**
* Method description
*

View File

@@ -30,6 +30,7 @@
*/
package sonia.scm.repository;
//~--- non-JDK imports --------------------------------------------------------
@@ -55,7 +56,7 @@ import java.io.IOException;
*
* @author Sebastian Sdorra
*/
public class HgPyFix
public final class HgPyFix
{
/** Field description */
@@ -72,6 +73,14 @@ public class HgPyFix
*/
private static final Logger logger = LoggerFactory.getLogger(HgUtil.class);
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*/
private HgPyFix() {}
//~--- methods --------------------------------------------------------------
/**
@@ -108,7 +117,6 @@ public class HgPyFix
* Visible for testing
*
*
* @param hg
*
* @param hgBat
*/

View File

@@ -30,6 +30,7 @@
*/
package sonia.scm.repository;
/**
@@ -37,7 +38,7 @@ package sonia.scm.repository;
* @author Sebastian Sdorra
* @since 1.18
*/
public class PersonTestData
public final class PersonTestData
{
/** Field description */
@@ -67,4 +68,12 @@ public class PersonTestData
/** Field description */
public static final Person ZAPHOD =
Person.toPerson("Zaphod Beeblebrox <zaphod.beeblebrox@hitchhiker.com>");
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*/
private PersonTestData() {}
}

View File

@@ -37,9 +37,17 @@ package sonia.scm.repository;
*
* @author Sebastian Sdorra
*/
public class RepositoryTestData
public final class RepositoryTestData
{
/**
* Constructs ...
*
*/
private RepositoryTestData() {}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
@@ -80,7 +88,7 @@ public class RepositoryTestData
public static Repository createHappyVerticalPeopleTransporter()
{
return createHappyVerticalPeopleTransporter(
DummyRepositoryHandler.TYPE_NAME);
DummyRepositoryHandler.TYPE_NAME);
}
/**
@@ -97,12 +105,12 @@ public class RepositoryTestData
happyVerticalPeopleTransporter.setType(type);
happyVerticalPeopleTransporter.setContact(
"zaphod.beeblebrox@hitchhiker.com");
"zaphod.beeblebrox@hitchhiker.com");
happyVerticalPeopleTransporter.setName("happyVerticalPeopleTransporter");
happyVerticalPeopleTransporter.setDescription(
"Happy Vertical People Transporter");
"Happy Vertical People Transporter");
happyVerticalPeopleTransporter.setUrl(
"http://hitchhiker.com/dummy/HeartOfGold");
"http://hitchhiker.com/dummy/HeartOfGold");
return happyVerticalPeopleTransporter;
}
@@ -134,7 +142,7 @@ public class RepositoryTestData
heartOfGold.setContact("zaphod.beeblebrox@hitchhiker.com");
heartOfGold.setName("HeartOfGold");
heartOfGold.setDescription(
"Heart of Gold is the first prototype ship to successfully utilise the revolutionary Infinite Improbability Drive");
"Heart of Gold is the first prototype ship to successfully utilise the revolutionary Infinite Improbability Drive");
heartOfGold.setUrl("http://hitchhiker.com/dummy/HeartOfGold");
return heartOfGold;
@@ -149,7 +157,7 @@ public class RepositoryTestData
public static Repository createRestaurantAtTheEndOfTheUniverse()
{
return createRestaurantAtTheEndOfTheUniverse(
DummyRepositoryHandler.TYPE_NAME);
DummyRepositoryHandler.TYPE_NAME);
}
/**

View File

@@ -41,9 +41,17 @@ import java.io.File;
*
* @author Sebastian Sdorra
*/
public class RepositoryClientFactory
public final class RepositoryClientFactory
{
/**
* Constructs ...
*
*/
private RepositoryClientFactory() {}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
@@ -57,8 +65,8 @@ public class RepositoryClientFactory
* @throws RepositoryClientException
*/
public static RepositoryClient createClient(String type,
File localRepository, String remoteRepository)
throws RepositoryClientException
File localRepository, String remoteRepository)
throws RepositoryClientException
{
return createClient(type, localRepository, remoteRepository, null, null);
}
@@ -78,9 +86,9 @@ public class RepositoryClientFactory
* @throws RepositoryClientException
*/
public static RepositoryClient createClient(String type,
File localRepository, String remoteRepository, String username,
String password)
throws RepositoryClientException
File localRepository, String remoteRepository, String username,
String password)
throws RepositoryClientException
{
RepositoryClient client = null;
@@ -89,17 +97,17 @@ public class RepositoryClientFactory
if ("git".equals(type))
{
client = new GitRepositoryClient(localRepository, remoteRepository,
username, password);
username, password);
}
else if ("svn".equals(type))
{
client = new SvnRepositoryClient(localRepository, remoteRepository,
username, password);
username, password);
}
else if ("hg".equals(type))
{
client = new HgRepositoryClient(localRepository, remoteRepository,
username, password);
username, password);
}
}
catch (Exception ex)

View File

@@ -37,9 +37,17 @@ package sonia.scm.user;
*
* @author Sebastian Sdorra
*/
public class UserTestData
public final class UserTestData
{
/**
* Constructs ...
*
*/
private UserTestData() {}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
@@ -104,7 +112,7 @@ public class UserTestData
public static User createTrillian()
{
return new User("trillian", "Tricia McMillan",
"tricia.mcmillan@hitchhiker.com");
"tricia.mcmillan@hitchhiker.com");
}
/**
@@ -116,6 +124,6 @@ public class UserTestData
public static User createZaphod()
{
return new User("zaphod", "Zaphod Beeblebrox",
"zaphod.beeblebrox@hitchhiker.com");
"zaphod.beeblebrox@hitchhiker.com");
}
}

View File

@@ -30,6 +30,7 @@
*/
package sonia.scm.plugin.ext;
//~--- non-JDK imports --------------------------------------------------------
@@ -44,9 +45,17 @@ import java.lang.annotation.Annotation;
*
* @author Sebastian Sdorra
*/
public class Extensions
public final class Extensions
{
/**
* Constructs ...
*
*/
private Extensions() {}
//~--- methods --------------------------------------------------------------
/**
* Method description
*

View File

@@ -30,6 +30,7 @@
*/
package sonia.scm.upgrade;
//~--- non-JDK imports --------------------------------------------------------
@@ -46,7 +47,7 @@ import java.util.regex.Pattern;
*
* @author Sebastian Sdorra
*/
public class ClientDateFormatConverter
public final class ClientDateFormatConverter
{
/** Field description */
@@ -58,12 +59,20 @@ public class ClientDateFormatConverter
private static final Logger logger =
LoggerFactory.getLogger(ClientDateFormatConverter.class);
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*/
private ClientDateFormatConverter() {}
//~--- methods --------------------------------------------------------------
/**
* Documentations:
* - Extjs: http://trac.geoext.org/browser/ext/3.4.0/docs/source/Date.html
* - Moments: http://momentjs.com/docs/#/displaying/format/
* - Moments: http://momentjs.com/docs/#/displaying/format
*
*
* @param value
@@ -104,8 +113,8 @@ public class ClientDateFormatConverter
result = replaceDateFormatChars(result, "T", "z");
logger.debug(
"converted extjs date format \"{}\" to moments date format \"{}\"", value,
result);
"converted extjs date format \"{}\" to moments date format \"{}\"",
value, result);
return result;
}

View File

@@ -30,6 +30,7 @@
*/
package sonia.scm.user;
//~--- non-JDK imports --------------------------------------------------------
@@ -43,7 +44,7 @@ import sonia.scm.HandlerEvent;
*
* @author Sebastian Sdorra
*/
public class UserEventHack
public final class UserEventHack
{
/**
@@ -52,6 +53,14 @@ public class UserEventHack
private static final Logger logger =
LoggerFactory.getLogger(UserEventHack.class);
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*/
private UserEventHack() {}
//~--- methods --------------------------------------------------------------
/**

View File

@@ -30,6 +30,7 @@
*/
package sonia.scm.util;
//~--- non-JDK imports --------------------------------------------------------
@@ -43,7 +44,7 @@ import sonia.scm.DecoratorFactory;
*
* @author Sebastian Sdorra
*/
public class Decorators
public final class Decorators
{
/**
@@ -52,6 +53,14 @@ public class Decorators
private static final Logger logger =
LoggerFactory.getLogger(Decorators.class);
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*/
private Decorators() {}
//~--- methods --------------------------------------------------------------
/**