1 /* 2 * Copyright 2012-2013 smartics, Kronseder & Reiner GmbH 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package de.smartics.properties.api.config.domain; 17 18 import de.smartics.exceptions.i18n.message.MessageParam; 19 import de.smartics.properties.api.config.domain.key.ConfigurationKey; 20 21 /** 22 * Signals that a configuration with the given key has already been registered. 23 */ 24 public final class DuplicateConfigurationException extends 25 ConfigurationException 26 { 27 // ********************************* Fields ********************************* 28 29 // --- constants ------------------------------------------------------------ 30 31 /** 32 * The class version identifier. 33 */ 34 private static final long serialVersionUID = 1L; 35 36 // --- members -------------------------------------------------------------- 37 38 /** 39 * The configuration that has been registered and is currently active. 40 * 41 * @serial 42 */ 43 @MessageParam("current") 44 private final ConfigurationPropertiesManagement currentConfigurationProperties; 45 46 /** 47 * The configuration that is a duplication of the current configuration and 48 * has been rejected from being registered with the given key. 49 * 50 * @serial 51 */ 52 @MessageParam("duplicate") 53 private final ConfigurationPropertiesManagement duplicateConfigurationProperties; 54 55 // ****************************** Initializer ******************************* 56 57 // ****************************** Constructors ****************************** 58 59 /** 60 * Convenience constructor without root cause. 61 * 62 * @param key the key to the configuration that signaled problems. 63 * @param currentConfigurationProperties the configuration that has been 64 * registered and is currently active. 65 * @param duplicateConfigurationProperties the configuration that is a 66 * duplication of the current configuration and has been rejected 67 * from being registered with the given key. 68 */ 69 public DuplicateConfigurationException(final ConfigurationKey<?> key, 70 final ConfigurationPropertiesManagement currentConfigurationProperties, 71 final ConfigurationPropertiesManagement duplicateConfigurationProperties) 72 { 73 this(null, key, currentConfigurationProperties, 74 duplicateConfigurationProperties); 75 } 76 77 /** 78 * Default Constructor. 79 * 80 * @param cause the cause (which is saved for later retrieval by the 81 * {@link #getCause()} method). (A <tt>null</tt> value is permitted, 82 * and indicates that the cause is nonexistent or unknown.) 83 * @param key the key to the configuration that signaled problems. 84 * @param currentConfigurationProperties the configuration that has been 85 * registered and is currently active. 86 * @param duplicateConfigurationProperties the configuration that is a 87 * duplication of the current configuration and has been rejected 88 * from being registered with the given key. 89 */ 90 public DuplicateConfigurationException(final Throwable cause, 91 final ConfigurationKey<?> key, 92 final ConfigurationPropertiesManagement currentConfigurationProperties, 93 final ConfigurationPropertiesManagement duplicateConfigurationProperties) 94 { 95 super(ConfigurationCode.DUPLICATE_CONFIGURATION, cause, key); 96 97 this.currentConfigurationProperties = currentConfigurationProperties; 98 this.duplicateConfigurationProperties = duplicateConfigurationProperties; 99 } 100 101 // ****************************** Inner Classes ***************************** 102 103 // ********************************* Methods ******************************** 104 105 // --- init ----------------------------------------------------------------- 106 107 // --- get&set -------------------------------------------------------------- 108 109 /** 110 * Returns the configuration that has been registered and is currently active. 111 * 112 * @return the configuration that has been registered and is currently active. 113 */ 114 public ConfigurationPropertiesManagement getCurrentConfigurationProperties() 115 { 116 return currentConfigurationProperties; 117 } 118 119 /** 120 * Returns the configuration that is a duplication of the current 121 * configuration and has been rejected from being registered with the given 122 * key. 123 * 124 * @return the configuration that is a duplication of the current 125 * configuration and has been rejected from being registered with the 126 * given key. 127 */ 128 public ConfigurationPropertiesManagement getDuplicateConfigurationProperties() 129 { 130 return duplicateConfigurationProperties; 131 } 132 133 // --- business ------------------------------------------------------------- 134 135 // --- object basics -------------------------------------------------------- 136 137 }