diff options
author | Ahmed Ashour <asashour@yahoo.com> | 2017-10-26 13:26:20 +0200 |
---|---|---|
committer | Pekka Maanpää <pekkamaa@vaadin.com> | 2017-10-26 14:26:20 +0300 |
commit | 10bd7544fd22dccd7e8e32cb236eb50f102892d3 (patch) | |
tree | d0e6f2241dc2b612a0deeceeb30399e88e47ed6a /server/src | |
parent | 7c8f440781835dbcf72bfbc47ab8be2f669a40e4 (diff) | |
download | vaadin-framework-10bd7544fd22dccd7e8e32cb236eb50f102892d3.tar.gz vaadin-framework-10bd7544fd22dccd7e8e32cb236eb50f102892d3.zip |
Improve naming of fields and variables (#10242)
* Variable names to conform to naming convention.
* Use static constants where it makes sense
Diffstat (limited to 'server/src')
27 files changed, 151 insertions, 153 deletions
diff --git a/server/src/main/java/com/vaadin/data/BeanPropertySet.java b/server/src/main/java/com/vaadin/data/BeanPropertySet.java index ae14c31d83..dcbff134d4 100644 --- a/server/src/main/java/com/vaadin/data/BeanPropertySet.java +++ b/server/src/main/java/com/vaadin/data/BeanPropertySet.java @@ -270,7 +270,7 @@ public class BeanPropertySet<T> implements PropertySet<T> { } } - private static final ConcurrentMap<Class<?>, BeanPropertySet<?>> instances = new ConcurrentHashMap<>(); + private static final ConcurrentMap<Class<?>, BeanPropertySet<?>> INSTANCES = new ConcurrentHashMap<>(); private final Class<T> beanType; @@ -306,7 +306,7 @@ public class BeanPropertySet<T> implements PropertySet<T> { Objects.requireNonNull(beanType, "Bean type cannot be null"); // Cache the reflection results - return (PropertySet<T>) instances.computeIfAbsent(beanType, + return (PropertySet<T>) INSTANCES.computeIfAbsent(beanType, BeanPropertySet::new); } diff --git a/server/src/main/java/com/vaadin/event/dd/acceptcriteria/AcceptAll.java b/server/src/main/java/com/vaadin/event/dd/acceptcriteria/AcceptAll.java index 6dfca521a4..d7684b0142 100644 --- a/server/src/main/java/com/vaadin/event/dd/acceptcriteria/AcceptAll.java +++ b/server/src/main/java/com/vaadin/event/dd/acceptcriteria/AcceptAll.java @@ -29,13 +29,13 @@ import com.vaadin.event.dd.DragAndDropEvent; public final class AcceptAll extends ClientSideCriterion { private static final long serialVersionUID = 7406683402153141461L; - private static final AcceptCriterion singleton = new AcceptAll(); + private static final AcceptCriterion SINGLETON = new AcceptAll(); private AcceptAll() { } public static AcceptCriterion get() { - return singleton; + return SINGLETON; } @Override diff --git a/server/src/main/java/com/vaadin/event/dd/acceptcriteria/SourceIsTarget.java b/server/src/main/java/com/vaadin/event/dd/acceptcriteria/SourceIsTarget.java index 8c4b82c0c7..292ac636a7 100644 --- a/server/src/main/java/com/vaadin/event/dd/acceptcriteria/SourceIsTarget.java +++ b/server/src/main/java/com/vaadin/event/dd/acceptcriteria/SourceIsTarget.java @@ -35,7 +35,7 @@ import com.vaadin.ui.Component; public class SourceIsTarget extends ClientSideCriterion { private static final long serialVersionUID = -451399314705532584L; - private static final SourceIsTarget instance = new SourceIsTarget(); + private static final SourceIsTarget INSTANCE = new SourceIsTarget(); private SourceIsTarget() { } @@ -52,7 +52,7 @@ public class SourceIsTarget extends ClientSideCriterion { } public static synchronized SourceIsTarget get() { - return instance; + return INSTANCE; } } diff --git a/server/src/main/java/com/vaadin/server/AbstractClientConnector.java b/server/src/main/java/com/vaadin/server/AbstractClientConnector.java index 9086bf2cc2..d194dce51c 100644 --- a/server/src/main/java/com/vaadin/server/AbstractClientConnector.java +++ b/server/src/main/java/com/vaadin/server/AbstractClientConnector.java @@ -99,7 +99,7 @@ public abstract class AbstractClientConnector * ShareState classes. Using WeakHashMap since entries are recalculated on * demand. */ - private static final Map<Class<? extends AbstractClientConnector>, Class<? extends SharedState>> stateTypeCache = Collections + private static final Map<Class<? extends AbstractClientConnector>, Class<? extends SharedState>> STATE_TYPE_CACHE = Collections .synchronizedMap(new WeakHashMap<>()); @Override @@ -315,7 +315,7 @@ public abstract class AbstractClientConnector // exceptions flying around if (stateType == null) { // Cache because we don't need to do this once per instance - stateType = stateTypeCache.computeIfAbsent(this.getClass(), + stateType = STATE_TYPE_CACHE.computeIfAbsent(this.getClass(), key -> findStateType()); } diff --git a/server/src/main/java/com/vaadin/server/ComponentSizeValidator.java b/server/src/main/java/com/vaadin/server/ComponentSizeValidator.java index 8fe7892c39..58761f1e10 100644 --- a/server/src/main/java/com/vaadin/server/ComponentSizeValidator.java +++ b/server/src/main/java/com/vaadin/server/ComponentSizeValidator.java @@ -371,13 +371,13 @@ public class ComponentSizeValidator implements Serializable { private static void showComponent(Component component, String attribute, StringBuilder err, StringBuilder indent, boolean widthError) { - FileLocation createLoc = creationLocations.get(component); + FileLocation createLoc = CREATION_LOCATIONS.get(component); FileLocation sizeLoc; if (widthError) { - sizeLoc = widthLocations.get(component); + sizeLoc = WIDTH_LOCATIONS.get(component); } else { - sizeLoc = heightLocations.get(component); + sizeLoc = HEIGHT_LOCATIONS.get(component); } err.append(indent); @@ -600,9 +600,9 @@ public class ComponentSizeValidator implements Serializable { } - private static final Map<Object, FileLocation> creationLocations = new HashMap<>(); - private static final Map<Object, FileLocation> widthLocations = new HashMap<>(); - private static final Map<Object, FileLocation> heightLocations = new HashMap<>(); + private static final Map<Object, FileLocation> CREATION_LOCATIONS = new HashMap<>(); + private static final Map<Object, FileLocation> WIDTH_LOCATIONS = new HashMap<>(); + private static final Map<Object, FileLocation> HEIGHT_LOCATIONS = new HashMap<>(); public static class FileLocation implements Serializable { public String method; @@ -622,15 +622,15 @@ public class ComponentSizeValidator implements Serializable { } public static void setCreationLocation(Object object) { - setLocation(creationLocations, object); + setLocation(CREATION_LOCATIONS, object); } public static void setWidthLocation(Object object) { - setLocation(widthLocations, object); + setLocation(WIDTH_LOCATIONS, object); } public static void setHeightLocation(Object object) { - setLocation(heightLocations, object); + setLocation(HEIGHT_LOCATIONS, object); } private static void setLocation(Map<Object, FileLocation> map, diff --git a/server/src/main/java/com/vaadin/server/DefaultSystemMessagesProvider.java b/server/src/main/java/com/vaadin/server/DefaultSystemMessagesProvider.java index 971587d74b..3acb1191f5 100644 --- a/server/src/main/java/com/vaadin/server/DefaultSystemMessagesProvider.java +++ b/server/src/main/java/com/vaadin/server/DefaultSystemMessagesProvider.java @@ -25,7 +25,7 @@ package com.vaadin.server; */ public class DefaultSystemMessagesProvider implements SystemMessagesProvider { - private static final DefaultSystemMessagesProvider instance = new DefaultSystemMessagesProvider(); + private static final DefaultSystemMessagesProvider INSTANCE = new DefaultSystemMessagesProvider(); private DefaultSystemMessagesProvider() { // Singleton @@ -43,7 +43,7 @@ public class DefaultSystemMessagesProvider implements SystemMessagesProvider { * @return the default system messages provider. */ public static SystemMessagesProvider get() { - return instance; + return INSTANCE; } } diff --git a/server/src/main/java/com/vaadin/server/GlobalResourceHandler.java b/server/src/main/java/com/vaadin/server/GlobalResourceHandler.java index 11e6832696..d8f312d4ea 100644 --- a/server/src/main/java/com/vaadin/server/GlobalResourceHandler.java +++ b/server/src/main/java/com/vaadin/server/GlobalResourceHandler.java @@ -60,7 +60,7 @@ public class GlobalResourceHandler implements RequestHandler { private int nextLegacyId = 0; // APP/global/[uiid]/[type]/[id] - private static final Pattern pattern = Pattern + private static final Pattern PATTERN = Pattern .compile("^/?" + ApplicationConstants.APP_PATH + '/' + RESOURCE_REQUEST_PATH + "(\\d+)/(([^/]+)(/.*))"); @@ -72,7 +72,7 @@ public class GlobalResourceHandler implements RequestHandler { return false; } - Matcher matcher = pattern.matcher(pathInfo); + Matcher matcher = PATTERN.matcher(pathInfo); if (!matcher.matches()) { return false; } diff --git a/server/src/main/java/com/vaadin/server/JsonCodec.java b/server/src/main/java/com/vaadin/server/JsonCodec.java index fc8e858b3b..5f26d14513 100644 --- a/server/src/main/java/com/vaadin/server/JsonCodec.java +++ b/server/src/main/java/com/vaadin/server/JsonCodec.java @@ -206,19 +206,19 @@ public class JsonCodec implements Serializable { * happens to process Vaadin requests, so it must be protected from * corruption caused by concurrent access. */ - private static final ConcurrentMap<Class<?>, Collection<BeanProperty>> typePropertyCache = new ConcurrentHashMap<>(); + private static final ConcurrentMap<Class<?>, Collection<BeanProperty>> TYPE_PROPERTY_CACHE = new ConcurrentHashMap<>(); - private static final Map<Class<?>, String> typeToTransportType = new HashMap<>(); + private static final Map<Class<?>, String> TYPE_TO_TRANSPORT_TYPE = new HashMap<>(); /** * Note! This does not contain primitives. * <p> */ - private static final Map<String, Class<?>> transportTypeToType = new HashMap<>(); + private static final Map<String, Class<?>> TRANSPORT_TYPE_TO_TYPE = new HashMap<>(); - private static final Map<Class<?>, JSONSerializer<?>> customSerializers = new HashMap<>(); + private static final Map<Class<?>, JSONSerializer<?>> CUSTOM_SERIALIZERS = new HashMap<>(); static { - customSerializers.put(Date.class, new DateSerializer()); + CUSTOM_SERIALIZERS.put(Date.class, new DateSerializer()); } static { @@ -244,14 +244,14 @@ public class JsonCodec implements Serializable { } private static void registerType(Class<?> type, String transportType) { - typeToTransportType.put(type, transportType); + TYPE_TO_TRANSPORT_TYPE.put(type, transportType); if (!type.isPrimitive()) { - transportTypeToType.put(transportType, type); + TRANSPORT_TYPE_TO_TYPE.put(transportType, type); } } public static boolean isInternalTransportType(String transportType) { - return transportTypeToType.containsKey(transportType); + return TRANSPORT_TYPE_TO_TYPE.containsKey(transportType); } public static boolean isInternalType(Type type) { @@ -267,7 +267,7 @@ public class JsonCodec implements Serializable { // value return true; } - return typeToTransportType.containsKey(getClassForType(type)); + return TYPE_TO_TRANSPORT_TYPE.containsKey(getClassForType(type)); } private static Class<?> getClassForType(Type type) { @@ -281,7 +281,7 @@ public class JsonCodec implements Serializable { } private static Class<?> getType(String transportType) { - return transportTypeToType.get(transportType); + return TRANSPORT_TYPE_TO_TYPE.get(transportType); } public static Object decodeInternalOrCustomType(Type targetType, @@ -329,8 +329,8 @@ public class JsonCodec implements Serializable { Class<?> classForType = getClassForType(targetType); return decodeEnum(classForType.asSubclass(Enum.class), (JsonString) value); - } else if (customSerializers.containsKey(getClassForType(targetType))) { - return customSerializers.get(getClassForType(targetType)) + } else if (CUSTOM_SERIALIZERS.containsKey(getClassForType(targetType))) { + return CUSTOM_SERIALIZERS.get(getClassForType(targetType)) .deserialize(targetType, value, connectorTracker); } else { return decodeObject(targetType, (JsonObject) value, @@ -669,7 +669,7 @@ public class JsonCodec implements Serializable { toReturn = Json.create(((Connector) value).getConnectorId()); } else if (value instanceof Enum) { toReturn = Json.create(((Enum<?>) value).name()); - } else if (customSerializers.containsKey(value.getClass())) { + } else if (CUSTOM_SERIALIZERS.containsKey(value.getClass())) { toReturn = serializeJson(value, connectorTracker); } else if (valueType instanceof GenericArrayType) { toReturn = encodeArrayContents( @@ -695,7 +695,7 @@ public class JsonCodec implements Serializable { public static Collection<BeanProperty> getProperties(Class<?> type) throws IntrospectionException { - Collection<BeanProperty> cachedProperties = typePropertyCache.get(type); + Collection<BeanProperty> cachedProperties = TYPE_PROPERTY_CACHE.get(type); if (cachedProperties != null) { return cachedProperties; } @@ -706,7 +706,7 @@ public class JsonCodec implements Serializable { // Doesn't matter if the same calculation is done multiple times from // different threads, so there's no need to do e.g. putIfAbsent - typePropertyCache.put(type, properties); + TYPE_PROPERTY_CACHE.put(type, properties); return properties; } @@ -982,12 +982,12 @@ public class JsonCodec implements Serializable { * of the hot part. */ private static String getInternalTransportType(Type valueType) { - return typeToTransportType.get(getClassForType(valueType)); + return TYPE_TO_TRANSPORT_TYPE.get(getClassForType(valueType)); } private static JsonValue serializeJson(Object value, ConnectorTracker connectorTracker) { - JSONSerializer serializer = customSerializers.get(value.getClass()); + JSONSerializer serializer = CUSTOM_SERIALIZERS.get(value.getClass()); return serializer.serialize(value, connectorTracker); } diff --git a/server/src/main/java/com/vaadin/server/LegacyCommunicationManager.java b/server/src/main/java/com/vaadin/server/LegacyCommunicationManager.java index cebb90a0ad..c66609b17b 100644 --- a/server/src/main/java/com/vaadin/server/LegacyCommunicationManager.java +++ b/server/src/main/java/com/vaadin/server/LegacyCommunicationManager.java @@ -82,7 +82,7 @@ public class LegacyCommunicationManager implements Serializable { return session; } - private static final ConcurrentHashMap<Class<? extends SharedState>, JsonValue> referenceDiffStates = new ConcurrentHashMap<>(); + private static final ConcurrentHashMap<Class<? extends SharedState>, JsonValue> REFERENCE_DIFF_STATES = new ConcurrentHashMap<>(); /** * @deprecated As of 7.1. See #11411. @@ -98,10 +98,10 @@ public class LegacyCommunicationManager implements Serializable { if (diffState == null) { // Use an empty state object as reference for full // repaints - diffState = referenceDiffStates.get(stateType); + diffState = REFERENCE_DIFF_STATES.get(stateType); if (diffState == null) { diffState = createReferenceDiffStateState(stateType); - referenceDiffStates.put(stateType, diffState); + REFERENCE_DIFF_STATES.put(stateType, diffState); } } EncodeResult encodeResult = JsonCodec.encode(state, diffState, diff --git a/server/src/main/java/com/vaadin/server/LegacyVaadinPortlet.java b/server/src/main/java/com/vaadin/server/LegacyVaadinPortlet.java index 831239096a..56a1d7b806 100644 --- a/server/src/main/java/com/vaadin/server/LegacyVaadinPortlet.java +++ b/server/src/main/java/com/vaadin/server/LegacyVaadinPortlet.java @@ -24,7 +24,7 @@ import com.vaadin.util.ReflectTools; public class LegacyVaadinPortlet extends VaadinPortlet { - private static final LegacyApplicationUIProvider provider = new LegacyApplicationUIProvider() { + private static final LegacyApplicationUIProvider PROVIDER = new LegacyApplicationUIProvider() { @Override protected LegacyApplication createApplication() { VaadinPortlet portlet = VaadinPortlet.getCurrent(); @@ -80,7 +80,7 @@ public class LegacyVaadinPortlet extends VaadinPortlet { private void onVaadinSessionStarted(VaadinPortletRequest request, VaadinPortletSession session) throws PortletException { - session.addUIProvider(provider); + session.addUIProvider(PROVIDER); } protected boolean shouldCreateApplication(PortletRequest request) { diff --git a/server/src/main/java/com/vaadin/server/LegacyVaadinServlet.java b/server/src/main/java/com/vaadin/server/LegacyVaadinServlet.java index 70174fdc32..b5da2da2a4 100644 --- a/server/src/main/java/com/vaadin/server/LegacyVaadinServlet.java +++ b/server/src/main/java/com/vaadin/server/LegacyVaadinServlet.java @@ -24,7 +24,7 @@ import com.vaadin.util.ReflectTools; public class LegacyVaadinServlet extends VaadinServlet { - private static final UIProvider provider = new LegacyApplicationUIProvider() { + private static final UIProvider PROVIDER = new LegacyApplicationUIProvider() { @Override protected LegacyApplication createApplication() { @@ -84,7 +84,7 @@ public class LegacyVaadinServlet extends VaadinServlet { private void onVaadinSessionStarted(VaadinRequest request, VaadinSession session) throws ServletException { - session.addUIProvider(provider); + session.addUIProvider(PROVIDER); } } diff --git a/server/src/main/java/com/vaadin/server/LocaleService.java b/server/src/main/java/com/vaadin/server/LocaleService.java index 9ec7e1282f..dac57a1bd7 100644 --- a/server/src/main/java/com/vaadin/server/LocaleService.java +++ b/server/src/main/java/com/vaadin/server/LocaleService.java @@ -177,15 +177,15 @@ public class LocaleService implements Serializable { localeData.dateFormat = datePattern.trim(); - final boolean twelve_hour_clock = timePattern.indexOf("a") > -1; + final boolean twelveHourClock = timePattern.indexOf("a") > -1; // TODO there are other possibilities as well, like 'h' in french // (ignore them, too complicated) - final String hour_min_delimiter = timePattern.indexOf(".") > -1 ? "." + final String hourMinDelimiter = timePattern.indexOf(".") > -1 ? "." : ":"; - localeData.twelveHourClock = twelve_hour_clock; - localeData.hourMinuteDelimiter = hour_min_delimiter; - if (twelve_hour_clock) { + localeData.twelveHourClock = twelveHourClock; + localeData.hourMinuteDelimiter = hourMinDelimiter; + if (twelveHourClock) { final String[] ampm = dfs.getAmPmStrings(); localeData.am = ampm[0]; localeData.pm = ampm[1]; diff --git a/server/src/main/java/com/vaadin/server/ServerRpcManager.java b/server/src/main/java/com/vaadin/server/ServerRpcManager.java index 30c8ec48ba..ba6d0b6ee5 100644 --- a/server/src/main/java/com/vaadin/server/ServerRpcManager.java +++ b/server/src/main/java/com/vaadin/server/ServerRpcManager.java @@ -68,7 +68,7 @@ public class ServerRpcManager<T extends ServerRpc> implements Serializable { } - private static final Map<Class<?>, Class<?>> boxedTypes = new HashMap<>(); + private static final Map<Class<?>, Class<?>> BOXED_TYPES = new HashMap<>(); static { try { Class<?>[] boxClasses = new Class<?>[] { Boolean.class, Byte.class, @@ -77,7 +77,7 @@ public class ServerRpcManager<T extends ServerRpc> implements Serializable { for (Class<?> boxClass : boxClasses) { Field typeField = boxClass.getField("TYPE"); Class<?> primitiveType = (Class<?>) typeField.get(boxClass); - boxedTypes.put(primitiveType, boxClass); + BOXED_TYPES.put(primitiveType, boxClass); } } catch (Exception e) { throw new RuntimeException(e); diff --git a/server/src/main/java/com/vaadin/server/ServerRpcMethodInvocation.java b/server/src/main/java/com/vaadin/server/ServerRpcMethodInvocation.java index f4e2b4064d..98b436f489 100644 --- a/server/src/main/java/com/vaadin/server/ServerRpcMethodInvocation.java +++ b/server/src/main/java/com/vaadin/server/ServerRpcMethodInvocation.java @@ -24,7 +24,7 @@ import com.vaadin.shared.communication.ServerRpc; public class ServerRpcMethodInvocation extends MethodInvocation { - private static final Map<String, Method> invocationMethodCache = new ConcurrentHashMap<>( + private static final Map<String, Method> INVOCATION_METHOD_CACHE = new ConcurrentHashMap<>( 128, 0.75f, 1); private final Method method; @@ -67,14 +67,14 @@ public class ServerRpcMethodInvocation extends MethodInvocation { // signature String signature = targetType.getName() + "." + methodName + "(" + parameterCount; - Method invocationMethod = invocationMethodCache.get(signature); + Method invocationMethod = INVOCATION_METHOD_CACHE.get(signature); if (invocationMethod == null) { invocationMethod = doFindInvocationMethod(targetType, methodName, parameterCount); if (invocationMethod != null) { - invocationMethodCache.put(signature, invocationMethod); + INVOCATION_METHOD_CACHE.put(signature, invocationMethod); } } diff --git a/server/src/main/java/com/vaadin/server/SizeWithUnit.java b/server/src/main/java/com/vaadin/server/SizeWithUnit.java index 935f7dd050..57765164e1 100644 --- a/server/src/main/java/com/vaadin/server/SizeWithUnit.java +++ b/server/src/main/java/com/vaadin/server/SizeWithUnit.java @@ -32,7 +32,7 @@ import com.vaadin.shared.util.SharedUtil; public class SizeWithUnit implements Serializable { private final float size; private final Unit unit; - private static final Pattern sizePattern = Pattern + private static final Pattern SIZE_PATTERN = Pattern .compile(SharedUtil.SIZE_PATTERN); /** @@ -90,7 +90,7 @@ public class SizeWithUnit implements Serializable { } float size = 0; Unit unit = null; - Matcher matcher = sizePattern.matcher(s); + Matcher matcher = SIZE_PATTERN.matcher(s); if (matcher.find()) { size = Float.parseFloat(matcher.group(1)); if (size < 0) { @@ -107,7 +107,7 @@ public class SizeWithUnit implements Serializable { } } else { throw new IllegalArgumentException("Invalid size argument: \"" + s - + "\" (should match " + sizePattern.pattern() + ")"); + + "\" (should match " + SIZE_PATTERN.pattern() + ")"); } return new SizeWithUnit(size, unit); } diff --git a/server/src/main/java/com/vaadin/server/StreamResource.java b/server/src/main/java/com/vaadin/server/StreamResource.java index 6b8f36ba54..9b6e02d0f6 100644 --- a/server/src/main/java/com/vaadin/server/StreamResource.java +++ b/server/src/main/java/com/vaadin/server/StreamResource.java @@ -41,7 +41,7 @@ public class StreamResource implements ConnectorResource { /** * Explicit mime-type. */ - private String MIMEType = null; + private String mimeType = null; /** * Filename. @@ -76,8 +76,8 @@ public class StreamResource implements ConnectorResource { */ @Override public String getMIMEType() { - if (MIMEType != null) { - return MIMEType; + if (mimeType != null) { + return mimeType; } return FileTypeResolver.getMIMEType(filename); } @@ -85,11 +85,11 @@ public class StreamResource implements ConnectorResource { /** * Sets the mime type of the resource. * - * @param MIMEType + * @param mimeType * the MIME type to be set. */ - public void setMIMEType(String MIMEType) { - this.MIMEType = MIMEType; + public void setMIMEType(String mimeType) { + this.mimeType = mimeType; } /** @@ -223,7 +223,7 @@ public class StreamResource implements ConnectorResource { } else if (obj instanceof StreamResource) { StreamResource that = (StreamResource) obj; return SharedUtil.equals(getStreamSource(), that.getStreamSource()) - && SharedUtil.equals(MIMEType, that.MIMEType) + && SharedUtil.equals(mimeType, that.mimeType) && SharedUtil.equals(getFilename(), that.getFilename()) && getBufferSize() == that.getBufferSize() && getCacheTime() == that.getCacheTime(); @@ -234,7 +234,7 @@ public class StreamResource implements ConnectorResource { @Override public int hashCode() { - return Arrays.hashCode(new Object[] { getStreamSource(), MIMEType, + return Arrays.hashCode(new Object[] { getStreamSource(), mimeType, getFilename(), getBufferSize(), getCacheTime() }); } diff --git a/server/src/main/java/com/vaadin/server/widgetsetutils/ClassPathExplorer.java b/server/src/main/java/com/vaadin/server/widgetsetutils/ClassPathExplorer.java index 74f8e1d013..31053fa778 100644 --- a/server/src/main/java/com/vaadin/server/widgetsetutils/ClassPathExplorer.java +++ b/server/src/main/java/com/vaadin/server/widgetsetutils/ClassPathExplorer.java @@ -92,15 +92,15 @@ public class ClassPathExplorer { * entries that could include widgets/widgetsets are listed (primarily * directories, Vaadin JARs and add-on JARs). */ - private static final List<String> rawClasspathEntries = getRawClasspathEntries(); + private static final List<String> RAW_CLASSPATH_ENTRIES = getRawClasspathEntries(); /** * Map from identifiers (either a package name preceded by the path and a * slash, or a URL for a JAR file) to the corresponding URLs. This is * constructed from the class path. */ - private static final Map<String, URL> classpathLocations = getClasspathLocations( - rawClasspathEntries); + private static final Map<String, URL> CLASSPATH_LOCATIONS = getClasspathLocations( + RAW_CLASSPATH_ENTRIES); private static boolean debug = false; @@ -138,7 +138,7 @@ public class ClassPathExplorer { long start = System.currentTimeMillis(); Map<String, URL> widgetsets = new HashMap<>(); Map<String, URL> themes = new HashMap<>(); - Set<String> keySet = classpathLocations.keySet(); + Set<String> keySet = CLASSPATH_LOCATIONS.keySet(); for (String location : keySet) { searchForWidgetSetsAndAddonStyles(location, widgetsets, themes); } @@ -179,16 +179,16 @@ public class ClassPathExplorer { * "Vaadin-Widgetsets" attribute in its manifest are added to widgetsets. * * @param locationString - * an entry in {@link #classpathLocations} + * an entry in {@link #CLASSPATH_LOCATIONS} * @param widgetsets * a map from widgetset name (including package, with dots as - * separators) to a URL (see {@link #classpathLocations}) - new + * separators) to a URL (see {@link #CLASSPATH_LOCATIONS}) - new * entries are added to this map */ private static void searchForWidgetSetsAndAddonStyles(String locationString, Map<String, URL> widgetsets, Map<String, URL> addonStyles) { - URL location = classpathLocations.get(locationString); + URL location = CLASSPATH_LOCATIONS.get(locationString); File directory = new File(location.getFile()); if (directory.exists() && !directory.isHidden()) { @@ -329,12 +329,12 @@ public class ClassPathExplorer { * Determine every URL location defined by the current classpath, and it's * associated package name. * - * See {@link #classpathLocations} for information on output format. + * See {@link #CLASSPATH_LOCATIONS} for information on output format. * * @param rawClasspathEntries * raw class path entries as split from the Java class path * string - * @return map of classpath locations, see {@link #classpathLocations} + * @return map of classpath locations, see {@link #CLASSPATH_LOCATIONS} */ private static final Map<String, URL> getClasspathLocations( List<String> rawClasspathEntries) { @@ -419,7 +419,7 @@ public class ClassPathExplorer { /** * Recursively add subdirectories and jar files to locations - see - * {@link #classpathLocations}. + * {@link #CLASSPATH_LOCATIONS}. * * @param name * @param file @@ -465,7 +465,7 @@ public class ClassPathExplorer { } /** - * Add a jar file to locations - see {@link #classpathLocations}. + * Add a jar file to locations - see {@link #CLASSPATH_LOCATIONS}. * * @param file * @param locations @@ -522,14 +522,14 @@ public class ClassPathExplorer { if (debug) { debug("classpathLocations values:"); List<String> locations = new ArrayList<>( - classpathLocations.keySet()); + CLASSPATH_LOCATIONS.keySet()); for (String location : locations) { - debug(String.valueOf(classpathLocations.get(location))); + debug(String.valueOf(CLASSPATH_LOCATIONS.get(location))); } } URL firstDirectory = null; - for (String entry : rawClasspathEntries) { + for (String entry : RAW_CLASSPATH_ENTRIES) { File directory = new File(entry); if (directory.exists() && !directory.isHidden() diff --git a/server/src/main/java/com/vaadin/ui/AbstractComponent.java b/server/src/main/java/com/vaadin/ui/AbstractComponent.java index 7a87230125..89dd61986a 100644 --- a/server/src/main/java/com/vaadin/ui/AbstractComponent.java +++ b/server/src/main/java/com/vaadin/ui/AbstractComponent.java @@ -1251,7 +1251,7 @@ public abstract class AbstractComponent extends AbstractClientConnector * implementation */ protected Collection<String> getCustomAttributes() { - List<String> l = new ArrayList<>(Arrays.asList(customAttributes)); + List<String> l = new ArrayList<>(Arrays.asList(CUSTOM_ATTRIBUTES)); if (this instanceof Focusable) { l.add("tab-index"); l.add("tabindex"); @@ -1259,7 +1259,7 @@ public abstract class AbstractComponent extends AbstractClientConnector return l; } - private static final String[] customAttributes = { "width", "height", + private static final String[] CUSTOM_ATTRIBUTES = { "width", "height", "debug-id", "error", "width-auto", "height-auto", "width-full", "height-full", "size-auto", "size-full", "immediate", "locale", "read-only", "_id" }; diff --git a/server/src/main/java/com/vaadin/ui/Upload.java b/server/src/main/java/com/vaadin/ui/Upload.java index 9096d8bc40..b8ae510059 100644 --- a/server/src/main/java/com/vaadin/ui/Upload.java +++ b/server/src/main/java/com/vaadin/ui/Upload.java @@ -280,15 +280,15 @@ public class Upload extends AbstractComponent * the source of the file. * @param filename * the received file name. - * @param MIMEType + * @param mimeType * the MIME type of the received file. * @param length * the length of the received file. */ - public FinishedEvent(Upload source, String filename, String MIMEType, + public FinishedEvent(Upload source, String filename, String mimeType, long length) { super(source); - type = MIMEType; + type = mimeType; this.filename = filename; this.length = length; } @@ -346,13 +346,13 @@ public class Upload extends AbstractComponent * * @param source * @param filename - * @param MIMEType + * @param mimeType * @param length * @param reason */ - public FailedEvent(Upload source, String filename, String MIMEType, + public FailedEvent(Upload source, String filename, String mimeType, long length, Exception reason) { - this(source, filename, MIMEType, length); + this(source, filename, mimeType, length); this.reason = reason; } @@ -360,12 +360,12 @@ public class Upload extends AbstractComponent * * @param source * @param filename - * @param MIMEType + * @param mimeType * @param length */ - public FailedEvent(Upload source, String filename, String MIMEType, + public FailedEvent(Upload source, String filename, String mimeType, long length) { - super(source, filename, MIMEType, length); + super(source, filename, mimeType, length); } /** @@ -388,12 +388,12 @@ public class Upload extends AbstractComponent * * @param source * @param filename - * @param MIMEType + * @param mimeType * @param length */ public NoOutputStreamEvent(Upload source, String filename, - String MIMEType, long length) { - super(source, filename, MIMEType, length); + String mimeType, long length) { + super(source, filename, mimeType, length); } } @@ -406,14 +406,13 @@ public class Upload extends AbstractComponent * * @param source * @param filename - * @param MIMEType + * @param mimeType * @param length */ public NoInputStreamEvent(Upload source, String filename, - String MIMEType, long length) { - super(source, filename, MIMEType, length); + String mimeType, long length) { + super(source, filename, mimeType, length); } - } /** @@ -429,14 +428,13 @@ public class Upload extends AbstractComponent * * @param source * @param filename - * @param MIMEType + * @param mimeType * @param length */ - public SucceededEvent(Upload source, String filename, String MIMEType, + public SucceededEvent(Upload source, String filename, String mimeType, long length) { - super(source, filename, MIMEType, length); + super(source, filename, mimeType, length); } - } /** @@ -458,14 +456,14 @@ public class Upload extends AbstractComponent * * @param source * @param filename - * @param MIMEType + * @param mimeType * @param contentLength */ - public StartedEvent(Upload source, String filename, String MIMEType, + public StartedEvent(Upload source, String filename, String mimeType, long contentLength) { super(source); this.filename = filename; - type = MIMEType; + type = mimeType; length = contentLength; } @@ -783,10 +781,10 @@ public class Upload extends AbstractComponent * Emit upload received event. * * @param filename - * @param MIMEType + * @param mimeType */ - protected void fireStarted(String filename, String MIMEType) { - fireEvent(new Upload.StartedEvent(this, filename, MIMEType, + protected void fireStarted(String filename, String mimeType) { + fireEvent(new Upload.StartedEvent(this, filename, mimeType, contentLength)); } @@ -794,29 +792,29 @@ public class Upload extends AbstractComponent * Emits the upload failed event. * * @param filename - * @param MIMEType + * @param mimeType * @param length */ - protected void fireUploadInterrupted(String filename, String MIMEType, + protected void fireUploadInterrupted(String filename, String mimeType, long length) { - fireEvent(new Upload.FailedEvent(this, filename, MIMEType, length)); + fireEvent(new Upload.FailedEvent(this, filename, mimeType, length)); } - protected void fireNoInputStream(String filename, String MIMEType, + protected void fireNoInputStream(String filename, String mimeType, long length) { - fireEvent(new Upload.NoInputStreamEvent(this, filename, MIMEType, + fireEvent(new Upload.NoInputStreamEvent(this, filename, mimeType, length)); } - protected void fireNoOutputStream(String filename, String MIMEType, + protected void fireNoOutputStream(String filename, String mimeType, long length) { - fireEvent(new Upload.NoOutputStreamEvent(this, filename, MIMEType, + fireEvent(new Upload.NoOutputStreamEvent(this, filename, mimeType, length)); } - protected void fireUploadInterrupted(String filename, String MIMEType, + protected void fireUploadInterrupted(String filename, String mimeType, long length, Exception e) { - fireEvent(new Upload.FailedEvent(this, filename, MIMEType, length, e)); + fireEvent(new Upload.FailedEvent(this, filename, mimeType, length, e)); } /** diff --git a/server/src/main/java/com/vaadin/ui/declarative/DesignAttributeHandler.java b/server/src/main/java/com/vaadin/ui/declarative/DesignAttributeHandler.java index c508b693f8..4115edfde0 100644 --- a/server/src/main/java/com/vaadin/ui/declarative/DesignAttributeHandler.java +++ b/server/src/main/java/com/vaadin/ui/declarative/DesignAttributeHandler.java @@ -59,7 +59,7 @@ public class DesignAttributeHandler implements Serializable { return Logger.getLogger(DesignAttributeHandler.class.getName()); } - private static final Map<Class<?>, AttributeCacheEntry> cache = new ConcurrentHashMap<>(); + private static final Map<Class<?>, AttributeCacheEntry> CACHE = new ConcurrentHashMap<>(); // translates string <-> object private static final DesignFormatter FORMATTER = new DesignFormatter(); @@ -145,7 +145,7 @@ public class DesignAttributeHandler implements Serializable { */ public static Collection<String> getSupportedAttributes(Class<?> clazz) { resolveSupportedAttributes(clazz); - return cache.get(clazz).getAttributes(); + return CACHE.get(clazz).getAttributes(); } /** @@ -160,7 +160,7 @@ public class DesignAttributeHandler implements Serializable { if (clazz == null) { throw new IllegalArgumentException("The clazz can not be null"); } - if (cache.containsKey(clazz)) { + if (CACHE.containsKey(clazz)) { // NO-OP return; } @@ -184,7 +184,7 @@ public class DesignAttributeHandler implements Serializable { entry.addAttribute(attribute, getter, setter); } } - cache.put(clazz, entry); + CACHE.put(clazz, entry); } /** @@ -413,7 +413,7 @@ public class DesignAttributeHandler implements Serializable { private static Method findSetterForAttribute(Class<?> clazz, String attribute) { resolveSupportedAttributes(clazz); - return cache.get(clazz).getSetter(attribute); + return CACHE.get(clazz).getSetter(attribute); } /** @@ -429,7 +429,7 @@ public class DesignAttributeHandler implements Serializable { private static Method findGetterForAttribute(Class<?> clazz, String attribute) { resolveSupportedAttributes(clazz); - return cache.get(clazz).getGetter(attribute); + return CACHE.get(clazz).getGetter(attribute); } /** diff --git a/server/src/main/java/com/vaadin/ui/declarative/converters/DesignResourceConverter.java b/server/src/main/java/com/vaadin/ui/declarative/converters/DesignResourceConverter.java index 11ed3c259b..46eecde33f 100644 --- a/server/src/main/java/com/vaadin/ui/declarative/converters/DesignResourceConverter.java +++ b/server/src/main/java/com/vaadin/ui/declarative/converters/DesignResourceConverter.java @@ -185,22 +185,22 @@ public class DesignResourceConverter implements Converter<String, Resource> { return ((ExternalResource) value).getURL(); } - private static final Map<Class<? extends Resource>, ResourceConverterByProtocol> typeToConverter = new HashMap<>(); + private static final Map<Class<? extends Resource>, ResourceConverterByProtocol> TYPE_TO_CONVERTER = new HashMap<>(); static { - typeToConverter.put(ExternalResource.class, HTTP); + TYPE_TO_CONVERTER.put(ExternalResource.class, HTTP); // ^ any of non-specialized would actually work - typeToConverter.put(ThemeResource.class, THEME); - typeToConverter.put(FontIcon.class, FONTICON); - typeToConverter.put(FileResource.class, FILE); + TYPE_TO_CONVERTER.put(ThemeResource.class, THEME); + TYPE_TO_CONVERTER.put(FontIcon.class, FONTICON); + TYPE_TO_CONVERTER.put(FileResource.class, FILE); } public static ResourceConverterByProtocol byType( Class<? extends Resource> resourceType) { - for (Class<?> type : typeToConverter.keySet()) { + for (Class<?> type : TYPE_TO_CONVERTER.keySet()) { if (type.isAssignableFrom(resourceType)) { - return typeToConverter.get(type); + return TYPE_TO_CONVERTER.get(type); } } return null; diff --git a/server/src/main/java/com/vaadin/util/CurrentInstance.java b/server/src/main/java/com/vaadin/util/CurrentInstance.java index 8c3d93993a..0c15abc9ae 100644 --- a/server/src/main/java/com/vaadin/util/CurrentInstance.java +++ b/server/src/main/java/com/vaadin/util/CurrentInstance.java @@ -58,7 +58,7 @@ public class CurrentInstance implements Serializable { private final WeakReference<Object> instance; - private static final ThreadLocal<Map<Class<?>, CurrentInstance>> instances = new ThreadLocal<>(); + private static final ThreadLocal<Map<Class<?>, CurrentInstance>> INSTANCES = new ThreadLocal<>(); private CurrentInstance(Object instance) { this.instance = new WeakReference<>(instance); @@ -73,7 +73,7 @@ public class CurrentInstance implements Serializable { * if there is no current instance. */ public static <T> T get(Class<T> type) { - Map<Class<?>, CurrentInstance> map = instances.get(); + Map<Class<?>, CurrentInstance> map = INSTANCES.get(); if (map == null) { return null; } @@ -97,7 +97,7 @@ public class CurrentInstance implements Serializable { removeStaleInstances(map); if (map.isEmpty()) { - instances.remove(); + INSTANCES.remove(); } return null; @@ -135,14 +135,14 @@ public class CurrentInstance implements Serializable { * the actual instance */ public static <T> CurrentInstance set(Class<T> type, T instance) { - Map<Class<?>, CurrentInstance> map = instances.get(); + Map<Class<?>, CurrentInstance> map = INSTANCES.get(); CurrentInstance previousInstance = null; if (instance == null) { // remove the instance if (map != null) { previousInstance = map.remove(type); if (map.isEmpty()) { - instances.remove(); + INSTANCES.remove(); map = null; } } @@ -150,7 +150,7 @@ public class CurrentInstance implements Serializable { assert type.isInstance(instance) : "Invald instance type"; if (map == null) { map = new HashMap<>(); - instances.set(map); + INSTANCES.set(map); } previousInstance = map.put(type, new CurrentInstance(instance)); @@ -165,7 +165,7 @@ public class CurrentInstance implements Serializable { * Clears all current instances. */ public static void clearAll() { - instances.remove(); + INSTANCES.remove(); } /** @@ -220,7 +220,7 @@ public class CurrentInstance implements Serializable { * @return a map containing the current instances */ public static Map<Class<?>, CurrentInstance> getInstances() { - Map<Class<?>, CurrentInstance> map = instances.get(); + Map<Class<?>, CurrentInstance> map = INSTANCES.get(); if (map == null) { return Collections.emptyMap(); } else { @@ -237,7 +237,7 @@ public class CurrentInstance implements Serializable { if (removeStale) { removeStaleInstances(map); if (map.isEmpty()) { - instances.remove(); + INSTANCES.remove(); } } return copy; diff --git a/server/src/main/java/com/vaadin/util/FileTypeResolver.java b/server/src/main/java/com/vaadin/util/FileTypeResolver.java index 48d7916967..8abaec0490 100644 --- a/server/src/main/java/com/vaadin/util/FileTypeResolver.java +++ b/server/src/main/java/com/vaadin/util/FileTypeResolver.java @@ -54,7 +54,7 @@ public class FileTypeResolver implements Serializable { /** * Initial file extension to mime-type mapping. */ - private static final String initialExtToMIMEMap = "application/cu-seeme csm cu," + private static final String INITIAL_EXT_TO_MIME_MAP = "application/cu-seeme csm cu," + "application/dsptype tsp," + "application/futuresplash spl," + "application/mac-binhex40 hqx," @@ -221,7 +221,7 @@ public class FileTypeResolver implements Serializable { static { // Initialize extension to MIME map - final StringTokenizer lines = new StringTokenizer(initialExtToMIMEMap, + final StringTokenizer lines = new StringTokenizer(INITIAL_EXT_TO_MIME_MAP, ","); while (lines.hasMoreTokens()) { final String line = lines.nextToken(); @@ -356,24 +356,24 @@ public class FileTypeResolver implements Serializable { * @param extension * the filename extension to be associated with * <code>MIMEType</code>. - * @param MIMEType + * @param mimeType * the new mime-type for <code>extension</code>. */ - public static void addExtension(String extension, String MIMEType) { - EXT_TO_MIME_MAP.put(extension.toLowerCase(Locale.ROOT), MIMEType); + public static void addExtension(String extension, String mimeType) { + EXT_TO_MIME_MAP.put(extension.toLowerCase(Locale.ROOT), mimeType); } /** * Adds a icon for the given mime-type. If the mime-type also has a * corresponding icon, it is replaced with the new icon. * - * @param MIMEType + * @param mimeType * the mime-type whose icon is to be changed. * @param icon * the new icon to be associated with <code>MIMEType</code>. */ - public static void addIcon(String MIMEType, Resource icon) { - MIME_TO_ICON_MAP.put(MIMEType, icon); + public static void addIcon(String mimeType, Resource icon) { + MIME_TO_ICON_MAP.put(mimeType, icon); } /** diff --git a/server/src/main/java/com/vaadin/util/TimeZoneUtil.java b/server/src/main/java/com/vaadin/util/TimeZoneUtil.java index c3c25b21e4..fb56c3688e 100644 --- a/server/src/main/java/com/vaadin/util/TimeZoneUtil.java +++ b/server/src/main/java/com/vaadin/util/TimeZoneUtil.java @@ -104,7 +104,7 @@ public final class TimeZoneUtil implements Serializable { } info.id = zoneId.getId(); info.transitions = transitionsList.stream().mapToLong(l -> l).toArray(); - info.std_offset = (int) Duration.ofMillis(timeZone.getRawOffset()) + info.stdOffset = (int) Duration.ofMillis(timeZone.getRawOffset()) .toMinutes(); info.names = new String[] { timeZone.getDisplayName(false, TimeZone.SHORT, locale), @@ -119,7 +119,7 @@ public final class TimeZoneUtil implements Serializable { JreJsonFactory factory = new JreJsonFactory(); JsonObject object = factory.createObject(); object.put("id", info.id); - object.put("std_offset", info.std_offset); + object.put("std_offset", info.stdOffset); object.put("names", getArray(factory, info.names)); object.put("transitions", getArray(factory, info.transitions)); return JsonUtil.stringify(object); @@ -143,7 +143,7 @@ public final class TimeZoneUtil implements Serializable { private static class TimeZoneInfo implements Serializable { String id; - int std_offset; + int stdOffset; String[] names; long[] transitions; } diff --git a/server/src/test/java/com/vaadin/data/BeanPropertySetTest.java b/server/src/test/java/com/vaadin/data/BeanPropertySetTest.java index 7b492ad012..d7bc8f4c44 100644 --- a/server/src/test/java/com/vaadin/data/BeanPropertySetTest.java +++ b/server/src/test/java/com/vaadin/data/BeanPropertySetTest.java @@ -66,7 +66,7 @@ public class BeanPropertySetTest { // Simulate deserializing into a different JVM by clearing the instance // map Field instancesField = BeanPropertySet.class - .getDeclaredField("instances"); + .getDeclaredField("INSTANCES"); instancesField.setAccessible(true); Map<?, ?> instances = (Map<?, ?>) instancesField.get(null); instances.clear(); diff --git a/server/src/test/java/com/vaadin/server/AbstractClientConnectorTest.java b/server/src/test/java/com/vaadin/server/AbstractClientConnectorTest.java index b4e4f95194..368595ef27 100644 --- a/server/src/test/java/com/vaadin/server/AbstractClientConnectorTest.java +++ b/server/src/test/java/com/vaadin/server/AbstractClientConnectorTest.java @@ -88,7 +88,7 @@ public class AbstractClientConnectorTest { NoSuchFieldException, SecurityException, InterruptedException, ClassNotFoundException { Field stateTypeCacheField = AbstractClientConnector.class - .getDeclaredField("stateTypeCache"); + .getDeclaredField("STATE_TYPE_CACHE"); stateTypeCacheField.setAccessible(true); Map<Class<?>, ?> stateTypeCache = (Map<Class<?>, ?>) stateTypeCacheField .get(null); diff --git a/server/src/test/java/com/vaadin/util/CurrentInstanceTest.java b/server/src/test/java/com/vaadin/util/CurrentInstanceTest.java index 74b8ce7e6d..34d8de2fc6 100644 --- a/server/src/test/java/com/vaadin/util/CurrentInstanceTest.java +++ b/server/src/test/java/com/vaadin/util/CurrentInstanceTest.java @@ -77,7 +77,7 @@ public class CurrentInstanceTest { private ThreadLocal<Map<Class<?>, CurrentInstance>> getInternalCurrentInstanceVariable() throws SecurityException, NoSuchFieldException, IllegalAccessException { - Field f = CurrentInstance.class.getDeclaredField("instances"); + Field f = CurrentInstance.class.getDeclaredField("INSTANCES"); f.setAccessible(true); return (ThreadLocal<Map<Class<?>, CurrentInstance>>) f.get(null); } |