From 721d9125abd1ccb20ab635c0bd20752ebca9b4f8 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sat, 25 Oct 2014 19:14:15 -0700 Subject: [PATCH] GUAC-904: Implement copy constructor for GuacamoleConfiguration. --- .../protocol/GuacamoleConfiguration.java | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/guacamole-common/src/main/java/org/glyptodon/guacamole/protocol/GuacamoleConfiguration.java b/guacamole-common/src/main/java/org/glyptodon/guacamole/protocol/GuacamoleConfiguration.java index 6140f9fc5..e43841236 100644 --- a/guacamole-common/src/main/java/org/glyptodon/guacamole/protocol/GuacamoleConfiguration.java +++ b/guacamole-common/src/main/java/org/glyptodon/guacamole/protocol/GuacamoleConfiguration.java @@ -56,7 +56,33 @@ public class GuacamoleConfiguration implements Serializable { /** * Map of all associated parameter values, indexed by parameter name. */ - private Map parameters = new HashMap(); + private final Map parameters = new HashMap(); + + /** + * Creates a new, blank GuacamoleConfiguration with its protocol, connection + * ID, and parameters unset. + */ + public GuacamoleConfiguration() { + } + + /** + * Copies the given GuacamoleConfiguration, creating a new, indepedent + * GuacamoleConfiguration containing the same protocol, connection ID, + * and parameter values, if any. + * + * @param config The GuacamoleConfiguration to copy. + */ + public GuacamoleConfiguration(GuacamoleConfiguration config) { + + // Copy protocol and connection ID + protocol = config.getProtocol(); + connectionID = config.getConnectionID(); + + // Copy parameter values + for (String name : config.getParameterNames()) + parameters.put(name, config.getParameter(name)); + + } /** * Returns the ID of the connection being joined, if any. If no connection