checkstyle HideUtilityClassConstructor

https://sonar.spring.io/issues/search#componentRoots=org.springframework.integration%3Aspring-integration|createdAt=2016-04-01T10%3A00%3A36%2B0000|sort=UPDATE_DATE|asc=false
This commit is contained in:
Gary Russell
2016-04-01 10:30:25 -04:00
committed by Artem Bilan
parent b363bdb15e
commit 43af472c3a
34 changed files with 226 additions and 79 deletions

View File

@@ -32,6 +32,10 @@ import org.springframework.messaging.Message;
*/
public class MappingUtils {
private MappingUtils() {
super();
}
/**
* Map an o.s.Message to an o.s.a.core.Message.
* @param requestMessage the request message.

View File

@@ -25,10 +25,15 @@ import java.util.Collections;
* entries from/to Message Headers and other adapter, e.g. AMQP.
*
* @author Artem Bilan
* @author Gary Russell
* @since 3.0
*/
public class JsonHeaders {
private JsonHeaders() {
super();
}
public static final String PREFIX = "json";
public static final String TYPE_ID = PREFIX + "__TypeId__";

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,6 +28,10 @@ import org.springframework.util.ClassUtils;
*/
public final class JacksonJsonUtils {
private JacksonJsonUtils() {
super();
}
private static final ClassLoader classLoader = JacksonJsonUtils.class.getClassLoader();
private static final boolean jackson2Present =

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,6 +39,10 @@ public final class JsonObjectMapperProvider {
private static final boolean boonPresent =
ClassUtils.isPresent("org.boon.json.ObjectMapper", classLoader);
private JsonObjectMapperProvider() {
super();
}
public static JsonObjectMapper<?, ?> newInstance() {
if (JacksonJsonUtils.isJackson2Present()) {
return new Jackson2JsonObjectMapper();

View File

@@ -49,6 +49,10 @@ public class IntegrationUtils {
*/
public static final boolean fatalWhenNoBeanFactory = Boolean.valueOf(System.getenv("SI_FATAL_WHEN_NO_BEANFACTORY"));
private IntegrationUtils() {
super();
}
/**
* @param beanFactory BeanFactory for lookup, must not be null.
* @return The {@link ConversionService} bean whose name is "integrationConversionService" if available.

View File

@@ -29,52 +29,56 @@ import java.util.logging.Logger;
class TimeBasedUUIDGenerator {
private static final Logger logger = Logger.getLogger(TimeBasedUUIDGenerator.class.getName());
public static final Object lock = new Object();
private static boolean canNotDetermineMac = true;
private static long lastTime;
private static long clockSequence = 0;
private static final long macAddress = getMac();
private TimeBasedUUIDGenerator() {
super();
}
/**
* Will generate unique time based UUID where the next UUID is
* Will generate unique time based UUID where the next UUID is
* always greater then the previous.
*/
public final static UUID generateId() {
return generateIdFromTimestamp(System.currentTimeMillis());
}
public final static UUID generateIdFromTimestamp(long currentTimeMillis){
long time;
synchronized (lock) {
if (currentTimeMillis > lastTime) {
lastTime = currentTimeMillis;
clockSequence = 0;
} else {
++clockSequence;
} else {
++clockSequence;
}
}
time = currentTimeMillis;
// low Time
time = currentTimeMillis << 32;
// mid Time
time |= ((currentTimeMillis & 0xFFFF00000000L) >> 16);
// hi Time
time |= 0x1000 | ((currentTimeMillis >> 48) & 0x0FFF); // version 1
long clock_seq_hi_and_reserved = clockSequence;
clock_seq_hi_and_reserved <<=48;
long cls = 0 | clock_seq_hi_and_reserved;
long clock_seq_hi_and_reserved = clockSequence;
clock_seq_hi_and_reserved <<=48;
long cls = 0 | clock_seq_hi_and_reserved;
long lsb = cls | macAddress;
if (canNotDetermineMac){
logger.warning("UUID generation process was not able to determine your MAC address. Returning random UUID (non version 1 UUID)");
@@ -93,12 +97,12 @@ class TimeBasedUUIDGenerator {
byte[] mac = "01:23:45:67:89:ab".getBytes();
//Converts array of unsigned bytes to an long
if (mac != null) {
for (int i = 0; i < mac.length; i++) {
for (int i = 0; i < mac.length; i++) {
macAddressAsLong <<= 8;
macAddressAsLong ^= (long)mac[i] & 0xFF;
}
}
}
}
canNotDetermineMac = false;
} catch (Exception e) {
e.printStackTrace();

View File

@@ -37,6 +37,10 @@ final class FileChannelCache {
private static ConcurrentMap<File, FileChannel> channelCache = new ConcurrentHashMap<File, FileChannel>();
private FileChannelCache() {
super();
}
/**
* Try to get a lock for this file while guaranteeing that the same channel will be used for all file locks in this
* VM. If the lock could not be acquired this method will return <code>null</code>.

View File

@@ -23,34 +23,42 @@ import org.springframework.core.io.InputStreamResource;
/**
* @author Dan Oxlade
* @author Gary Russell
*/
class ParserTestUtil {
static ParserContext createFakeParserContext() {
return new ParserContext(new XmlReaderContext(thisClassAsResource(), new FailFastProblemReporter(), null, null, null, null), null);
}
static InputStreamResource thisClassAsResource() {
return new InputStreamResource(ParserTestUtil.class.getResourceAsStream(ParserTestUtil.class.getSimpleName() + ".class"));
}
private ParserTestUtil() {
super();
}
static ParserContext createFakeParserContext() {
return new ParserContext(
new XmlReaderContext(thisClassAsResource(), new FailFastProblemReporter(), null, null, null, null),
null);
}
static org.w3c.dom.Document loadXMLFrom(String xml)
throws org.xml.sax.SAXException, java.io.IOException {
return loadXMLFrom(new java.io.ByteArrayInputStream(xml.getBytes()));
}
static InputStreamResource thisClassAsResource() {
return new InputStreamResource(
ParserTestUtil.class.getResourceAsStream(ParserTestUtil.class.getSimpleName() + ".class"));
}
static org.w3c.dom.Document loadXMLFrom(String xml) throws org.xml.sax.SAXException, java.io.IOException {
return loadXMLFrom(new java.io.ByteArrayInputStream(xml.getBytes()));
}
static org.w3c.dom.Document loadXMLFrom(java.io.InputStream is)
throws org.xml.sax.SAXException, java.io.IOException {
javax.xml.parsers.DocumentBuilderFactory factory = javax.xml.parsers.DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
javax.xml.parsers.DocumentBuilder builder = null;
try {
builder = factory.newDocumentBuilder();
}
catch (javax.xml.parsers.ParserConfigurationException ex) {
}
org.w3c.dom.Document doc = builder.parse(is);
is.close();
return doc;
}
static org.w3c.dom.Document loadXMLFrom(java.io.InputStream is)
throws org.xml.sax.SAXException, java.io.IOException {
javax.xml.parsers.DocumentBuilderFactory factory =
javax.xml.parsers.DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
javax.xml.parsers.DocumentBuilder builder = null;
try {
builder = factory.newDocumentBuilder();
} catch (javax.xml.parsers.ParserConfigurationException ex) {
}
org.w3c.dom.Document doc = builder.parse(is);
is.close();
return doc;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2013 the original author or authors.
* Copyright 2013-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,12 +32,17 @@ import com.gemstone.gemfire.cache.server.CacheServer;
* @author David Turanski
* @author Gunnar Hillert
* @author Soby Chacko
* @author Gary Russell
*
* Runs as a standalone Java app.
* Modified from SGF implementation for testing client/server CQ features
*/
public class CacheServerProcess {
private CacheServerProcess() {
super();
}
public static void main(String[] args) throws Exception {
Properties props = new Properties();

View File

@@ -37,6 +37,10 @@ public class ForkUtil {
private static String TEMP_DIR = System.getProperty("java.io.tmpdir");
private ForkUtil() {
super();
}
public static OutputStream cloneJVM(String argument) {
String cp = System.getProperty("java.class.path");
String home = System.getProperty("java.home");

View File

@@ -20,10 +20,15 @@ package org.springframework.integration.http.support;
* Utility class for accessing HTTP integration components from the {@link org.springframework.beans.factory.BeanFactory}.
*
* @author Artem Bilan
* @author Gary Russell
* @since 3.0
*/
public final class HttpContextUtils {
private HttpContextUtils() {
super();
}
/**
* @see org.springframework.integration.http.config.HttpInboundEndpointParser
*/

View File

@@ -30,6 +30,10 @@ import org.springframework.integration.ip.tcp.connection.AbstractServerConnectio
*/
public class TestingUtilities {
private TestingUtilities() {
super();
}
/**
* Wait for a server connection factory to actually start listening before
* starting a test. Waits for up to 10 seconds by default.

View File

@@ -26,6 +26,10 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
*/
public class SyslogdTests {
private SyslogdTests() {
super();
}
public static void main(String[] args) throws Exception {
AbstractApplicationContext ctx = new ClassPathXmlApplicationContext("SyslogdTests-context.xml", SyslogdTests.class);
System.out.println("Hit enter to terminate");

View File

@@ -26,6 +26,10 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
*/
public class SyslogdTests {
private SyslogdTests() {
super();
}
public static void main(String[] args) throws Exception {
AbstractApplicationContext ctx = new ClassPathXmlApplicationContext("SyslogdTests-context.xml", SyslogdTests.class);
System.out.println("Hit enter to terminate");

View File

@@ -47,6 +47,10 @@ public class SocketTestUtils {
private static final Log logger = LogFactory.getLog(SocketTestUtils.class);
private SocketTestUtils() {
super();
}
/**
* Sends a message in two chunks with a preceding length. Two such messages are sent.
* @param latch If not null, await until counted down before sending second chunk.

View File

@@ -21,11 +21,16 @@ import java.util.Locale;
/**
*
* @author Gunnar Hillert
* @author Gary Russell
*
*/
public final class DerbyFunctions {
public static String convertStringToUpperCase( String invalue ) {
private DerbyFunctions() {
super();
}
public static String convertStringToUpperCase( String invalue ) {
return invalue.toUpperCase(Locale.ENGLISH);
}

View File

@@ -29,10 +29,15 @@ import org.springframework.jdbc.support.JdbcUtils;
*
* @author Gunnar Hillert
* @author Artem Bilan
* @author Gary Russell
*
*/
public final class DerbyStoredProcedures {
private DerbyStoredProcedures() {
super();
}
public static void createUser(String username, String password, String email)
throws SQLException {
Connection conn = null;

View File

@@ -26,27 +26,32 @@ import org.h2.tools.SimpleResultSet;
/**
*
* @author Gunnar Hillert
* @author Gary Russell
*
*/
public final class H2StoredProcedures {
public static ResultSet getPrimes(int beginRange, int endRange) throws SQLException {
private H2StoredProcedures() {
super();
}
SimpleResultSet rs = new SimpleResultSet();
rs.addColumn("PRIME", Types.INTEGER, 10, 0);
public static ResultSet getPrimes(int beginRange, int endRange) throws SQLException {
for (int i = beginRange; i <= endRange; i++) {
SimpleResultSet rs = new SimpleResultSet();
rs.addColumn("PRIME", Types.INTEGER, 10, 0);
if (new BigInteger(String.valueOf(i)).isProbablePrime(100)) {
rs.addRow(i);
}
}
for (int i = beginRange; i <= endRange; i++) {
return rs;
}
if (new BigInteger(String.valueOf(i)).isProbablePrime(100)) {
rs.addRow(i);
}
}
public static Integer random() {
return 1 + (int)(Math.random() * 100);
}
return rs;
}
public static Integer random() {
return 1 + (int) (Math.random() * 100);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,11 +20,11 @@ import java.io.File;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.Before;
/**
* @author Oleg Zhurakousky
* @author Gary Russell
*
*/
public class ActiveMqTestUtils {
@@ -32,6 +32,10 @@ public class ActiveMqTestUtils {
private static final Log logger = LogFactory.getLog(ActiveMqTestUtils.class);
private ActiveMqTestUtils() {
super();
}
@Before
public static void prepare() {
logger.info("####### Refreshing ActiveMq ########");

View File

@@ -20,22 +20,27 @@ import java.util.Calendar;
import java.util.Date;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.messaging.MessageChannel;
import org.springframework.integration.config.SourcePollingChannelAdapterFactoryBean;
import org.springframework.integration.core.MessageSource;
import org.springframework.integration.endpoint.SourcePollingChannelAdapter;
import org.springframework.integration.jpa.test.entity.Gender;
import org.springframework.integration.jpa.test.entity.StudentDomain;
import org.springframework.integration.scheduling.PollerMetadata;
import org.springframework.messaging.MessageChannel;
/**
*
* @author Gunnar Hillert
* @author Gary Russell
* @since 2.2
*
*/
public final class JpaTestUtils {
private JpaTestUtils() {
super();
}
public static StudentDomain getTestStudent() {
Calendar dateOfBirth = Calendar.getInstance();

View File

@@ -20,11 +20,11 @@ import static org.mockito.Mockito.mock;
import javax.mail.Folder;
import org.springframework.messaging.Message;
import org.springframework.integration.mail.MailReceiver.MailReceiverContext;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.messaging.Message;
/**
* @author Marius Bogoevici
@@ -50,6 +50,10 @@ public class MailTestsHelper {
public static final String REPLY_TO = "replyTo@springframework.org";
private MailTestsHelper() {
super();
}
public static SimpleMailMessage createSimpleMailMessage() {
SimpleMailMessage message = new SimpleMailMessage();
message.setBcc(BCC);

View File

@@ -16,12 +16,13 @@
package org.springframework.integration.mongodb.config;
import org.w3c.dom.Element;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.integration.config.xml.IntegrationNamespaceUtils;
import org.springframework.util.StringUtils;
import org.w3c.dom.Element;
/**
* Utility class used by mongo parsers
*
@@ -31,6 +32,10 @@ import org.w3c.dom.Element;
*/
class MongoParserUtils {
private MongoParserUtils() {
super();
}
/**
* Will parse and validate
* 'mongodb-template', 'mongodb-factory', 'collection-name', 'collection-name-expression' and 'mongo-converter'

View File

@@ -25,6 +25,10 @@ package org.springframework.integration.mongodb.support;
*/
public class MongoHeaders {
private MongoHeaders() {
super();
}
public static final String PREFIX = "mongo_";
public static final String COLLECTION_NAME = PREFIX + "collectionName";

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014 the original author or authors.
* Copyright 2014-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,6 +27,10 @@ package org.springframework.integration.redis.support;
*/
public class RedisHeaders {
private RedisHeaders() {
super();
}
public static final String PREFIX = "redis_";
public static final String KEY = PREFIX + "key";

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,6 +31,10 @@ import org.springframework.security.core.context.SecurityContextImpl;
*/
public class SecurityTestUtils {
private SecurityTestUtils() {
super();
}
public static SecurityContext createContext(String username, String password, String... roles) {
SecurityContextImpl ctxImpl = new SecurityContextImpl();
UsernamePasswordAuthenticationToken authToken;

View File

@@ -20,9 +20,14 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
* @author Josh Long
* @author Gary Russell
*/
public class TestInboundSftp {
private TestInboundSftp() {
super();
}
static public void main(String[] args) throws Throwable {
ClassPathXmlApplicationContext classPathXmlApplicationContext = new ClassPathXmlApplicationContext("TestInboundSftp.xml");
classPathXmlApplicationContext.start();

View File

@@ -24,6 +24,10 @@ package org.springframework.integration.sftp.session;
*/
public class SftpTestSessionFactory {
private SftpTestSessionFactory() {
super();
}
public static SftpSession createSftpSession(com.jcraft.jsch.Session jschSession) {
SftpSession sftpSession = new SftpSession(jschSession);
sftpSession.connect();

View File

@@ -27,6 +27,10 @@ import org.springframework.integration.transformer.SyslogToMapTransformer;
*/
public class SyslogHeaders {
private SyslogHeaders() {
super();
}
public static String PREFIX = "syslog_";
public static final String FACILITY = PREFIX + SyslogToMapTransformer.FACILITY;

View File

@@ -68,6 +68,10 @@ import org.springframework.messaging.Message;
*/
public class MockitoMessageMatchers {
private MockitoMessageMatchers() {
super();
}
@SuppressWarnings("unchecked")
public static <T> Message<T> messageWithPayload(Matcher<T> payloadMatcher) {
return argThat(hasPayload(payloadMatcher));

View File

@@ -48,6 +48,10 @@ public class HeapDumper {
// field to store the hotspot diagnostic MBean
private static volatile HotSpotDiagnosticMXBean hotspotMBean;
private HeapDumper() {
super();
}
public static void dumpHeap(String fileName) {
dumpHeap(fileName, true);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,7 +17,11 @@
package org.springframework.integration.xml.config;
public class TestXmlApplicationContextHelper {
private TestXmlApplicationContextHelper() {
super();
}
public static TestXmlApplicationContext getTestAppContext(String xmlFragment) {
String xml = header + xmlFragment + footer;
TestXmlApplicationContext ctx = new TestXmlApplicationContext(xml);
@@ -30,7 +34,7 @@ public class TestXmlApplicationContextHelper {
+ "xmlns:si='http://www.springframework.org/schema/integration' "
+ "xmlns:util='http://www.springframework.org/schema/util' "
+ "xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' "
+ "xmlns:context='http://www.springframework.org/schema/context' "
+ "xmlns:context='http://www.springframework.org/schema/context' "
+ "xsi:schemaLocation="
+ "'http://www.springframework.org/schema/beans "
+ "http://www.springframework.org/schema/beans/spring-beans.xsd "

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,21 +25,26 @@ import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.dom.DOMSource;
import org.springframework.xml.transform.StringResult;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import org.springframework.xml.transform.StringResult;
/**
* Utility class for XML related testing
*
*
* @author Jonas Partner
*/
public class XmlTestUtil {
private XmlTestUtil() {
super();
}
public static Document getDocumentForString(String strDoc) throws Exception {
DocumentBuilderFactory builder = DocumentBuilderFactory.newInstance();
builder.setNamespaceAware(true);
return builder.newDocumentBuilder().parse(
new InputSource(new StringReader(strDoc)));
}
@@ -68,8 +73,8 @@ public class XmlTestUtil {
transform(source, stringResult);
return stringResult.toString();
}
public static void transform(Source source, Result res) throws Exception {
TransformerFactory.newInstance().newTransformer().transform(source, res);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2011 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,6 +27,11 @@ package org.springframework.integration.xmpp;
*/
public class XmppHeaders {
private XmppHeaders() {
super();
// TODO Auto-generated constructor stub
}
public static final String PREFIX = "xmpp_";
public static final String CHAT = PREFIX + "chat";

View File

@@ -44,7 +44,7 @@
<!-- Class Design -->
<!-- <module name="FinalClass" /> -->
<!-- <module name="InterfaceIsType" /> -->
<!-- <module name="HideUtilityClassConstructor" /> -->
<module name="HideUtilityClassConstructor" />
<!-- <module name="MutableException" /> -->
<!-- <module name="InnerTypeLast" /> -->
<!-- <module name="OneTopLevelClass" /> -->