Skip to content

Commit

Permalink
Merge pull request #632 from DevFactory/staging/Utility-classes-shoul…
Browse files Browse the repository at this point in the history
…d-not-have-public-constructors-fix1

squid:S1118 - Utility classes should not have public constructors
  • Loading branch information
Turini authored Jun 29, 2016
2 parents ae0d95a + 5e46663 commit db2bae5
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@
*
* @author guilherme silveira
*/
public class BaseComponents {
public final class BaseComponents {

static final Logger logger = LoggerFactory.getLogger(BaseComponents.class);

Expand Down Expand Up @@ -325,6 +325,10 @@ ProxyInitializer.class, getProxyInitializerImpl()
Intercepts.class
};

private BaseComponents() {
throw new InstantiationError( "Must not instantiate this class" );
}

@SuppressWarnings({ "unchecked", "rawtypes" })
private static final Set<Class<? extends Deserializer>> DESERIALIZERS = new HashSet(Arrays.asList(
XMLDeserializer.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@
/**
* @author Fabio Kung
*/
public class VRaptorRequestHolder {
public final class VRaptorRequestHolder {
private static final ThreadLocal<RequestInfo> vraptorRequests = new ThreadLocal<RequestInfo>();

private VRaptorRequestHolder() {
throw new InstantiationError( "Must not instantiate this class" );
}

public static RequestInfo currentRequest() {
return vraptorRequests.get();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@
* @author Lucas Cavalcanti
*/
public class StringUtils {
public final class StringUtils {

private StringUtils() {
throw new InstantiationError( "Must not instantiate this class" );
}

public static String decapitalize(String name) {
if (name.length() == 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;

public class Stringnifier {
public final class Stringnifier {

private Stringnifier() {
throw new InstantiationError( "Must not instantiate this class" );
}

static String argumentsToString(Class<?>[] parameterTypes) {
StringBuilder builder = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@

import com.google.common.base.Function;

public class Functions {
public final class Functions {

private Functions() {
throw new InstantiationError( "Must not instantiate this class" );
}

public static <T> Function<Class<? extends T>, ? extends T> instanceWith(final Container container) {
return new Function<Class<? extends T>, T>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@
*
* @author Guilherme Silveira
*/
public class Results {
public final class Results {

private Results() {
throw new InstantiationError( "Must not instantiate this class" );
}

/**
* Offers server side forward and include for web pages.<br>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@

import br.com.caelum.vraptor.http.route.Route;

public class VRaptorMatchers {
public final class VRaptorMatchers {

private VRaptorMatchers () {
throw new InstantiationError( "Must not instantiate this class" );
}

public static Matcher<Collection<?>> hasOneCopyOf(final Object item) {
return new TypeSafeMatcher<Collection<?>>(){

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@

public final class AbstractOgnlTestSupport {

private AbstractOgnlTestSupport () {
throw new InstantiationError( "Must not instantiate this class" );
}

public static void configOgnl(Converters converters) throws OgnlException {
Proxifier proxifier = new JavassistProxifier(new ReflectionInstanceCreator());
OgnlRuntime.setNullHandler(Object.class, new ReflectionBasedNullHandler(proxifier));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@
*
* @author Guilherme Silveira
*/
public class VRaptorMatchers {
public final class VRaptorMatchers {

private VRaptorMatchers () {
throw new InstantiationError( "Must not instantiate this class" );
}

public static TypeSafeMatcher<ResourceMethod> resourceMethod(final Method method) {
return new TypeSafeMatcher<ResourceMethod>() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* @author Lucas Cavalcanti
*
*/
public class CustomMatchers {
public final class CustomMatchers {

private static TypeSafeMatcher<String> EMPTY = new TypeSafeMatcher<String>() {

Expand All @@ -44,6 +44,10 @@ public void describeTo(Description description) {

};

private CustomMatchers() {
throw new InstantiationError( "Must not instantiate this class" );
}

/**
* matches if the given string is not empty. This matcher is null-safe.
* @return
Expand Down

1 comment on commit db2bae5

@GauravRoy092
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow

Please sign in to comment.