Make fields immutable (final) where possible
This commit is contained in:
@@ -36,8 +36,8 @@ import org.apache.ftpserver.usermanager.impl.WritePermission;
|
||||
*
|
||||
*/
|
||||
public class TestUserManager extends AbstractUserManager {
|
||||
private BaseUser testUser;
|
||||
private BaseUser anonUser;
|
||||
private final BaseUser testUser;
|
||||
private final BaseUser anonUser;
|
||||
|
||||
private static final String TEST_USERNAME = "demo";
|
||||
private static final String TEST_PASSWORD = "demo";
|
||||
|
||||
@@ -42,7 +42,7 @@ import org.springframework.messaging.support.GenericMessage;
|
||||
*/
|
||||
public class HelloWorldApp {
|
||||
|
||||
private static Log logger = LogFactory.getLog(HelloWorldApp.class);
|
||||
private static final Log logger = LogFactory.getLog(HelloWorldApp.class);
|
||||
|
||||
public static void main(String[] args) {
|
||||
AbstractApplicationContext context = new ClassPathXmlApplicationContext("/META-INF/spring/integration/helloWorldDemo.xml", HelloWorldApp.class);
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
*/
|
||||
public class HttpClientDemo {
|
||||
|
||||
private static Log logger = LogFactory.getLog(HttpClientDemo.class);
|
||||
private static final Log logger = LogFactory.getLog(HttpClientDemo.class);
|
||||
|
||||
public static void main(String[] args) {
|
||||
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
|
||||
@@ -27,9 +27,9 @@ import java.util.Map;
|
||||
public enum Gender {
|
||||
|
||||
MALE("M"),FEMALE("F");
|
||||
private static Map<String, Gender> map;
|
||||
|
||||
private String identifier;
|
||||
private static final Map<String, Gender> map;
|
||||
|
||||
private final String identifier;
|
||||
|
||||
private Gender(String identifier) {
|
||||
this.identifier = identifier;
|
||||
@@ -37,12 +37,12 @@ public enum Gender {
|
||||
|
||||
public String getIdentifier() {
|
||||
return identifier;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static Gender getGenderByIdentifier(String identifier) {
|
||||
return map.get(identifier);
|
||||
}
|
||||
|
||||
|
||||
static {
|
||||
map = new HashMap<String, Gender>();
|
||||
for(Gender gender:EnumSet.allOf(Gender.class)) {
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
package org.springframework.integration.samples.jdbc.domain;
|
||||
|
||||
public class User {
|
||||
private String username;
|
||||
private String password;
|
||||
private String email;
|
||||
private final String username;
|
||||
private final String password;
|
||||
private final String email;
|
||||
|
||||
public User(String username, String password, String email) {
|
||||
super();
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.springframework.messaging.MessagingException;
|
||||
*
|
||||
*/
|
||||
public class GmailInboundImapIdleAdapterTestApp {
|
||||
private static Log logger = LogFactory.getLog(GmailInboundImapIdleAdapterTestApp.class);
|
||||
private static final Log logger = LogFactory.getLog(GmailInboundImapIdleAdapterTestApp.class);
|
||||
|
||||
|
||||
public static void main (String[] args) throws Exception {
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.springframework.messaging.MessagingException;
|
||||
*/
|
||||
public class GmailInboundPop3AdapterTestApp {
|
||||
|
||||
private static Log logger = LogFactory.getLog(GmailInboundPop3AdapterTestApp.class);
|
||||
private static final Log logger = LogFactory.getLog(GmailInboundPop3AdapterTestApp.class);
|
||||
|
||||
public static void main (String[] args) throws Exception {
|
||||
@SuppressWarnings("resource")
|
||||
|
||||
@@ -40,10 +40,10 @@ import org.springframework.integration.mqtt.core.DefaultMqttPahoClientFactory;
|
||||
*/
|
||||
public class BrokerRunning extends TestWatcher {
|
||||
|
||||
private static Log logger = LogFactory.getLog(BrokerRunning.class);
|
||||
private static final Log logger = LogFactory.getLog(BrokerRunning.class);
|
||||
|
||||
// Static so that we only test once on failure: speeds up test suite
|
||||
private static Map<Integer, Boolean> brokerOnline = new HashMap<>();
|
||||
private static final Map<Integer, Boolean> brokerOnline = new HashMap<>();
|
||||
|
||||
private final int port;
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ import org.springframework.integration.annotation.ServiceActivator;
|
||||
*/
|
||||
@MessageEndpoint
|
||||
public class EvenLogger {
|
||||
private static Log logger = LogFactory.getLog(EvenLogger.class);
|
||||
private static final Log logger = LogFactory.getLog(EvenLogger.class);
|
||||
|
||||
@ServiceActivator
|
||||
public void log(int i) {
|
||||
|
||||
@@ -34,7 +34,7 @@ import org.springframework.integration.annotation.ServiceActivator;
|
||||
*/
|
||||
@MessageEndpoint
|
||||
public class OddLogger {
|
||||
private static Log logger = LogFactory.getLog(OddLogger.class);
|
||||
private static final Log logger = LogFactory.getLog(OddLogger.class);
|
||||
|
||||
@ServiceActivator
|
||||
public void log(int i) {
|
||||
|
||||
@@ -23,9 +23,9 @@ import java.math.BigDecimal;
|
||||
*/
|
||||
public class Quote {
|
||||
|
||||
private String ticker;
|
||||
private final String ticker;
|
||||
|
||||
private BigDecimal price;
|
||||
private final BigDecimal price;
|
||||
|
||||
public Quote(String ticker, BigDecimal price) {
|
||||
this.ticker = ticker;
|
||||
|
||||
@@ -25,9 +25,9 @@ import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
*/
|
||||
public class CustomOrder {
|
||||
|
||||
private int number;
|
||||
private final int number;
|
||||
|
||||
private String sender;
|
||||
private final String sender;
|
||||
|
||||
private String message;
|
||||
|
||||
|
||||
@@ -25,16 +25,16 @@ import java.util.Map;
|
||||
*/
|
||||
public class Traffic {
|
||||
|
||||
private Map<String, String> incidents = new HashMap<String, String>();
|
||||
|
||||
private final Map<String, String> incidents = new HashMap<String, String>();
|
||||
|
||||
public void addIncident(String title, String description){
|
||||
incidents.put(title, description);
|
||||
}
|
||||
|
||||
|
||||
public Map<String, String> getIncidents(){
|
||||
return incidents;
|
||||
}
|
||||
|
||||
|
||||
public String toString(){
|
||||
return "Traffic: {" + incidents.keySet().toString() + "}";
|
||||
}
|
||||
|
||||
@@ -40,8 +40,8 @@ import org.w3c.dom.Node;
|
||||
* @since SpringOne2GX - 2010, Chicago
|
||||
*/
|
||||
public class TrafficHttpConverter implements HttpMessageConverter<Traffic> {
|
||||
private List<MediaType> supportedMediaTypes = Collections.emptyList();
|
||||
|
||||
private final List<MediaType> supportedMediaTypes = Collections.emptyList();
|
||||
|
||||
public boolean canRead(Class<?> clazz, MediaType mediaType) {
|
||||
return Traffic.class.equals(clazz);
|
||||
}
|
||||
|
||||
@@ -47,9 +47,9 @@ public class WeatherMarshaller implements Marshaller, Unmarshaller, Initializing
|
||||
|
||||
private static final TransformerFactory transformerFactory = TransformerFactory.newInstance();
|
||||
|
||||
private Map<String, String> namespacePrefixes = new HashMap<String, String>();
|
||||
private final Map<String, String> namespacePrefixes = new HashMap<String, String>();
|
||||
|
||||
private String xpathPrefix = "/p:GetCityWeatherByZIPResponse/p:GetCityWeatherByZIPResult/";
|
||||
private static final String XPATH_PREFIX = "/p:GetCityWeatherByZIPResponse/p:GetCityWeatherByZIPResult/";
|
||||
|
||||
public Object unmarshal(Source source) throws IOException, XmlMappingException {
|
||||
|
||||
@@ -63,16 +63,16 @@ public class WeatherMarshaller implements Marshaller, Unmarshaller, Initializing
|
||||
throw new MarshallingFailureException("Failed to unmarshal SOAP Response", e);
|
||||
}
|
||||
Weather weather = new Weather();
|
||||
String expression = xpathPrefix + "p:City";
|
||||
String expression = XPATH_PREFIX + "p:City";
|
||||
String city = XPathExpressionFactory.createXPathExpression(expression, namespacePrefixes).evaluateAsString(result.getNode());
|
||||
weather.setCity(city);
|
||||
expression = xpathPrefix + "p:State";
|
||||
expression = XPATH_PREFIX + "p:State";
|
||||
String state = XPathExpressionFactory.createXPathExpression(expression, namespacePrefixes).evaluateAsString(result.getNode());
|
||||
weather.setState(state);
|
||||
expression = xpathPrefix + "p:Temperature";
|
||||
expression = XPATH_PREFIX + "p:Temperature";
|
||||
String temperature = XPathExpressionFactory.createXPathExpression(expression, namespacePrefixes).evaluateAsString(result.getNode());
|
||||
weather.setTemperature(temperature);
|
||||
expression = xpathPrefix + "p:Description";
|
||||
expression = XPATH_PREFIX + "p:Description";
|
||||
String description = XPathExpressionFactory.createXPathExpression(expression, namespacePrefixes).evaluateAsString(result.getNode());
|
||||
weather.setDescription(description);
|
||||
return weather;
|
||||
|
||||
@@ -41,7 +41,7 @@ import org.springframework.xml.transform.StringSource;
|
||||
*/
|
||||
public class InContainerTests {
|
||||
|
||||
private static Log logger = LogFactory.getLog(InContainerTests.class);
|
||||
private static final Log logger = LogFactory.getLog(InContainerTests.class);
|
||||
private static final String WS_URI = "http://localhost:8080/ws-inbound-gateway/echoservice";
|
||||
private final WebServiceTemplate template = new WebServiceTemplate();
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.w3c.dom.Document;
|
||||
* @author Gary Russell
|
||||
*/
|
||||
public class ExternalResupply {
|
||||
private static Log logger = LogFactory.getLog(ExternalResupply.class);
|
||||
private static final Log logger = LogFactory.getLog(ExternalResupply.class);
|
||||
|
||||
public void orderResupply(Document resupplyOrder) {
|
||||
logger.info("Placing resupply order: \n" + XmlUtil.docAsString(resupplyOrder));
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.w3c.dom.Document;
|
||||
* @author Gary Russell
|
||||
*/
|
||||
public class WarehouseDispatch {
|
||||
private static Log logger = LogFactory.getLog(WarehouseDispatch.class);
|
||||
private static final Log logger = LogFactory.getLog(WarehouseDispatch.class);
|
||||
|
||||
public void dispatch(Document orderItem){
|
||||
logger.info("Warehouse dispatching orderItem: \n" + XmlUtil.docAsString(orderItem));
|
||||
|
||||
Reference in New Issue
Block a user