diff options
author | Artur Signell <artur@vaadin.com> | 2016-09-05 12:33:39 +0300 |
---|---|---|
committer | Johannes Dahlström <johannesd@vaadin.com> | 2016-09-05 10:02:48 +0000 |
commit | 504b3c4c65c6a2ccfeeb1501eff7a29f5a3dbec3 (patch) | |
tree | e65c1813439a25bbab6c81e71c27ba8ccf69970b /server/src/main | |
parent | 6941d683eb15a8ae10e0d302bcf9608be8825f8a (diff) | |
download | vaadin-framework-504b3c4c65c6a2ccfeeb1501eff7a29f5a3dbec3.tar.gz vaadin-framework-504b3c4c65c6a2ccfeeb1501eff7a29f5a3dbec3.zip |
Use diamond operator where it can be used
Does not modify compatibility packages to keep to closer to Vaadin 7.7
Change-Id: Ic9c4944eb90218290545a04ecd7455eb63910012
Diffstat (limited to 'server/src/main')
67 files changed, 218 insertions, 218 deletions
diff --git a/server/src/main/java/com/vaadin/data/Result.java b/server/src/main/java/com/vaadin/data/Result.java index 7fb25bf9af..b82b3ff4e7 100644 --- a/server/src/main/java/com/vaadin/data/Result.java +++ b/server/src/main/java/com/vaadin/data/Result.java @@ -62,7 +62,7 @@ public interface Result<R> extends Serializable { */ public static <R> Result<R> error(String message) { Objects.requireNonNull(message, "message cannot be null"); - return new SimpleResult<R>(null, message); + return new SimpleResult<>(null, message); } /** diff --git a/server/src/main/java/com/vaadin/data/sort/Sort.java b/server/src/main/java/com/vaadin/data/sort/Sort.java index 63d152b001..fe082149e9 100644 --- a/server/src/main/java/com/vaadin/data/sort/Sort.java +++ b/server/src/main/java/com/vaadin/data/sort/Sort.java @@ -140,7 +140,7 @@ public class Sort implements Serializable { ++count; } - List<SortOrder> order = new ArrayList<SortOrder>(count); + List<SortOrder> order = new ArrayList<>(count); s = this; do { diff --git a/server/src/main/java/com/vaadin/event/ActionManager.java b/server/src/main/java/com/vaadin/event/ActionManager.java index 98b1359337..b221d17511 100644 --- a/server/src/main/java/com/vaadin/event/ActionManager.java +++ b/server/src/main/java/com/vaadin/event/ActionManager.java @@ -98,7 +98,7 @@ public class ActionManager @Override public <T extends Action & Action.Listener> void addAction(T action) { if (ownActions == null) { - ownActions = new LinkedHashSet<Action>(); + ownActions = new LinkedHashSet<>(); } if (ownActions.add(action)) { requestRepaint(); @@ -123,7 +123,7 @@ public class ActionManager if (actionHandler != null) { if (actionHandlers == null) { - actionHandlers = new LinkedHashSet<Handler>(); + actionHandlers = new LinkedHashSet<>(); } if (actionHandlers.add(actionHandler)) { @@ -165,7 +165,7 @@ public class ActionManager * removed but still exist on client side */ if (!actions.isEmpty() || clientHasActions) { - actionMapper = new KeyMapper<Action>(); + actionMapper = new KeyMapper<>(); paintTarget.addVariable((VariableOwner) viewer, "action", ""); paintTarget.startTag("actions"); @@ -240,7 +240,7 @@ public class ActionManager } private LinkedHashSet<Action> getActionSet(Object target, Object sender) { - LinkedHashSet<Action> actions = new LinkedHashSet<Action>(); + LinkedHashSet<Action> actions = new LinkedHashSet<>(); if (ownActions != null) { actions.addAll(ownActions); diff --git a/server/src/main/java/com/vaadin/event/EventRouter.java b/server/src/main/java/com/vaadin/event/EventRouter.java index 9e8051fed3..9ef6c8123b 100644 --- a/server/src/main/java/com/vaadin/event/EventRouter.java +++ b/server/src/main/java/com/vaadin/event/EventRouter.java @@ -52,7 +52,7 @@ public class EventRouter implements MethodEventSource { @Override public void addListener(Class<?> eventType, Object object, Method method) { if (listenerList == null) { - listenerList = new LinkedHashSet<ListenerMethod>(); + listenerList = new LinkedHashSet<>(); } listenerList.add(new ListenerMethod(eventType, object, method)); } @@ -66,7 +66,7 @@ public class EventRouter implements MethodEventSource { public void addListener(Class<?> eventType, Object object, String methodName) { if (listenerList == null) { - listenerList = new LinkedHashSet<ListenerMethod>(); + listenerList = new LinkedHashSet<>(); } listenerList.add(new ListenerMethod(eventType, object, methodName)); } @@ -232,7 +232,7 @@ public class EventRouter implements MethodEventSource { * are found. */ public Collection<?> getListeners(Class<?> eventType) { - List<Object> listeners = new ArrayList<Object>(); + List<Object> listeners = new ArrayList<>(); if (listenerList != null) { for (ListenerMethod lm : listenerList) { if (lm.isOrExtendsType(eventType)) { diff --git a/server/src/main/java/com/vaadin/event/SelectionEvent.java b/server/src/main/java/com/vaadin/event/SelectionEvent.java index f22f499893..b5a4d587e6 100644 --- a/server/src/main/java/com/vaadin/event/SelectionEvent.java +++ b/server/src/main/java/com/vaadin/event/SelectionEvent.java @@ -37,8 +37,8 @@ public class SelectionEvent extends EventObject { public SelectionEvent(Object source, Collection<Object> oldSelection, Collection<Object> newSelection) { super(source); - this.oldSelection = new LinkedHashSet<Object>(oldSelection); - this.newSelection = new LinkedHashSet<Object>(newSelection); + this.oldSelection = new LinkedHashSet<>(oldSelection); + this.newSelection = new LinkedHashSet<>(newSelection); } /** @@ -79,7 +79,7 @@ public class SelectionEvent extends EventObject { if (set2.isEmpty()) { return set1; } else { - LinkedHashSet<T> set = new LinkedHashSet<T>(set1); + LinkedHashSet<T> set = new LinkedHashSet<>(set1); set.removeAll(set2); return set; } diff --git a/server/src/main/java/com/vaadin/event/TransferableImpl.java b/server/src/main/java/com/vaadin/event/TransferableImpl.java index fad6adf2eb..4da28176fc 100644 --- a/server/src/main/java/com/vaadin/event/TransferableImpl.java +++ b/server/src/main/java/com/vaadin/event/TransferableImpl.java @@ -27,7 +27,7 @@ import com.vaadin.ui.Component; * @since 6.3 */ public class TransferableImpl implements Transferable { - private Map<String, Object> rawVariables = new HashMap<String, Object>(); + private Map<String, Object> rawVariables = new HashMap<>(); private Component sourceComponent; public TransferableImpl(Component sourceComponent, diff --git a/server/src/main/java/com/vaadin/event/dd/TargetDetailsImpl.java b/server/src/main/java/com/vaadin/event/dd/TargetDetailsImpl.java index cce6029159..42bff9c007 100644 --- a/server/src/main/java/com/vaadin/event/dd/TargetDetailsImpl.java +++ b/server/src/main/java/com/vaadin/event/dd/TargetDetailsImpl.java @@ -30,7 +30,7 @@ import com.vaadin.shared.MouseEventDetails; @SuppressWarnings("serial") public class TargetDetailsImpl implements TargetDetails { - private HashMap<String, Object> data = new HashMap<String, Object>(); + private HashMap<String, Object> data = new HashMap<>(); private DropTarget dropTarget; protected TargetDetailsImpl(Map<String, Object> rawDropData) { diff --git a/server/src/main/java/com/vaadin/navigator/Navigator.java b/server/src/main/java/com/vaadin/navigator/Navigator.java index 5704457f72..13e3b4c2e7 100644 --- a/server/src/main/java/com/vaadin/navigator/Navigator.java +++ b/server/src/main/java/com/vaadin/navigator/Navigator.java @@ -374,8 +374,8 @@ public class Navigator implements Serializable { private NavigationStateManager stateManager; private ViewDisplay display; private View currentView = null; - private List<ViewChangeListener> listeners = new LinkedList<ViewChangeListener>(); - private List<ViewProvider> providers = new LinkedList<ViewProvider>(); + private List<ViewChangeListener> listeners = new LinkedList<>(); + private List<ViewProvider> providers = new LinkedList<>(); private String currentNavigationState = null; private ViewProvider errorProvider; @@ -722,7 +722,7 @@ public class Navigator implements Serializable { // a copy of the listener list is needed to avoid // ConcurrentModificationException as a listener can add/remove // listeners - for (ViewChangeListener l : new ArrayList<ViewChangeListener>( + for (ViewChangeListener l : new ArrayList<>( listeners)) { if (!l.beforeViewChange(event)) { return false; @@ -786,7 +786,7 @@ public class Navigator implements Serializable { // a copy of the listener list is needed to avoid // ConcurrentModificationException as a listener can add/remove // listeners - for (ViewChangeListener l : new ArrayList<ViewChangeListener>( + for (ViewChangeListener l : new ArrayList<>( listeners)) { l.afterViewChange(event); } diff --git a/server/src/main/java/com/vaadin/server/AbstractClientConnector.java b/server/src/main/java/com/vaadin/server/AbstractClientConnector.java index 676256fb5d..ea969bea2b 100644 --- a/server/src/main/java/com/vaadin/server/AbstractClientConnector.java +++ b/server/src/main/java/com/vaadin/server/AbstractClientConnector.java @@ -60,13 +60,13 @@ public abstract class AbstractClientConnector * A map from client to server RPC interface class name to the RPC call * manager that handles incoming RPC calls for that interface. */ - private Map<String, ServerRpcManager<?>> rpcManagerMap = new HashMap<String, ServerRpcManager<?>>(); + private Map<String, ServerRpcManager<?>> rpcManagerMap = new HashMap<>(); /** * A map from server to client RPC interface class to the RPC proxy that * sends ourgoing RPC calls for that interface. */ - private Map<Class<?>, ClientRpc> rpcProxyMap = new HashMap<Class<?>, ClientRpc>(); + private Map<Class<?>, ClientRpc> rpcProxyMap = new HashMap<>(); /** * Shared state object to be communicated from the server to the client when @@ -79,11 +79,11 @@ public abstract class AbstractClientConnector /** * Pending RPC method invocations to be sent. */ - private ArrayList<ClientMethodInvocation> pendingInvocations = new ArrayList<ClientMethodInvocation>(); + private ArrayList<ClientMethodInvocation> pendingInvocations = new ArrayList<>(); private String connectorId; - private ArrayList<Extension> extensions = new ArrayList<Extension>(); + private ArrayList<Extension> extensions = new ArrayList<>(); /** * The EventRouter used for the event model. @@ -92,7 +92,7 @@ public abstract class AbstractClientConnector private ErrorHandler errorHandler = null; - private static final ConcurrentHashMap<Class<? extends AbstractClientConnector>, Class<? extends SharedState>> stateTypeCache = new ConcurrentHashMap<Class<? extends AbstractClientConnector>, Class<? extends SharedState>>(); + private static final ConcurrentHashMap<Class<? extends AbstractClientConnector>, Class<? extends SharedState>> stateTypeCache = new ConcurrentHashMap<>(); @Override public void addAttachListener(AttachListener listener) { @@ -170,7 +170,7 @@ public abstract class AbstractClientConnector protected <T extends ServerRpc> void registerRpc(T implementation, Class<T> rpcInterfaceType) { rpcManagerMap.put(rpcInterfaceType.getName(), - new ServerRpcManager<T>(implementation, rpcInterfaceType)); + new ServerRpcManager<>(implementation, rpcInterfaceType)); } /** @@ -425,7 +425,7 @@ public abstract class AbstractClientConnector return Collections.emptyList(); } else { List<ClientMethodInvocation> result = pendingInvocations; - pendingInvocations = new ArrayList<ClientMethodInvocation>(); + pendingInvocations = new ArrayList<>(); return Collections.unmodifiableList(result); } } diff --git a/server/src/main/java/com/vaadin/server/AbstractErrorMessage.java b/server/src/main/java/com/vaadin/server/AbstractErrorMessage.java index 0bd00bae86..491462b53d 100644 --- a/server/src/main/java/com/vaadin/server/AbstractErrorMessage.java +++ b/server/src/main/java/com/vaadin/server/AbstractErrorMessage.java @@ -63,7 +63,7 @@ public abstract class AbstractErrorMessage implements ErrorMessage { */ private ErrorLevel level = ErrorLevel.ERROR; - private List<ErrorMessage> causes = new ArrayList<ErrorMessage>(); + private List<ErrorMessage> causes = new ArrayList<>(); protected AbstractErrorMessage(String message) { this.message = message; diff --git a/server/src/main/java/com/vaadin/server/BootstrapHandler.java b/server/src/main/java/com/vaadin/server/BootstrapHandler.java index 359f878ad1..84ee3c2334 100644 --- a/server/src/main/java/com/vaadin/server/BootstrapHandler.java +++ b/server/src/main/java/com/vaadin/server/BootstrapHandler.java @@ -303,7 +303,7 @@ public abstract class BootstrapHandler extends SynchronizedRequestHandler { .getBootstrapResponse(); if (vaadinService.isStandalone(request)) { - Map<String, Object> headers = new LinkedHashMap<String, Object>(); + Map<String, Object> headers = new LinkedHashMap<>(); Document document = Document.createShell(""); BootstrapPageResponse pageResponse = new BootstrapPageResponse(this, request, context.getSession(), context.getUIClass(), diff --git a/server/src/main/java/com/vaadin/server/ComponentSizeValidator.java b/server/src/main/java/com/vaadin/server/ComponentSizeValidator.java index dcf47ba438..241aea2078 100644 --- a/server/src/main/java/com/vaadin/server/ComponentSizeValidator.java +++ b/server/src/main/java/com/vaadin/server/ComponentSizeValidator.java @@ -70,7 +70,7 @@ public class ComponentSizeValidator implements Serializable { parent.addError(error); } else { if (errors == null) { - errors = new LinkedList<InvalidLayout>(); + errors = new LinkedList<>(); } errors.add(error); } @@ -168,7 +168,7 @@ public class ComponentSizeValidator implements Serializable { private final boolean invalidHeight; private final boolean invalidWidth; - private final Vector<InvalidLayout> subErrors = new Vector<InvalidLayout>(); + private final Vector<InvalidLayout> subErrors = new Vector<>(); public InvalidLayout(Component component, boolean height, boolean width) { @@ -281,7 +281,7 @@ public class ComponentSizeValidator implements Serializable { private static Stack<ComponentInfo> getHeightAttributes( Component component) { - Stack<ComponentInfo> attributes = new Stack<ComponentInfo>(); + Stack<ComponentInfo> attributes = new Stack<>(); attributes .add(new ComponentInfo(component, getHeightString(component))); Component parent = component.getParent(); @@ -296,7 +296,7 @@ public class ComponentSizeValidator implements Serializable { private static Stack<ComponentInfo> getWidthAttributes( Component component) { - Stack<ComponentInfo> attributes = new Stack<ComponentInfo>(); + Stack<ComponentInfo> attributes = new Stack<>(); attributes.add(new ComponentInfo(component, getWidthString(component))); Component parent = component.getParent(); attributes.add(new ComponentInfo(parent, getWidthString(parent))); @@ -581,9 +581,9 @@ public class ComponentSizeValidator implements Serializable { } - private static Map<Object, FileLocation> creationLocations = new HashMap<Object, FileLocation>(); - private static Map<Object, FileLocation> widthLocations = new HashMap<Object, FileLocation>(); - private static Map<Object, FileLocation> heightLocations = new HashMap<Object, FileLocation>(); + private static Map<Object, FileLocation> creationLocations = new HashMap<>(); + private static Map<Object, FileLocation> widthLocations = new HashMap<>(); + private static Map<Object, FileLocation> heightLocations = new HashMap<>(); public static class FileLocation implements Serializable { public String method; diff --git a/server/src/main/java/com/vaadin/server/DownloadStream.java b/server/src/main/java/com/vaadin/server/DownloadStream.java index d67fbda8c2..a0a1334135 100644 --- a/server/src/main/java/com/vaadin/server/DownloadStream.java +++ b/server/src/main/java/com/vaadin/server/DownloadStream.java @@ -148,7 +148,7 @@ public class DownloadStream implements Serializable { */ public void setParameter(String name, String value) { if (params == null) { - params = new HashMap<String, String>(); + params = new HashMap<>(); } params.put(name, value); } diff --git a/server/src/main/java/com/vaadin/server/GAEVaadinServlet.java b/server/src/main/java/com/vaadin/server/GAEVaadinServlet.java index aa3bccdb93..93a43829b3 100644 --- a/server/src/main/java/com/vaadin/server/GAEVaadinServlet.java +++ b/server/src/main/java/com/vaadin/server/GAEVaadinServlet.java @@ -428,7 +428,7 @@ public class GAEVaadinServlet extends VaadinServlet { getLogger().log(Level.INFO, "Vaadin cleanup deleting {0} expired Vaadin sessions.", entities.size()); - List<Key> keys = new ArrayList<Key>(); + List<Key> keys = new ArrayList<>(); for (Entity e : entities) { keys.add(e.getKey()); } @@ -448,7 +448,7 @@ public class GAEVaadinServlet extends VaadinServlet { getLogger().log(Level.INFO, "Vaadin cleanup deleting {0} expired appengine sessions.", entities.size()); - List<Key> keys = new ArrayList<Key>(); + List<Key> keys = new ArrayList<>(); for (Entity e : entities) { keys.add(e.getKey()); } diff --git a/server/src/main/java/com/vaadin/server/GlobalResourceHandler.java b/server/src/main/java/com/vaadin/server/GlobalResourceHandler.java index 62f3d33014..975d5475d1 100644 --- a/server/src/main/java/com/vaadin/server/GlobalResourceHandler.java +++ b/server/src/main/java/com/vaadin/server/GlobalResourceHandler.java @@ -49,15 +49,15 @@ public class GlobalResourceHandler implements RequestHandler { /** * Used to detect when a resource is no longer used by any connector. */ - private final Map<Resource, Set<ClientConnector>> resourceUsers = new HashMap<Resource, Set<ClientConnector>>(); + private final Map<Resource, Set<ClientConnector>> resourceUsers = new HashMap<>(); /** * Used to find the resources that might not be needed any more when a * connector is unregistered. */ - private final Map<ClientConnector, Set<Resource>> usedResources = new HashMap<ClientConnector, Set<Resource>>(); + private final Map<ClientConnector, Set<Resource>> usedResources = new HashMap<>(); - private final Map<ConnectorResource, String> legacyResourceKeys = new HashMap<ConnectorResource, String>(); - private final Map<String, ConnectorResource> legacyResources = new HashMap<String, ConnectorResource>(); + private final Map<ConnectorResource, String> legacyResourceKeys = new HashMap<>(); + private final Map<String, ConnectorResource> legacyResources = new HashMap<>(); private int nextLegacyId = 0; // APP/global/[uiid]/[type]/[id] @@ -173,7 +173,7 @@ public class GlobalResourceHandler implements RequestHandler { private <K, V> void ensureInSet(Map<K, Set<V>> map, K key, V value) { Set<V> set = map.get(key); if (set == null) { - set = new HashSet<V>(); + set = new HashSet<>(); map.put(key, set); } set.add(value); diff --git a/server/src/main/java/com/vaadin/server/JavaScriptCallbackHelper.java b/server/src/main/java/com/vaadin/server/JavaScriptCallbackHelper.java index f4b8556385..cdd42c19da 100644 --- a/server/src/main/java/com/vaadin/server/JavaScriptCallbackHelper.java +++ b/server/src/main/java/com/vaadin/server/JavaScriptCallbackHelper.java @@ -49,7 +49,7 @@ public class JavaScriptCallbackHelper implements Serializable { JavaScriptCallbackRpc.class, "call", String.class, JsonArray.class); private AbstractClientConnector connector; - private Map<String, JavaScriptFunction> callbacks = new HashMap<String, JavaScriptFunction>(); + private Map<String, JavaScriptFunction> callbacks = new HashMap<>(); private JavaScriptCallbackRpc javascriptCallbackRpc; public JavaScriptCallbackHelper(AbstractClientConnector connector) { @@ -109,7 +109,7 @@ public class JavaScriptCallbackHelper implements Serializable { .getRpcInterfaces(); String interfaceName = rpcInterfaceType.getName(); if (!rpcInterfaces.containsKey(interfaceName)) { - Set<String> methodNames = new HashSet<String>(); + Set<String> methodNames = new HashSet<>(); for (Method method : rpcInterfaceType.getMethods()) { methodNames.add(method.getName()); diff --git a/server/src/main/java/com/vaadin/server/JsonCodec.java b/server/src/main/java/com/vaadin/server/JsonCodec.java index 2dae3ed03e..adf3e029ee 100644 --- a/server/src/main/java/com/vaadin/server/JsonCodec.java +++ b/server/src/main/java/com/vaadin/server/JsonCodec.java @@ -137,7 +137,7 @@ public class JsonCodec implements Serializable { public static Collection<FieldProperty> find(Class<?> type) throws IntrospectionException { Field[] fields = type.getFields(); - Collection<FieldProperty> properties = new ArrayList<FieldProperty>( + Collection<FieldProperty> properties = new ArrayList<>( fields.length); for (Field field : fields) { if (!Modifier.isStatic(field.getModifiers())) { @@ -178,7 +178,7 @@ public class JsonCodec implements Serializable { public static Collection<MethodProperty> find(Class<?> type) throws IntrospectionException { - Collection<MethodProperty> properties = new ArrayList<MethodProperty>(); + Collection<MethodProperty> properties = new ArrayList<>(); for (PropertyDescriptor pd : Introspector.getBeanInfo(type) .getPropertyDescriptors()) { @@ -204,17 +204,17 @@ public class JsonCodec implements Serializable { * happens to process Vaadin requests, so it must be protected from * corruption caused by concurrent access. */ - private static ConcurrentMap<Class<?>, Collection<BeanProperty>> typePropertyCache = new ConcurrentHashMap<Class<?>, Collection<BeanProperty>>(); + private static ConcurrentMap<Class<?>, Collection<BeanProperty>> typePropertyCache = new ConcurrentHashMap<>(); - private static Map<Class<?>, String> typeToTransportType = new HashMap<Class<?>, String>(); + private static Map<Class<?>, String> typeToTransportType = new HashMap<>(); /** * Note! This does not contain primitives. * <p> */ - private static Map<String, Class<?>> transportTypeToType = new HashMap<String, Class<?>>(); + private static Map<String, Class<?>> transportTypeToType = new HashMap<>(); - private static Map<Class<?>, JSONSerializer<?>> customSerializers = new HashMap<Class<?>, JSONSerializer<?>>(); + private static Map<Class<?>, JSONSerializer<?>> customSerializers = new HashMap<>(); static { customSerializers.put(Date.class, new DateSerializer()); } @@ -464,7 +464,7 @@ public class JsonCodec implements Serializable { // See #8906. JsonArray jsonArray = (JsonArray) jsonMap; if (jsonArray.length() == 0) { - return new HashMap<Object, Object>(); + return new HashMap<>(); } } @@ -499,7 +499,7 @@ public class JsonCodec implements Serializable { assert (keys.length() == values.length()); - Map<Object, Object> map = new HashMap<Object, Object>( + Map<Object, Object> map = new HashMap<>( keys.length() * 2); for (int i = 0; i < keys.length(); i++) { Object key = decodeInternalOrCustomType(keyType, keys.get(i), @@ -515,7 +515,7 @@ public class JsonCodec implements Serializable { private static Map<Object, Object> decodeConnectorMap(Type valueType, JsonObject jsonMap, ConnectorTracker connectorTracker) { - Map<Object, Object> map = new HashMap<Object, Object>(); + Map<Object, Object> map = new HashMap<>(); for (String key : jsonMap.keys()) { Object value = decodeInternalOrCustomType(valueType, @@ -531,7 +531,7 @@ public class JsonCodec implements Serializable { private static Map<Object, Object> decodeStringMap(Type valueType, JsonObject jsonMap, ConnectorTracker connectorTracker) { - Map<Object, Object> map = new HashMap<Object, Object>(); + Map<Object, Object> map = new HashMap<>(); for (String key : jsonMap.keys()) { Object value = decodeInternalOrCustomType(valueType, @@ -590,7 +590,7 @@ public class JsonCodec implements Serializable { boolean restrictToInternalTypes, JsonArray jsonArray, ConnectorTracker connectorTracker) { int arrayLength = jsonArray.length(); - List<Object> list = new ArrayList<Object>(arrayLength); + List<Object> list = new ArrayList<>(arrayLength); for (int i = 0; i < arrayLength; ++i) { // each entry always has two elements: type and value JsonValue encodedValue = jsonArray.get(i); @@ -604,7 +604,7 @@ public class JsonCodec implements Serializable { private static Set<Object> decodeSet(Type targetType, boolean restrictToInternalTypes, JsonArray jsonArray, ConnectorTracker connectorTracker) { - HashSet<Object> set = new HashSet<Object>(); + HashSet<Object> set = new HashSet<>(); set.addAll(decodeList(targetType, restrictToInternalTypes, jsonArray, connectorTracker)); return set; @@ -702,7 +702,7 @@ public class JsonCodec implements Serializable { if (cachedProperties != null) { return cachedProperties; } - Collection<BeanProperty> properties = new ArrayList<BeanProperty>(); + Collection<BeanProperty> properties = new ArrayList<>(); properties.addAll(MethodProperty.find(type)); properties.addAll(FieldProperty.find(type)); diff --git a/server/src/main/java/com/vaadin/server/JsonPaintTarget.java b/server/src/main/java/com/vaadin/server/JsonPaintTarget.java index 19f79b6507..4463fd1ab5 100644 --- a/server/src/main/java/com/vaadin/server/JsonPaintTarget.java +++ b/server/src/main/java/com/vaadin/server/JsonPaintTarget.java @@ -65,7 +65,7 @@ public class JsonPaintTarget implements PaintTarget { private int changes = 0; - private final Set<Object> usedResources = new HashSet<Object>(); + private final Set<Object> usedResources = new HashSet<>(); private boolean customLayoutArgumentsOpen = false; @@ -73,7 +73,7 @@ public class JsonPaintTarget implements PaintTarget { private boolean cacheEnabled = false; - private final Set<Class<? extends ClientConnector>> usedClientConnectors = new HashSet<Class<? extends ClientConnector>>(); + private final Set<Class<? extends ClientConnector>> usedClientConnectors = new HashSet<>(); /** * Creates a new JsonPaintTarget. @@ -96,11 +96,11 @@ public class JsonPaintTarget implements PaintTarget { uidlBuffer = new PrintWriter(outWriter); // Initialize tag-writing - mOpenTags = new Stack<String>(); - openJsonTags = new Stack<JsonTag>(); + mOpenTags = new Stack<>(); + openJsonTags = new Stack<>(); - openPaintables = new Stack<ClientConnector>(); - openPaintableTags = new Stack<String>(); + openPaintables = new Stack<>(); + openPaintableTags = new Stack<>(); cacheEnabled = cachingRequired; } @@ -728,11 +728,11 @@ public class JsonPaintTarget implements PaintTarget { class JsonTag implements Serializable { boolean firstField = false; - Vector<Object> variables = new Vector<Object>(); + Vector<Object> variables = new Vector<>(); - Vector<Object> children = new Vector<Object>(); + Vector<Object> children = new Vector<>(); - Vector<Object> attr = new Vector<Object>(); + Vector<Object> attr = new Vector<>(); StringBuilder data = new StringBuilder(); diff --git a/server/src/main/java/com/vaadin/server/KeyMapper.java b/server/src/main/java/com/vaadin/server/KeyMapper.java index 389fcd8b66..54d85c4bce 100644 --- a/server/src/main/java/com/vaadin/server/KeyMapper.java +++ b/server/src/main/java/com/vaadin/server/KeyMapper.java @@ -32,9 +32,9 @@ public class KeyMapper<V> implements DataKeyMapper<V>, Serializable { private int lastKey = 0; - private final HashMap<V, String> objectKeyMap = new HashMap<V, String>(); + private final HashMap<V, String> objectKeyMap = new HashMap<>(); - private final HashMap<String, V> keyObjectMap = new HashMap<String, V>(); + private final HashMap<String, V> keyObjectMap = new HashMap<>(); /** * Gets key for an object. diff --git a/server/src/main/java/com/vaadin/server/LegacyApplication.java b/server/src/main/java/com/vaadin/server/LegacyApplication.java index 93f3da3d8f..210520cfaa 100644 --- a/server/src/main/java/com/vaadin/server/LegacyApplication.java +++ b/server/src/main/java/com/vaadin/server/LegacyApplication.java @@ -42,7 +42,7 @@ public abstract class LegacyApplication implements ErrorHandler { private LegacyWindow mainWindow; private String theme; - private Map<String, LegacyWindow> legacyUINames = new HashMap<String, LegacyWindow>(); + private Map<String, LegacyWindow> legacyUINames = new HashMap<>(); private boolean isRunning = true; diff --git a/server/src/main/java/com/vaadin/server/LegacyCommunicationManager.java b/server/src/main/java/com/vaadin/server/LegacyCommunicationManager.java index 513f598b21..858f61d0c7 100644 --- a/server/src/main/java/com/vaadin/server/LegacyCommunicationManager.java +++ b/server/src/main/java/com/vaadin/server/LegacyCommunicationManager.java @@ -56,7 +56,7 @@ import elemental.json.JsonValue; public class LegacyCommunicationManager implements Serializable { // TODO Refactor (#11410) - private final HashMap<Integer, ClientCache> uiToClientCache = new HashMap<Integer, ClientCache>(); + private final HashMap<Integer, ClientCache> uiToClientCache = new HashMap<>(); /** * The session this communication manager is used for @@ -67,7 +67,7 @@ public class LegacyCommunicationManager implements Serializable { private String requestThemeName; // TODO Refactor (#11413) - private Map<String, Class<?>> publishedFileContexts = new HashMap<String, Class<?>>(); + private Map<String, Class<?>> publishedFileContexts = new HashMap<>(); /** * TODO New constructor - document me! @@ -82,7 +82,7 @@ public class LegacyCommunicationManager implements Serializable { return session; } - private static final ConcurrentHashMap<Class<? extends SharedState>, JsonValue> referenceDiffStates = new ConcurrentHashMap<Class<? extends SharedState>, JsonValue>(); + private static final ConcurrentHashMap<Class<? extends SharedState>, JsonValue> referenceDiffStates = new ConcurrentHashMap<>(); /** * @deprecated As of 7.1. See #11411. @@ -307,7 +307,7 @@ public class LegacyCommunicationManager implements Serializable { } } - private final HashMap<Class<? extends ClientConnector>, Integer> typeToKey = new HashMap<Class<? extends ClientConnector>, Integer>(); + private final HashMap<Class<? extends ClientConnector>, Integer> typeToKey = new HashMap<>(); private int nextTypeKey = 0; /** @@ -338,7 +338,7 @@ public class LegacyCommunicationManager implements Serializable { @Deprecated public class ClientCache implements Serializable { - private final Set<Object> res = new HashSet<Object>(); + private final Set<Object> res = new HashSet<>(); /** * diff --git a/server/src/main/java/com/vaadin/server/Page.java b/server/src/main/java/com/vaadin/server/Page.java index 7142659fca..9330c08a28 100644 --- a/server/src/main/java/com/vaadin/server/Page.java +++ b/server/src/main/java/com/vaadin/server/Page.java @@ -273,7 +273,7 @@ public class Page implements Serializable { * Resources to be opened automatically on next repaint. The list is * automatically cleared when it has been sent to the client. */ - private final LinkedList<OpenResource> openList = new LinkedList<OpenResource>(); + private final LinkedList<OpenResource> openList = new LinkedList<>(); /** * A list of notifications that are waiting to be sent to the client. @@ -388,9 +388,9 @@ public class Page implements Serializable { */ public static class Styles implements Serializable { - private LinkedHashSet<InjectedStyle> injectedStyles = new LinkedHashSet<InjectedStyle>(); + private LinkedHashSet<InjectedStyle> injectedStyles = new LinkedHashSet<>(); - private LinkedHashSet<InjectedStyle> pendingInjections = new LinkedHashSet<InjectedStyle>(); + private LinkedHashSet<InjectedStyle> pendingInjections = new LinkedHashSet<>(); private final UI ui; @@ -440,7 +440,7 @@ public class Page implements Serializable { if (target.isFullRepaint()) { injectedStyles.addAll(pendingInjections); pendingInjections = injectedStyles; - injectedStyles = new LinkedHashSet<InjectedStyle>(); + injectedStyles = new LinkedHashSet<>(); } if (!pendingInjections.isEmpty()) { @@ -1161,7 +1161,7 @@ public class Page implements Serializable { */ private void addNotification(Notification notification) { if (notifications == null) { - notifications = new LinkedList<Notification>(); + notifications = new LinkedList<>(); } notifications.add(notification); uI.markAsDirty(); diff --git a/server/src/main/java/com/vaadin/server/ServerRpcManager.java b/server/src/main/java/com/vaadin/server/ServerRpcManager.java index e1f5f79860..e9f8d9543e 100644 --- a/server/src/main/java/com/vaadin/server/ServerRpcManager.java +++ b/server/src/main/java/com/vaadin/server/ServerRpcManager.java @@ -69,7 +69,7 @@ public class ServerRpcManager<T extends ServerRpc> implements Serializable { } - private static final Map<Class<?>, Class<?>> boxedTypes = new HashMap<Class<?>, Class<?>>(); + private static final Map<Class<?>, Class<?>> boxedTypes = new HashMap<>(); static { try { Class<?>[] boxClasses = new Class<?>[] { Boolean.class, Byte.class, diff --git a/server/src/main/java/com/vaadin/server/ServerRpcMethodInvocation.java b/server/src/main/java/com/vaadin/server/ServerRpcMethodInvocation.java index 22bcd1bf6b..f4e2b4064d 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<String, Method>( + private static final Map<String, Method> invocationMethodCache = new ConcurrentHashMap<>( 128, 0.75f, 1); private final Method method; diff --git a/server/src/main/java/com/vaadin/server/VaadinPortletSession.java b/server/src/main/java/com/vaadin/server/VaadinPortletSession.java index f431d08b7e..6a6cb429d3 100644 --- a/server/src/main/java/com/vaadin/server/VaadinPortletSession.java +++ b/server/src/main/java/com/vaadin/server/VaadinPortletSession.java @@ -64,13 +64,13 @@ import com.vaadin.util.CurrentInstance; @SuppressWarnings("serial") public class VaadinPortletSession extends VaadinSession { - private final Set<PortletListener> portletListeners = new LinkedHashSet<PortletListener>(); + private final Set<PortletListener> portletListeners = new LinkedHashSet<>(); - private final Map<String, QName> eventActionDestinationMap = new HashMap<String, QName>(); - private final Map<String, Serializable> eventActionValueMap = new HashMap<String, Serializable>(); + private final Map<String, QName> eventActionDestinationMap = new HashMap<>(); + private final Map<String, Serializable> eventActionValueMap = new HashMap<>(); - private final Map<String, String> sharedParameterActionNameMap = new HashMap<String, String>(); - private final Map<String, String> sharedParameterActionValueMap = new HashMap<String, String>(); + private final Map<String, String> sharedParameterActionNameMap = new HashMap<>(); + private final Map<String, String> sharedParameterActionValueMap = new HashMap<>(); /** * Create a portlet service session for the given portlet service @@ -143,7 +143,7 @@ public class VaadinPortletSession extends VaadinSession { */ public void firePortletRenderRequest(UI uI, RenderRequest request, RenderResponse response) { - for (PortletListener l : new ArrayList<PortletListener>( + for (PortletListener l : new ArrayList<>( portletListeners)) { l.handleRenderRequest(request, new RestrictedRenderResponse(response), uI); @@ -172,7 +172,7 @@ public class VaadinPortletSession extends VaadinSession { sharedParameterActionValueMap.remove(key); } else { // normal action request, notify listeners - for (PortletListener l : new ArrayList<PortletListener>( + for (PortletListener l : new ArrayList<>( portletListeners)) { l.handleActionRequest(request, response, uI); } @@ -184,7 +184,7 @@ public class VaadinPortletSession extends VaadinSession { */ public void firePortletEventRequest(UI uI, EventRequest request, EventResponse response) { - for (PortletListener l : new ArrayList<PortletListener>( + for (PortletListener l : new ArrayList<>( portletListeners)) { l.handleEventRequest(request, response, uI); } @@ -195,7 +195,7 @@ public class VaadinPortletSession extends VaadinSession { */ public void firePortletResourceRequest(UI uI, ResourceRequest request, ResourceResponse response) { - for (PortletListener l : new ArrayList<PortletListener>( + for (PortletListener l : new ArrayList<>( portletListeners)) { l.handleResourceRequest(request, response, uI); } diff --git a/server/src/main/java/com/vaadin/server/VaadinService.java b/server/src/main/java/com/vaadin/server/VaadinService.java index 50e20a0389..922c7cfe52 100644 --- a/server/src/main/java/com/vaadin/server/VaadinService.java +++ b/server/src/main/java/com/vaadin/server/VaadinService.java @@ -209,7 +209,7 @@ public abstract class VaadinService implements Serializable { */ protected List<RequestHandler> createRequestHandlers() throws ServiceException { - ArrayList<RequestHandler> handlers = new ArrayList<RequestHandler>(); + ArrayList<RequestHandler> handlers = new ArrayList<>(); handlers.add(new SessionRequestHandler()); handlers.add(new PublishedFileHandler()); handlers.add(new HeartbeatHandler()); @@ -466,7 +466,7 @@ public abstract class VaadinService implements Serializable { if (session.getState() == State.OPEN) { closeSession(session); } - ArrayList<UI> uis = new ArrayList<UI>(session.getUIs()); + ArrayList<UI> uis = new ArrayList<>(session.getUIs()); for (final UI ui : uis) { ui.accessSynchronously(new Runnable() { @Override @@ -1050,7 +1050,7 @@ public abstract class VaadinService implements Serializable { // Stores all attributes (security key, reference to this context // instance) so they can be added to the new session Set<String> attributeNames = oldSession.getAttributeNames(); - HashMap<String, Object> attrs = new HashMap<String, Object>( + HashMap<String, Object> attrs = new HashMap<>( attributeNames.size() * 2); for (String name : attributeNames) { Object value = oldSession.getAttribute(name); @@ -1190,7 +1190,7 @@ public abstract class VaadinService implements Serializable { * @param session */ private void removeClosedUIs(final VaadinSession session) { - ArrayList<UI> uis = new ArrayList<UI>(session.getUIs()); + ArrayList<UI> uis = new ArrayList<>(session.getUIs()); for (final UI ui : uis) { if (ui.isClosing()) { ui.accessSynchronously(new Runnable() { diff --git a/server/src/main/java/com/vaadin/server/VaadinServlet.java b/server/src/main/java/com/vaadin/server/VaadinServlet.java index e3402f6937..03d47b6693 100644 --- a/server/src/main/java/com/vaadin/server/VaadinServlet.java +++ b/server/src/main/java/com/vaadin/server/VaadinServlet.java @@ -87,7 +87,7 @@ public class VaadinServlet extends HttpServlet implements Constants { css = json.getString("css"); timestamp = Long.parseLong(json.getString("timestamp")); - sourceUris = new ArrayList<String>(); + sourceUris = new ArrayList<>(); JsonArray uris = json.getArray("uris"); for (int i = 0; i < uris.length(); i++) { @@ -661,7 +661,7 @@ public class VaadinServlet extends HttpServlet implements Constants { return sb.toString(); } - private static final Collection<Character> CHAR_BLACKLIST = new HashSet<Character>( + private static final Collection<Character> CHAR_BLACKLIST = new HashSet<>( Arrays.asList(new Character[] { '&', '"', '\'', '<', '>', '(', ')', ';' })); @@ -678,7 +678,7 @@ public class VaadinServlet extends HttpServlet implements Constants { * Global cache of scss compilation results. This map is protected from * concurrent access by {@link #SCSS_MUTEX}. */ - private final Map<String, ScssCacheEntry> scssCache = new HashMap<String, ScssCacheEntry>(); + private final Map<String, ScssCacheEntry> scssCache = new HashMap<>(); /** * Keeps track of whether a warning about not being able to persist cache diff --git a/server/src/main/java/com/vaadin/server/VaadinSession.java b/server/src/main/java/com/vaadin/server/VaadinSession.java index 8b503b9b37..d2cf4e740a 100644 --- a/server/src/main/java/com/vaadin/server/VaadinSession.java +++ b/server/src/main/java/com/vaadin/server/VaadinSession.java @@ -226,12 +226,12 @@ public class VaadinSession implements HttpSessionBindingListener, Serializable { @Deprecated private Object converterFactory; - private LinkedList<RequestHandler> requestHandlers = new LinkedList<RequestHandler>(); + private LinkedList<RequestHandler> requestHandlers = new LinkedList<>(); private int nextUIId = 0; - private Map<Integer, UI> uIs = new HashMap<Integer, UI>(); + private Map<Integer, UI> uIs = new HashMap<>(); - private final Map<String, Integer> embedIdMap = new HashMap<String, Integer>(); + private final Map<String, Integer> embedIdMap = new HashMap<>(); private final EventRouter eventRouter = new EventRouter(); @@ -253,9 +253,9 @@ public class VaadinSession implements HttpSessionBindingListener, Serializable { private transient WrappedSession session; - private final Map<String, Object> attributes = new HashMap<String, Object>(); + private final Map<String, Object> attributes = new HashMap<>(); - private LinkedList<UIProvider> uiProviders = new LinkedList<UIProvider>(); + private LinkedList<UIProvider> uiProviders = new LinkedList<>(); private transient VaadinService service; @@ -266,7 +266,7 @@ public class VaadinSession implements HttpSessionBindingListener, Serializable { * session is serialized as long as it doesn't happen while some other * thread has the lock. */ - private transient ConcurrentLinkedQueue<FutureAccess> pendingAccessQueue = new ConcurrentLinkedQueue<FutureAccess>(); + private transient ConcurrentLinkedQueue<FutureAccess> pendingAccessQueue = new ConcurrentLinkedQueue<>(); /** * Creates a new VaadinSession tied to a VaadinService. @@ -465,7 +465,7 @@ public class VaadinSession implements HttpSessionBindingListener, Serializable { */ public static Collection<VaadinSession> getAllSessions( HttpSession httpSession) { - Set<VaadinSession> sessions = new HashSet<VaadinSession>(); + Set<VaadinSession> sessions = new HashSet<>(); Enumeration<String> attributeNames = httpSession.getAttributeNames(); while (attributeNames.hasMoreElements()) { @@ -1426,7 +1426,7 @@ public class VaadinSession implements HttpSessionBindingListener, Serializable { Map<Class<?>, CurrentInstance> old = CurrentInstance.setCurrent(this); try { stream.defaultReadObject(); - pendingAccessQueue = new ConcurrentLinkedQueue<FutureAccess>(); + pendingAccessQueue = new ConcurrentLinkedQueue<>(); } finally { CurrentInstance.restoreInstances(old); } diff --git a/server/src/main/java/com/vaadin/server/WrappedHttpSession.java b/server/src/main/java/com/vaadin/server/WrappedHttpSession.java index 781cdedc5c..39944fc7da 100644 --- a/server/src/main/java/com/vaadin/server/WrappedHttpSession.java +++ b/server/src/main/java/com/vaadin/server/WrappedHttpSession.java @@ -76,7 +76,7 @@ public class WrappedHttpSession implements WrappedSession { // Helper shared with WrappedPortletSession static <T> Set<T> enumerationToSet(Enumeration<T> values) { - HashSet<T> set = new HashSet<T>(); + HashSet<T> set = new HashSet<>(); while (values.hasMoreElements()) { set.add(values.nextElement()); } diff --git a/server/src/main/java/com/vaadin/server/communication/ClientRpcWriter.java b/server/src/main/java/com/vaadin/server/communication/ClientRpcWriter.java index 94755385eb..efa8cc3be9 100644 --- a/server/src/main/java/com/vaadin/server/communication/ClientRpcWriter.java +++ b/server/src/main/java/com/vaadin/server/communication/ClientRpcWriter.java @@ -116,7 +116,7 @@ public class ClientRpcWriter implements Serializable { */ private Collection<ClientMethodInvocation> collectPendingRpcCalls( Collection<ClientConnector> rpcPendingQueue) { - List<ClientMethodInvocation> pendingInvocations = new ArrayList<ClientMethodInvocation>(); + List<ClientMethodInvocation> pendingInvocations = new ArrayList<>(); for (ClientConnector connector : rpcPendingQueue) { List<ClientMethodInvocation> paintablePendingRpc = connector .retrievePendingRpcCalls(); @@ -124,7 +124,7 @@ public class ClientRpcWriter implements Serializable { List<ClientMethodInvocation> oldPendingRpc = pendingInvocations; int totalCalls = pendingInvocations.size() + paintablePendingRpc.size(); - pendingInvocations = new ArrayList<ClientMethodInvocation>( + pendingInvocations = new ArrayList<>( totalCalls); // merge two ordered comparable lists diff --git a/server/src/main/java/com/vaadin/server/communication/LegacyUidlWriter.java b/server/src/main/java/com/vaadin/server/communication/LegacyUidlWriter.java index 041c5e9e8b..498dcf5bf4 100644 --- a/server/src/main/java/com/vaadin/server/communication/LegacyUidlWriter.java +++ b/server/src/main/java/com/vaadin/server/communication/LegacyUidlWriter.java @@ -60,7 +60,7 @@ public class LegacyUidlWriter implements Serializable { Collection<ClientConnector> dirtyVisibleConnectors = ui .getConnectorTracker().getDirtyVisibleConnectors(); - List<Component> legacyComponents = new ArrayList<Component>( + List<Component> legacyComponents = new ArrayList<>( dirtyVisibleConnectors.size()); for (ClientConnector connector : dirtyVisibleConnectors) { // All Components that want to use paintContent must implement diff --git a/server/src/main/java/com/vaadin/server/communication/ServerRpcHandler.java b/server/src/main/java/com/vaadin/server/communication/ServerRpcHandler.java index c4160a92dd..8ec3503be0 100644 --- a/server/src/main/java/com/vaadin/server/communication/ServerRpcHandler.java +++ b/server/src/main/java/com/vaadin/server/communication/ServerRpcHandler.java @@ -334,7 +334,7 @@ public class ServerRpcHandler implements Serializable { try { ConnectorTracker connectorTracker = ui.getConnectorTracker(); - Set<Connector> enabledConnectors = new HashSet<Connector>(); + Set<Connector> enabledConnectors = new HashSet<>(); List<MethodInvocation> invocations = parseInvocations( ui.getConnectorTracker(), invocationsData, @@ -491,7 +491,7 @@ public class ServerRpcHandler implements Serializable { ConnectorTracker connectorTracker, JsonArray invocationsJson, int lastSyncIdSeenByClient) { int invocationCount = invocationsJson.length(); - ArrayList<MethodInvocation> invocations = new ArrayList<MethodInvocation>( + ArrayList<MethodInvocation> invocations = new ArrayList<>( invocationCount); MethodInvocation previousInvocation = null; diff --git a/server/src/main/java/com/vaadin/server/communication/SessionRequestHandler.java b/server/src/main/java/com/vaadin/server/communication/SessionRequestHandler.java index 0a890282cd..85b1fda1bf 100644 --- a/server/src/main/java/com/vaadin/server/communication/SessionRequestHandler.java +++ b/server/src/main/java/com/vaadin/server/communication/SessionRequestHandler.java @@ -54,7 +54,7 @@ public class SessionRequestHandler implements RequestHandler { session.lock(); ArrayList<RequestHandler> requestHandlers; try { - requestHandlers = new ArrayList<RequestHandler>( + requestHandlers = new ArrayList<>( session.getRequestHandlers()); } finally { session.unlock(); diff --git a/server/src/main/java/com/vaadin/server/communication/SharedStateWriter.java b/server/src/main/java/com/vaadin/server/communication/SharedStateWriter.java index 1e0efb88ff..73b82fc877 100644 --- a/server/src/main/java/com/vaadin/server/communication/SharedStateWriter.java +++ b/server/src/main/java/com/vaadin/server/communication/SharedStateWriter.java @@ -58,7 +58,7 @@ public class SharedStateWriter implements Serializable { Collection<ClientConnector> dirtyVisibleConnectors = ui .getConnectorTracker().getDirtyVisibleConnectors(); - Set<String> writtenConnectors = new HashSet<String>(); + Set<String> writtenConnectors = new HashSet<>(); JsonObject sharedStates = Json.createObject(); for (ClientConnector connector : dirtyVisibleConnectors) { // encode and send shared state diff --git a/server/src/main/java/com/vaadin/server/communication/UidlWriter.java b/server/src/main/java/com/vaadin/server/communication/UidlWriter.java index 3028475d1b..7132433963 100644 --- a/server/src/main/java/com/vaadin/server/communication/UidlWriter.java +++ b/server/src/main/java/com/vaadin/server/communication/UidlWriter.java @@ -80,7 +80,7 @@ public class UidlWriter implements Serializable { // to write out service.runPendingAccessTasks(session); - Set<ClientConnector> processedConnectors = new HashSet<ClientConnector>(); + Set<ClientConnector> processedConnectors = new HashSet<>(); LegacyCommunicationManager manager = session.getCommunicationManager(); ClientCache clientCache = manager.getClientCache(ui); @@ -90,7 +90,7 @@ public class UidlWriter implements Serializable { getLogger().log(Level.FINE, "* Creating response to client"); while (true) { - ArrayList<ClientConnector> connectorsToProcess = new ArrayList<ClientConnector>(); + ArrayList<ClientConnector> connectorsToProcess = new ArrayList<>(); for (ClientConnector c : uiConnectorTracker.getDirtyConnectors()) { if (!processedConnectors.contains(c) && LegacyCommunicationManager @@ -209,7 +209,7 @@ public class UidlWriter implements Serializable { .getUsedClientConnectors(); boolean typeMappingsOpen = false; - List<Class<? extends ClientConnector>> newConnectorTypes = new ArrayList<Class<? extends ClientConnector>>(); + List<Class<? extends ClientConnector>> newConnectorTypes = new ArrayList<>(); for (Class<? extends ClientConnector> class1 : usedClientConnectors) { if (clientCache.cache(class1)) { @@ -284,8 +284,8 @@ public class UidlWriter implements Serializable { } }); - List<String> scriptDependencies = new ArrayList<String>(); - List<String> styleDependencies = new ArrayList<String>(); + List<String> scriptDependencies = new ArrayList<>(); + List<String> styleDependencies = new ArrayList<>(); for (Class<? extends ClientConnector> class1 : newConnectorTypes) { JavaScript jsAnnotation = class1 diff --git a/server/src/main/java/com/vaadin/server/themeutils/SASSAddonImportFileCreator.java b/server/src/main/java/com/vaadin/server/themeutils/SASSAddonImportFileCreator.java index 2bb44f65dd..fe950b4318 100644 --- a/server/src/main/java/com/vaadin/server/themeutils/SASSAddonImportFileCreator.java +++ b/server/src/main/java/com/vaadin/server/themeutils/SASSAddonImportFileCreator.java @@ -100,7 +100,7 @@ public class SASSAddonImportFileCreator { // Sort addon styles so that CSS imports are first and SCSS import // last - List<String> paths = new ArrayList<String>(addonThemes.keySet()); + List<String> paths = new ArrayList<>(addonThemes.keySet()); Collections.sort(paths, new Comparator<String>() { @Override @@ -117,7 +117,7 @@ public class SASSAddonImportFileCreator { } }); - List<String> mixins = new ArrayList<String>(); + List<String> mixins = new ArrayList<>(); for (String path : paths) { mixins.addAll( addImport(printStream, path, addonThemes.get(path))); @@ -142,7 +142,7 @@ public class SASSAddonImportFileCreator { // Add import comment printImportComment(stream, location); - List<String> foundMixins = new ArrayList<String>(); + List<String> foundMixins = new ArrayList<>(); if (file.endsWith(".css")) { stream.print("@import url(\"../../../" + file + "\");\n"); 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 da5b692533..5d1bbbfa5f 100644 --- a/server/src/main/java/com/vaadin/server/widgetsetutils/ClassPathExplorer.java +++ b/server/src/main/java/com/vaadin/server/widgetsetutils/ClassPathExplorer.java @@ -145,8 +145,8 @@ public class ClassPathExplorer { */ public static LocationInfo getAvailableWidgetSetsAndStylesheets() { long start = System.currentTimeMillis(); - Map<String, URL> widgetsets = new HashMap<String, URL>(); - Map<String, URL> themes = new HashMap<String, URL>(); + Map<String, URL> widgetsets = new HashMap<>(); + Map<String, URL> themes = new HashMap<>(); Set<String> keySet = classpathLocations.keySet(); for (String location : keySet) { searchForWidgetSetsAndAddonStyles(location, widgetsets, themes); @@ -298,7 +298,7 @@ public class ClassPathExplorer { */ private final static List<String> getRawClasspathEntries() { // try to keep the order of the classpath - List<String> locations = new ArrayList<String>(); + List<String> locations = new ArrayList<>(); String pathSep = System.getProperty("path.separator"); String classpath = System.getProperty("java.class.path"); @@ -338,7 +338,7 @@ public class ClassPathExplorer { List<String> rawClasspathEntries) { long start = System.currentTimeMillis(); // try to keep the order of the classpath - Map<String, URL> locations = new LinkedHashMap<String, URL>(); + Map<String, URL> locations = new LinkedHashMap<>(); for (String classpathEntry : rawClasspathEntries) { File file = new File(classpathEntry); include(null, file, locations); @@ -520,7 +520,7 @@ public class ClassPathExplorer { public static URL getWidgetsetSourceDirectory(String widgetsetFileName) { if (debug) { debug("classpathLocations values:"); - ArrayList<String> locations = new ArrayList<String>( + ArrayList<String> locations = new ArrayList<>( classpathLocations.keySet()); for (String location : locations) { debug(String.valueOf(classpathLocations.get(location))); diff --git a/server/src/main/java/com/vaadin/server/widgetsetutils/WidgetSetBuilder.java b/server/src/main/java/com/vaadin/server/widgetsetutils/WidgetSetBuilder.java index 645c15fc1a..f64b43092f 100644 --- a/server/src/main/java/com/vaadin/server/widgetsetutils/WidgetSetBuilder.java +++ b/server/src/main/java/com/vaadin/server/widgetsetutils/WidgetSetBuilder.java @@ -168,7 +168,7 @@ public class WidgetSetBuilder { private static Collection<String> getCurrentInheritedWidgetsets( String content) { - HashSet<String> hashSet = new HashSet<String>(); + HashSet<String> hashSet = new HashSet<>(); Pattern inheritsPattern = Pattern.compile(" name=\"([^\"]*)\""); Matcher matcher = inheritsPattern.matcher(content); diff --git a/server/src/main/java/com/vaadin/ui/AbsoluteLayout.java b/server/src/main/java/com/vaadin/ui/AbsoluteLayout.java index 59221fcd83..d435bc806b 100644 --- a/server/src/main/java/com/vaadin/ui/AbsoluteLayout.java +++ b/server/src/main/java/com/vaadin/ui/AbsoluteLayout.java @@ -63,7 +63,7 @@ public class AbsoluteLayout extends AbstractLayout } }; // Maps each component to a position - private LinkedHashMap<Component, ComponentPosition> componentToCoordinates = new LinkedHashMap<Component, ComponentPosition>(); + private LinkedHashMap<Component, ComponentPosition> componentToCoordinates = new LinkedHashMap<>(); /** * Creates an AbsoluteLayout with full size. @@ -191,7 +191,7 @@ public class AbsoluteLayout extends AbstractLayout // Map<Connector,String> was supported. We cannot get the child // connectorId unless the component is attached to the application so // the String->String map cannot be populated in internal* either. - Map<String, String> connectorToPosition = new HashMap<String, String>(); + Map<String, String> connectorToPosition = new HashMap<>(); for (Iterator<Component> ci = getComponentIterator(); ci.hasNext();) { Component c = ci.next(); connectorToPosition.put(c.getConnectorId(), diff --git a/server/src/main/java/com/vaadin/ui/AbstractComponent.java b/server/src/main/java/com/vaadin/ui/AbstractComponent.java index 536e831d87..a34b09e9d8 100644 --- a/server/src/main/java/com/vaadin/ui/AbstractComponent.java +++ b/server/src/main/java/com/vaadin/ui/AbstractComponent.java @@ -197,7 +197,7 @@ public abstract class AbstractComponent extends AbstractClientConnector return; } if (getState().styles == null) { - getState().styles = new ArrayList<String>(); + getState().styles = new ArrayList<>(); } List<String> styles = getState().styles; styles.clear(); @@ -232,7 +232,7 @@ public abstract class AbstractComponent extends AbstractClientConnector } if (getState().styles == null) { - getState().styles = new ArrayList<String>(); + getState().styles = new ArrayList<>(); } List<String> styles = getState().styles; if (!styles.contains(style)) { @@ -1027,7 +1027,7 @@ public abstract class AbstractComponent extends AbstractClientConnector } // check for unsupported attributes - Set<String> supported = new HashSet<String>(); + Set<String> supported = new HashSet<>(); supported.addAll(getDefaultAttributes()); supported.addAll(getCustomAttributes()); for (Attribute a : attr) { @@ -1084,7 +1084,7 @@ public abstract class AbstractComponent extends AbstractClientConnector } } else { // remove responsive extensions - List<Extension> extensions = new ArrayList<Extension>( + List<Extension> extensions = new ArrayList<>( getExtensions()); for (Extension e : extensions) { if (e instanceof Responsive) { @@ -1263,7 +1263,7 @@ public abstract class AbstractComponent extends AbstractClientConnector * implementation */ protected Collection<String> getCustomAttributes() { - ArrayList<String> l = new ArrayList<String>( + ArrayList<String> l = new ArrayList<>( Arrays.asList(customAttributes)); if (this instanceof Focusable) { l.add("tab-index"); diff --git a/server/src/main/java/com/vaadin/ui/AbstractComponentContainer.java b/server/src/main/java/com/vaadin/ui/AbstractComponentContainer.java index 4dacf2c64a..b5fe4e9bcd 100644 --- a/server/src/main/java/com/vaadin/ui/AbstractComponentContainer.java +++ b/server/src/main/java/com/vaadin/ui/AbstractComponentContainer.java @@ -62,7 +62,7 @@ public abstract class AbstractComponentContainer extends AbstractComponent */ @Override public void removeAllComponents() { - final LinkedList<Component> l = new LinkedList<Component>(); + final LinkedList<Component> l = new LinkedList<>(); // Adds all components for (final Iterator<Component> i = getComponentIterator(); i @@ -83,7 +83,7 @@ public abstract class AbstractComponentContainer extends AbstractComponent */ @Override public void moveComponentsFrom(ComponentContainer source) { - final LinkedList<Component> components = new LinkedList<Component>(); + final LinkedList<Component> components = new LinkedList<>(); for (final Iterator<Component> i = source.getComponentIterator(); i .hasNext();) { components.add(i.next()); @@ -301,7 +301,7 @@ public abstract class AbstractComponentContainer extends AbstractComponent : ComponentSizeValidator.checkWidths(component); if (!valid) { if (components == null) { - components = new HashSet<Component>(); + components = new HashSet<>(); } components.add(component); } diff --git a/server/src/main/java/com/vaadin/ui/AbstractMedia.java b/server/src/main/java/com/vaadin/ui/AbstractMedia.java index f24c3e5e08..f56f6a7f27 100644 --- a/server/src/main/java/com/vaadin/ui/AbstractMedia.java +++ b/server/src/main/java/com/vaadin/ui/AbstractMedia.java @@ -152,7 +152,7 @@ public abstract class AbstractMedia extends AbstractComponent { * @return The sources pointed to in this media. */ public List<Resource> getSources() { - ArrayList<Resource> sources = new ArrayList<Resource>(); + ArrayList<Resource> sources = new ArrayList<>(); for (URLReference ref : getState(false).sources) { sources.add(((ResourceReference) ref).getResource()); } diff --git a/server/src/main/java/com/vaadin/ui/AbstractOrderedLayout.java b/server/src/main/java/com/vaadin/ui/AbstractOrderedLayout.java index 453adb2579..331a0e72be 100644 --- a/server/src/main/java/com/vaadin/ui/AbstractOrderedLayout.java +++ b/server/src/main/java/com/vaadin/ui/AbstractOrderedLayout.java @@ -58,7 +58,7 @@ public abstract class AbstractOrderedLayout extends AbstractLayout /** * Custom layout slots containing the components. */ - protected LinkedList<Component> components = new LinkedList<Component>(); + protected LinkedList<Component> components = new LinkedList<>(); private Alignment defaultComponentAlignment = Alignment.TOP_LEFT; diff --git a/server/src/main/java/com/vaadin/ui/ConnectorTracker.java b/server/src/main/java/com/vaadin/ui/ConnectorTracker.java index d92d554cf5..fd2c0029d1 100644 --- a/server/src/main/java/com/vaadin/ui/ConnectorTracker.java +++ b/server/src/main/java/com/vaadin/ui/ConnectorTracker.java @@ -67,21 +67,21 @@ import elemental.json.JsonObject; */ public class ConnectorTracker implements Serializable { - private final HashMap<String, ClientConnector> connectorIdToConnector = new HashMap<String, ClientConnector>(); - private Set<ClientConnector> dirtyConnectors = new HashSet<ClientConnector>(); - private Set<ClientConnector> uninitializedConnectors = new HashSet<ClientConnector>(); + private final HashMap<String, ClientConnector> connectorIdToConnector = new HashMap<>(); + private Set<ClientConnector> dirtyConnectors = new HashSet<>(); + private Set<ClientConnector> uninitializedConnectors = new HashSet<>(); /** * Connectors that have been unregistered and should be cleaned up the next * time {@link #cleanConnectorMap()} is invoked unless they have been * registered again. */ - private final Set<ClientConnector> unregisteredConnectors = new HashSet<ClientConnector>(); + private final Set<ClientConnector> unregisteredConnectors = new HashSet<>(); private boolean writingResponse = false; private UI uI; - private transient Map<ClientConnector, JsonObject> diffStates = new HashMap<ClientConnector, JsonObject>(); + private transient Map<ClientConnector, JsonObject> diffStates = new HashMap<>(); /** Maps connectorIds to a map of named StreamVariables */ private Map<String, Map<String, StreamVariable>> pidToNameToStreamVariable; @@ -96,7 +96,7 @@ public class ConnectorTracker implements Serializable { * @see #getCurrentSyncId() * @see #cleanConcurrentlyRemovedConnectorIds(long) */ - private TreeMap<Integer, Set<String>> syncIdToUnregisteredConnectorIds = new TreeMap<Integer, Set<String>>(); + private TreeMap<Integer, Set<String>> syncIdToUnregisteredConnectorIds = new TreeMap<>(); /** * Gets a logger for this class @@ -185,7 +185,7 @@ public class ConnectorTracker implements Serializable { Set<String> unregisteredConnectorIds = syncIdToUnregisteredConnectorIds .get(currentSyncId); if (unregisteredConnectorIds == null) { - unregisteredConnectorIds = new HashSet<String>(); + unregisteredConnectorIds = new HashSet<>(); syncIdToUnregisteredConnectorIds.put(currentSyncId, unregisteredConnectorIds); } @@ -438,10 +438,10 @@ public class ConnectorTracker implements Serializable { private boolean isHierarchyComplete() { boolean noErrors = true; - Set<ClientConnector> danglingConnectors = new HashSet<ClientConnector>( + Set<ClientConnector> danglingConnectors = new HashSet<>( connectorIdToConnector.values()); - LinkedList<ClientConnector> stack = new LinkedList<ClientConnector>(); + LinkedList<ClientConnector> stack = new LinkedList<>(); stack.add(uI); while (!stack.isEmpty()) { ClientConnector connector = stack.pop(); @@ -623,7 +623,7 @@ public class ConnectorTracker implements Serializable { */ public ArrayList<ClientConnector> getDirtyVisibleConnectors() { Collection<ClientConnector> dirtyConnectors = getDirtyConnectors(); - ArrayList<ClientConnector> dirtyVisibleConnectors = new ArrayList<ClientConnector>( + ArrayList<ClientConnector> dirtyVisibleConnectors = new ArrayList<>( dirtyConnectors.size()); for (ClientConnector c : dirtyConnectors) { if (LegacyCommunicationManager.isConnectorVisibleToClient(c)) { @@ -706,7 +706,7 @@ public class ConnectorTracker implements Serializable { out.defaultWriteObject(); // Convert JsonObjects in diff state to String representation as // JsonObject is not serializable - HashMap<ClientConnector, String> stringDiffStates = new HashMap<ClientConnector, String>( + HashMap<ClientConnector, String> stringDiffStates = new HashMap<>( diffStates.size() * 2); for (ClientConnector key : diffStates.keySet()) { stringDiffStates.put(key, diffStates.get(key).toString()); @@ -721,11 +721,11 @@ public class ConnectorTracker implements Serializable { // Read String versions of JsonObjects and parse into JsonObjects as // JsonObject is not serializable - diffStates = new HashMap<ClientConnector, JsonObject>(); + diffStates = new HashMap<>(); @SuppressWarnings("unchecked") HashMap<ClientConnector, String> stringDiffStates = (HashMap<ClientConnector, String>) in .readObject(); - diffStates = new HashMap<ClientConnector, JsonObject>( + diffStates = new HashMap<>( stringDiffStates.size() * 2); for (ClientConnector key : stringDiffStates.keySet()) { try { @@ -770,18 +770,18 @@ public class ConnectorTracker implements Serializable { StreamVariable variable) { assert getConnector(connectorId) != null; if (pidToNameToStreamVariable == null) { - pidToNameToStreamVariable = new HashMap<String, Map<String, StreamVariable>>(); + pidToNameToStreamVariable = new HashMap<>(); } Map<String, StreamVariable> nameToStreamVariable = pidToNameToStreamVariable .get(connectorId); if (nameToStreamVariable == null) { - nameToStreamVariable = new HashMap<String, StreamVariable>(); + nameToStreamVariable = new HashMap<>(); pidToNameToStreamVariable.put(connectorId, nameToStreamVariable); } nameToStreamVariable.put(variableName, variable); if (streamVariableToSeckey == null) { - streamVariableToSeckey = new HashMap<StreamVariable, String>(); + streamVariableToSeckey = new HashMap<>(); } String seckey = streamVariableToSeckey.get(variable); if (seckey == null) { diff --git a/server/src/main/java/com/vaadin/ui/CssLayout.java b/server/src/main/java/com/vaadin/ui/CssLayout.java index 982c55cab2..381e7aa463 100644 --- a/server/src/main/java/com/vaadin/ui/CssLayout.java +++ b/server/src/main/java/com/vaadin/ui/CssLayout.java @@ -85,7 +85,7 @@ public class CssLayout extends AbstractLayout implements LayoutClickNotifier { /** * Custom layout slots containing the components. */ - protected LinkedList<Component> components = new LinkedList<Component>(); + protected LinkedList<Component> components = new LinkedList<>(); /** * Constructs an empty CssLayout. diff --git a/server/src/main/java/com/vaadin/ui/CustomLayout.java b/server/src/main/java/com/vaadin/ui/CustomLayout.java index 11ab9c2f0e..179969765d 100644 --- a/server/src/main/java/com/vaadin/ui/CustomLayout.java +++ b/server/src/main/java/com/vaadin/ui/CustomLayout.java @@ -67,7 +67,7 @@ public class CustomLayout extends AbstractLayout implements LegacyComponent { /** * Custom layout slots containing the components. */ - private final HashMap<String, Component> slots = new HashMap<String, Component>(); + private final HashMap<String, Component> slots = new HashMap<>(); /** * Default constructor only used by subclasses. Subclasses are responsible diff --git a/server/src/main/java/com/vaadin/ui/DragAndDropWrapper.java b/server/src/main/java/com/vaadin/ui/DragAndDropWrapper.java index 280f80ee21..deffa06631 100644 --- a/server/src/main/java/com/vaadin/ui/DragAndDropWrapper.java +++ b/server/src/main/java/com/vaadin/ui/DragAndDropWrapper.java @@ -120,7 +120,7 @@ public class DragAndDropWrapper extends CustomComponent } }; - private Map<String, ProxyReceiver> receivers = new HashMap<String, ProxyReceiver>(); + private Map<String, ProxyReceiver> receivers = new HashMap<>(); public class WrapperTargetDetails extends TargetDetailsImpl { @@ -191,11 +191,11 @@ public class DragAndDropWrapper extends CustomComponent COMPONENT_OTHER, } - private final Map<String, Object> html5DataFlavors = new LinkedHashMap<String, Object>(); + private final Map<String, Object> html5DataFlavors = new LinkedHashMap<>(); private DragStartMode dragStartMode = DragStartMode.NONE; private Component dragImageComponent = null; - private Set<String> sentIds = new HashSet<String>(); + private Set<String> sentIds = new HashSet<>(); /** * This is an internal constructor. Use diff --git a/server/src/main/java/com/vaadin/ui/Embedded.java b/server/src/main/java/com/vaadin/ui/Embedded.java index 382b0d47c3..b0c7f1725b 100644 --- a/server/src/main/java/com/vaadin/ui/Embedded.java +++ b/server/src/main/java/com/vaadin/ui/Embedded.java @@ -88,7 +88,7 @@ public class Embedded extends AbstractComponent implements LegacyComponent { /** * Hash of object parameters. */ - private final Map<String, String> parameters = new HashMap<String, String>(); + private final Map<String, String> parameters = new HashMap<>(); /** * Applet or other client side runnable properties. diff --git a/server/src/main/java/com/vaadin/ui/Flash.java b/server/src/main/java/com/vaadin/ui/Flash.java index c6eac450ef..faec5a83d9 100644 --- a/server/src/main/java/com/vaadin/ui/Flash.java +++ b/server/src/main/java/com/vaadin/ui/Flash.java @@ -201,7 +201,7 @@ public class Flash extends AbstractEmbedded { */ public void setParameter(String name, String value) { if (getState().embedParams == null) { - getState().embedParams = new HashMap<String, String>(); + getState().embedParams = new HashMap<>(); } getState().embedParams.put(name, value); requestRepaint(); @@ -238,7 +238,7 @@ public class Flash extends AbstractEmbedded { super.writeDesign(design, designContext); // Parameters, in alphabetic order - ArrayList<String> paramNames = new ArrayList<String>(); + ArrayList<String> paramNames = new ArrayList<>(); for (String param : getParameterNames()) { paramNames.add(param); } diff --git a/server/src/main/java/com/vaadin/ui/GridLayout.java b/server/src/main/java/com/vaadin/ui/GridLayout.java index 546a89cdfc..6e74071f65 100644 --- a/server/src/main/java/com/vaadin/ui/GridLayout.java +++ b/server/src/main/java/com/vaadin/ui/GridLayout.java @@ -97,10 +97,10 @@ public class GridLayout extends AbstractLayout */ private int cursorY = 0; - private final LinkedList<Component> components = new LinkedList<Component>(); + private final LinkedList<Component> components = new LinkedList<>(); - private Map<Integer, Float> columnExpandRatio = new HashMap<Integer, Float>(); - private Map<Integer, Float> rowExpandRatio = new HashMap<Integer, Float>(); + private Map<Integer, Float> columnExpandRatio = new HashMap<>(); + private Map<Integer, Float> rowExpandRatio = new HashMap<>(); private Alignment defaultComponentAlignment = Alignment.TOP_LEFT; /** @@ -1290,8 +1290,8 @@ public class GridLayout extends AbstractLayout setMargin(readMargin(design, getMargin(), designContext)); - List<Element> rowElements = new ArrayList<Element>(); - List<Map<Integer, Component>> rows = new ArrayList<Map<Integer, Component>>(); + List<Element> rowElements = new ArrayList<>(); + List<Map<Integer, Component>> rows = new ArrayList<>(); // Prepare a 2D map for reading column contents for (Element e : design.children()) { if (e.tagName().equalsIgnoreCase("row")) { @@ -1301,8 +1301,8 @@ public class GridLayout extends AbstractLayout } } setRows(Math.max(rows.size(), 1)); - Map<Component, Alignment> alignments = new HashMap<Component, Alignment>(); - List<Integer> columnExpandRatios = new ArrayList<Integer>(); + Map<Component, Alignment> alignments = new HashMap<>(); + List<Integer> columnExpandRatios = new ArrayList<>(); for (int row = 0; row < rowElements.size(); ++row) { Element rowElement = rowElements.get(row); @@ -1386,7 +1386,7 @@ public class GridLayout extends AbstractLayout } // Reiterate through the 2D map and add components to GridLayout - Set<Component> visited = new HashSet<Component>(); + Set<Component> visited = new HashSet<>(); // Ignore any missing components visited.add(null); @@ -1457,7 +1457,7 @@ public class GridLayout extends AbstractLayout } // Go through the map and write only needed column tags - Set<Connector> visited = new HashSet<Connector>(); + Set<Connector> visited = new HashSet<>(); // Skip the dummy placeholder visited.add(dummyComponent); diff --git a/server/src/main/java/com/vaadin/ui/JavaScript.java b/server/src/main/java/com/vaadin/ui/JavaScript.java index b51577c4ac..92320c6df1 100644 --- a/server/src/main/java/com/vaadin/ui/JavaScript.java +++ b/server/src/main/java/com/vaadin/ui/JavaScript.java @@ -38,7 +38,7 @@ import elemental.json.JsonException; * @since 7.0.0 */ public class JavaScript extends AbstractExtension { - private Map<String, JavaScriptFunction> functions = new HashMap<String, JavaScriptFunction>(); + private Map<String, JavaScriptFunction> functions = new HashMap<>(); // Can not be defined in client package as this JSONArray is not available // in GWT diff --git a/server/src/main/java/com/vaadin/ui/LoginForm.java b/server/src/main/java/com/vaadin/ui/LoginForm.java index 9e986d34fb..fe31eb3d75 100644 --- a/server/src/main/java/com/vaadin/ui/LoginForm.java +++ b/server/src/main/java/com/vaadin/ui/LoginForm.java @@ -353,7 +353,7 @@ public class LoginForm extends AbstractSingleComponentContainer { * URL in the method or the password manager will not be triggered. */ private void login() { - HashMap<String, String> params = new HashMap<String, String>(); + HashMap<String, String> params = new HashMap<>(); params.put("username", getUsernameField().getValue()); params.put("password", getPasswordField().getValue()); LoginEvent event = new LoginEvent(LoginForm.this, params); diff --git a/server/src/main/java/com/vaadin/ui/MenuBar.java b/server/src/main/java/com/vaadin/ui/MenuBar.java index db252b0619..24f2dd89b3 100644 --- a/server/src/main/java/com/vaadin/ui/MenuBar.java +++ b/server/src/main/java/com/vaadin/ui/MenuBar.java @@ -162,7 +162,7 @@ public class MenuBar extends AbstractComponent /** Deserialize changes received from client. */ @Override public void changeVariables(Object source, Map<String, Object> variables) { - Stack<MenuItem> items = new Stack<MenuItem>(); + Stack<MenuItem> items = new Stack<>(); boolean found = false; if (variables.containsKey("clickedId")) { @@ -205,7 +205,7 @@ public class MenuBar extends AbstractComponent * Constructs an empty, horizontal menu */ public MenuBar() { - menuItems = new ArrayList<MenuItem>(); + menuItems = new ArrayList<>(); setMoreMenuItem(null); } @@ -554,7 +554,7 @@ public class MenuBar extends AbstractComponent } if (itsChildren == null) { - itsChildren = new ArrayList<MenuItem>(); + itsChildren = new ArrayList<>(); } MenuItem newItem = new MenuItem(caption, icon, command); @@ -1005,7 +1005,7 @@ public class MenuBar extends AbstractComponent } String caption = ""; - List<Element> subMenus = new ArrayList<Element>(); + List<Element> subMenus = new ArrayList<>(); for (Node node : menuElement.childNodes()) { if (node instanceof Element && ((Element) node).tagName().equals("menu")) { @@ -1051,7 +1051,7 @@ public class MenuBar extends AbstractComponent } if (!subMenus.isEmpty()) { - menu.itsChildren = new ArrayList<MenuItem>(); + menu.itsChildren = new ArrayList<>(); } for (Element subMenu : subMenus) { diff --git a/server/src/main/java/com/vaadin/ui/TabSheet.java b/server/src/main/java/com/vaadin/ui/TabSheet.java index ff9e1813f6..a03b342ba0 100644 --- a/server/src/main/java/com/vaadin/ui/TabSheet.java +++ b/server/src/main/java/com/vaadin/ui/TabSheet.java @@ -106,12 +106,12 @@ public class TabSheet extends AbstractComponentContainer * there is a {@link Tab} object in tabs for each tab with meta-data about * the tab. */ - private final ArrayList<Component> components = new ArrayList<Component>(); + private final ArrayList<Component> components = new ArrayList<>(); /** * Map containing information related to the tabs (caption, icon etc). */ - private final HashMap<Component, Tab> tabs = new HashMap<Component, Tab>(); + private final HashMap<Component, Tab> tabs = new HashMap<>(); /** * Selected tab content component. @@ -122,7 +122,7 @@ public class TabSheet extends AbstractComponentContainer * Mapper between server-side component instances (tab contents) and keys * given to the client that identify tabs. */ - private final KeyMapper<Component> keyMapper = new KeyMapper<Component>(); + private final KeyMapper<Component> keyMapper = new KeyMapper<>(); /** * Handler to be called when a tab is closed. diff --git a/server/src/main/java/com/vaadin/ui/UI.java b/server/src/main/java/com/vaadin/ui/UI.java index 4454f96596..82bbea7039 100644 --- a/server/src/main/java/com/vaadin/ui/UI.java +++ b/server/src/main/java/com/vaadin/ui/UI.java @@ -116,7 +116,7 @@ public abstract class UI extends AbstractSingleComponentContainer /** * List of windows in this UI. */ - private final LinkedHashSet<Window> windows = new LinkedHashSet<Window>(); + private final LinkedHashSet<Window> windows = new LinkedHashSet<>(); /** * The component that should be scrolled into view after the next repaint. @@ -415,7 +415,7 @@ public abstract class UI extends AbstractSingleComponentContainer public Iterator<Component> iterator() { // TODO could directly create some kind of combined iterator instead of // creating a new ArrayList - ArrayList<Component> components = new ArrayList<Component>(); + ArrayList<Component> components = new ArrayList<>(); if (getContent() != null) { components.add(getContent()); diff --git a/server/src/main/java/com/vaadin/ui/Upload.java b/server/src/main/java/com/vaadin/ui/Upload.java index 915e2035fa..9077a35b95 100644 --- a/server/src/main/java/com/vaadin/ui/Upload.java +++ b/server/src/main/java/com/vaadin/ui/Upload.java @@ -783,7 +783,7 @@ public class Upload extends AbstractComponent */ public void addProgressListener(ProgressListener listener) { if (progressListeners == null) { - progressListeners = new LinkedHashSet<ProgressListener>(); + progressListeners = new LinkedHashSet<>(); } progressListeners.add(listener); } diff --git a/server/src/main/java/com/vaadin/ui/Window.java b/server/src/main/java/com/vaadin/ui/Window.java index 6ad8ef500b..c0eac75970 100644 --- a/server/src/main/java/com/vaadin/ui/Window.java +++ b/server/src/main/java/com/vaadin/ui/Window.java @@ -106,7 +106,7 @@ public class Window extends Panel /** * Holds registered CloseShortcut instances for query and later removal */ - private List<CloseShortcut> closeShortcuts = new ArrayList<CloseShortcut>( + private List<CloseShortcut> closeShortcuts = new ArrayList<>( 4); /** @@ -1398,7 +1398,7 @@ public class Window extends Panel @Override protected void readDesignChildren(Elements children, DesignContext context) { - List<Component> descriptions = new ArrayList<Component>(); + List<Component> descriptions = new ArrayList<>(); Elements content = new Elements(); for (Element child : children) { 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 ba5c279ed1..a70ab256e1 100644 --- a/server/src/main/java/com/vaadin/ui/declarative/DesignAttributeHandler.java +++ b/server/src/main/java/com/vaadin/ui/declarative/DesignAttributeHandler.java @@ -55,7 +55,7 @@ public class DesignAttributeHandler implements Serializable { return Logger.getLogger(DesignAttributeHandler.class.getName()); } - private static Map<Class<?>, AttributeCacheEntry> cache = new ConcurrentHashMap<Class<?>, AttributeCacheEntry>(); + private static Map<Class<?>, AttributeCacheEntry> cache = new ConcurrentHashMap<>(); // translates string <-> object private static DesignFormatter FORMATTER = new DesignFormatter(); @@ -81,7 +81,7 @@ public class DesignAttributeHandler implements Serializable { for (Attribute a : attr.asList()) { attr.remove(a.getKey()); } - List<Node> children = new ArrayList<Node>(); + List<Node> children = new ArrayList<>(); children.addAll(design.childNodes()); for (Node node : children) { node.remove(); @@ -428,7 +428,7 @@ public class DesignAttributeHandler implements Serializable { * @author Vaadin Ltd */ private static class AttributeCacheEntry implements Serializable { - private Map<String, Method[]> accessMethods = new ConcurrentHashMap<String, Method[]>(); + private Map<String, Method[]> accessMethods = new ConcurrentHashMap<>(); private void addAttribute(String attribute, Method getter, Method setter) { @@ -439,7 +439,7 @@ public class DesignAttributeHandler implements Serializable { } private Collection<String> getAttributes() { - ArrayList<String> attributes = new ArrayList<String>(); + ArrayList<String> attributes = new ArrayList<>(); attributes.addAll(accessMethods.keySet()); return attributes; } diff --git a/server/src/main/java/com/vaadin/ui/declarative/DesignContext.java b/server/src/main/java/com/vaadin/ui/declarative/DesignContext.java index 505437d778..35145c45fb 100644 --- a/server/src/main/java/com/vaadin/ui/declarative/DesignContext.java +++ b/server/src/main/java/com/vaadin/ui/declarative/DesignContext.java @@ -64,7 +64,7 @@ public class DesignContext implements Serializable { private static final String VAADIN7_UI_PACKAGE = "com.vaadin.v7.ui"; // cache for object instances - private static Map<Class<?>, Component> instanceCache = new ConcurrentHashMap<Class<?>, Component>(); + private static Map<Class<?>, Component> instanceCache = new ConcurrentHashMap<>(); // The root component of the component hierarchy private Component rootComponent = null; @@ -74,20 +74,20 @@ public class DesignContext implements Serializable { public static final String CAPTION_ATTRIBUTE = "caption"; public static final String LOCAL_ID_ATTRIBUTE = "_id"; // Mappings from ids to components. Modified when reading from design. - private Map<String, Component> idToComponent = new HashMap<String, Component>(); - private Map<String, Component> localIdToComponent = new HashMap<String, Component>(); - private Map<String, Component> captionToComponent = new HashMap<String, Component>(); + private Map<String, Component> idToComponent = new HashMap<>(); + private Map<String, Component> localIdToComponent = new HashMap<>(); + private Map<String, Component> captionToComponent = new HashMap<>(); // Mapping from components to local ids. Accessed when writing to // design. Modified when reading from design. - private Map<Component, String> componentToLocalId = new HashMap<Component, String>(); + private Map<Component, String> componentToLocalId = new HashMap<>(); private Document doc; // required for calling createElement(String) // namespace mappings - private Map<String, String> packageToPrefix = new HashMap<String, String>(); - private Map<String, String> prefixToPackage = new HashMap<String, String>(); - private final Map<Component, Map<String, String>> customAttributes = new HashMap<Component, Map<String, String>>(); + private Map<String, String> packageToPrefix = new HashMap<>(); + private Map<String, String> prefixToPackage = new HashMap<>(); + private final Map<Component, Map<String, String>> customAttributes = new HashMap<>(); // component creation listeners - private List<ComponentCreationListener> listeners = new ArrayList<ComponentCreationListener>(); + private List<ComponentCreationListener> listeners = new ArrayList<>(); private ShouldWriteDataDelegate shouldWriteDataDelegate = ShouldWriteDataDelegate.DEFAULT; @@ -828,7 +828,7 @@ public class DesignContext implements Serializable { Map<String, String> map = customAttributes.get(component); if (map == null) { customAttributes.put(component, - map = new HashMap<String, String>()); + map = new HashMap<>()); } map.put(attribute, value); } diff --git a/server/src/main/java/com/vaadin/ui/declarative/DesignFormatter.java b/server/src/main/java/com/vaadin/ui/declarative/DesignFormatter.java index 0fcefe0a27..203954dd27 100644 --- a/server/src/main/java/com/vaadin/ui/declarative/DesignFormatter.java +++ b/server/src/main/java/com/vaadin/ui/declarative/DesignFormatter.java @@ -55,7 +55,7 @@ import com.vaadin.ui.declarative.converters.DesignToStringConverter; */ public class DesignFormatter implements Serializable { - private final Map<Class<?>, Converter<String, ?>> converterMap = new ConcurrentHashMap<Class<?>, Converter<String, ?>>(); + private final Map<Class<?>, Converter<String, ?>> converterMap = new ConcurrentHashMap<>(); private final Converter<String, Object> stringObjectConverter = new DesignObjectConverter(); /** diff --git a/server/src/main/java/com/vaadin/ui/declarative/FieldBinder.java b/server/src/main/java/com/vaadin/ui/declarative/FieldBinder.java index 25469b8cde..3d7dcc20d9 100644 --- a/server/src/main/java/com/vaadin/ui/declarative/FieldBinder.java +++ b/server/src/main/java/com/vaadin/ui/declarative/FieldBinder.java @@ -40,7 +40,7 @@ public class FieldBinder implements Serializable { // the instance containing the bound fields private Object bindTarget; // mapping between field names and Fields - private Map<String, Field> fieldMap = new HashMap<String, Field>(); + private Map<String, Field> fieldMap = new HashMap<>(); /** * Creates a new instance of LayoutFieldBinder. @@ -79,7 +79,7 @@ public class FieldBinder implements Serializable { * @return a collection of fields assignable to Component that are not bound */ public Collection<String> getUnboundFields() throws FieldBindingException { - List<String> unboundFields = new ArrayList<String>(); + List<String> unboundFields = new ArrayList<>(); for (Field f : fieldMap.values()) { try { Object value = getFieldValue(bindTarget, f); @@ -252,7 +252,7 @@ public class FieldBinder implements Serializable { */ protected static List<java.lang.reflect.Field> getFields( Class<?> searchClass) { - ArrayList<java.lang.reflect.Field> memberFields = new ArrayList<java.lang.reflect.Field>(); + ArrayList<java.lang.reflect.Field> memberFields = new ArrayList<>(); for (java.lang.reflect.Field memberField : searchClass .getDeclaredFields()) { 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 cc9d6ac655..1efc382fcc 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 @@ -169,7 +169,7 @@ public class DesignResourceConverter implements Converter<String, Resource> { return ((ExternalResource) value).getURL(); } - private static Map<Class<? extends Resource>, ResourceConverterByProtocol> typeToConverter = new HashMap<Class<? extends Resource>, ResourceConverterByProtocol>(); + private static Map<Class<? extends Resource>, ResourceConverterByProtocol> typeToConverter = new HashMap<>(); static { typeToConverter.put(ExternalResource.class, HTTP); // ^ any of non-specialized would actually work diff --git a/server/src/main/java/com/vaadin/ui/declarative/converters/DesignShortcutActionConverter.java b/server/src/main/java/com/vaadin/ui/declarative/converters/DesignShortcutActionConverter.java index fdd61f0489..2468c29c8c 100644 --- a/server/src/main/java/com/vaadin/ui/declarative/converters/DesignShortcutActionConverter.java +++ b/server/src/main/java/com/vaadin/ui/declarative/converters/DesignShortcutActionConverter.java @@ -40,7 +40,7 @@ public class DesignShortcutActionConverter private final Map<String, Integer> presentationMap; public DesignShortcutActionConverter() { - HashMap<Integer, String> codes = new HashMap<Integer, String>(); + HashMap<Integer, String> codes = new HashMap<>(); // map modifiers codes.put(ModifierKey.ALT, "alt"); codes.put(ModifierKey.CTRL, "ctrl"); @@ -112,7 +112,7 @@ public class DesignShortcutActionConverter keyCodeMap = Collections.unmodifiableMap(codes); - HashMap<String, Integer> presentations = new HashMap<String, Integer>(); + HashMap<String, Integer> presentations = new HashMap<>(); for (Entry<Integer, String> entry : keyCodeMap.entrySet()) { presentations.put(entry.getValue(), entry.getKey()); } diff --git a/server/src/main/java/com/vaadin/ui/declarative/converters/ShortcutKeyMapper.java b/server/src/main/java/com/vaadin/ui/declarative/converters/ShortcutKeyMapper.java index 1862173aba..b1010d811d 100644 --- a/server/src/main/java/com/vaadin/ui/declarative/converters/ShortcutKeyMapper.java +++ b/server/src/main/java/com/vaadin/ui/declarative/converters/ShortcutKeyMapper.java @@ -54,8 +54,8 @@ public interface ShortcutKeyMapper extends Serializable { */ public static final ShortcutKeyMapper DEFAULT = new ShortcutKeyMapper() { - private final Map<Integer, String> keyCodeMap = new ConcurrentHashMap<Integer, String>(); - private final Map<String, Integer> presentationMap = new ConcurrentHashMap<String, Integer>(); + private final Map<Integer, String> keyCodeMap = new ConcurrentHashMap<>(); + private final Map<String, Integer> presentationMap = new ConcurrentHashMap<>(); { // map modifiers diff --git a/server/src/main/java/com/vaadin/util/ConnectorHelper.java b/server/src/main/java/com/vaadin/util/ConnectorHelper.java index 3cb6a1c425..5b5958175b 100644 --- a/server/src/main/java/com/vaadin/util/ConnectorHelper.java +++ b/server/src/main/java/com/vaadin/util/ConnectorHelper.java @@ -66,7 +66,7 @@ public class ConnectorHelper { */ public static void writeHierarchyInformation(ClientConnector connector, StringBuilder builder) { - LinkedList<ClientConnector> h = new LinkedList<ClientConnector>(); + LinkedList<ClientConnector> h = new LinkedList<>(); h.add(connector); ClientConnector parent = connector.getParent(); while (parent != null) { diff --git a/server/src/main/java/com/vaadin/util/CurrentInstance.java b/server/src/main/java/com/vaadin/util/CurrentInstance.java index be5300e915..f8d6af2a4c 100644 --- a/server/src/main/java/com/vaadin/util/CurrentInstance.java +++ b/server/src/main/java/com/vaadin/util/CurrentInstance.java @@ -72,7 +72,7 @@ public class CurrentInstance implements Serializable { return null; } - Map<Class<?>, CurrentInstance> value = new HashMap<Class<?>, CurrentInstance>(); + Map<Class<?>, CurrentInstance> value = new HashMap<>(); // Copy all inheritable values to child map for (Entry<Class<?>, CurrentInstance> e : parentValue.entrySet()) { @@ -86,7 +86,7 @@ public class CurrentInstance implements Serializable { }; private CurrentInstance(Object instance, boolean inheritable) { - this.instance = new WeakReference<Object>(instance); + this.instance = new WeakReference<>(instance); this.inheritable = inheritable; } @@ -200,7 +200,7 @@ public class CurrentInstance implements Serializable { } else { assert type.isInstance(instance) : "Invald instance type"; if (map == null) { - map = new HashMap<Class<?>, CurrentInstance>(); + map = new HashMap<>(); instances.set(map); } @@ -286,7 +286,7 @@ public class CurrentInstance implements Serializable { if (map == null) { return Collections.emptyMap(); } else { - Map<Class<?>, CurrentInstance> copy = new HashMap<Class<?>, CurrentInstance>(); + Map<Class<?>, CurrentInstance> copy = new HashMap<>(); boolean removeStale = false; for (Class<?> c : map.keySet()) { CurrentInstance ci = map.get(c); @@ -338,7 +338,7 @@ public class CurrentInstance implements Serializable { */ public static Map<Class<?>, CurrentInstance> setCurrent( VaadinSession session) { - Map<Class<?>, CurrentInstance> old = new HashMap<Class<?>, CurrentInstance>(); + Map<Class<?>, CurrentInstance> old = new HashMap<>(); old.put(VaadinSession.class, set(VaadinSession.class, session, true)); VaadinService service = null; if (session != null) { diff --git a/server/src/main/java/com/vaadin/util/FileTypeResolver.java b/server/src/main/java/com/vaadin/util/FileTypeResolver.java index 7700ff9563..305bc1c5d7 100644 --- a/server/src/main/java/com/vaadin/util/FileTypeResolver.java +++ b/server/src/main/java/com/vaadin/util/FileTypeResolver.java @@ -210,12 +210,12 @@ public class FileTypeResolver implements Serializable { /** * File extension to MIME type mapping. All extensions are in lower case. */ - static private Hashtable<String, String> extToMIMEMap = new Hashtable<String, String>(); + static private Hashtable<String, String> extToMIMEMap = new Hashtable<>(); /** * MIME type to Icon mapping. */ - static private Hashtable<String, Resource> MIMEToIconMap = new Hashtable<String, Resource>(); + static private Hashtable<String, Resource> MIMEToIconMap = new Hashtable<>(); static { |