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.codes.ConfigurationsCode; 20 import de.smartics.properties.api.config.domain.key.ConfigurationKey; 21 import de.smartics.properties.api.core.app.AbstractBaseMessageBean; 22 23 /** 24 * Provides context information for problems dealing with property stores. 25 */ 26 public class PropertyStoreMessageBean extends AbstractBaseMessageBean // NOPMD 27 { 28 // ********************************* Fields ********************************* 29 30 // --- constants ------------------------------------------------------------ 31 32 /** 33 * The class version identifier. 34 * <p> 35 * The value of this constant is {@value}. 36 * </p> 37 */ 38 private static final long serialVersionUID = 1L; 39 40 // --- members -------------------------------------------------------------- 41 42 /** 43 * The key to the configuration where problems arise accessing the property 44 * store. 45 * 46 * @serial 47 */ 48 @MessageParam 49 private final ConfigurationKey<?> configurationKey; // NOPMD 50 51 /** 52 * The name of the property that cannot be accessed in the store. 53 * 54 * @serial 55 */ 56 @MessageParam 57 private final String propertyName; // NOPMD 58 59 // ****************************** Initializer ******************************* 60 61 // ****************************** Constructors ****************************** 62 63 /** 64 * Constructor without cause. 65 * 66 * @param code the error or exception code of the exception. 67 * @param configurationKey the key to the configuration where problems arise 68 * accessing the property store. 69 * @param propertyName the name of the property that cannot be accessed in the 70 * store. 71 */ 72 public PropertyStoreMessageBean(final ConfigurationsCode code, 73 final ConfigurationKey<?> configurationKey, final String propertyName) 74 { 75 this(code, null, configurationKey, propertyName); 76 } 77 78 /** 79 * Default constructor. 80 * 81 * @param code the error or exception code of the exception. 82 * @param cause the cause to the problem. 83 * @param configurationKey the key to the configuration where problems arise 84 * accessing the property store. 85 * @param propertyName the name of the property that cannot be accessed in the 86 * store. 87 */ 88 public PropertyStoreMessageBean(final ConfigurationsCode code, 89 final Throwable cause, final ConfigurationKey<?> configurationKey, 90 final String propertyName) 91 { 92 super(code, cause); 93 this.configurationKey = configurationKey; 94 this.propertyName = propertyName; 95 } 96 97 // ****************************** Inner Classes ***************************** 98 99 // ********************************* Methods ******************************** 100 101 // --- init ----------------------------------------------------------------- 102 103 // --- factory -------------------------------------------------------------- 104 105 /** 106 * Creates a message bean for 107 * {@link PropertyStoreCode#CANNOT_GET_PROPERTY_COLLECTION}. 108 * 109 * @param cause the cause to the problem. 110 * @param configurationKey the key to the configuration where problems arise 111 * accessing the property store. 112 * @return the requested message instance. 113 */ 114 public static PropertyStoreMessageBean collection(final Throwable cause, 115 final ConfigurationKey<?> configurationKey) 116 { 117 return new PropertyStoreMessageBean( 118 PropertyStoreCode.CANNOT_GET_PROPERTY_COLLECTION, cause, 119 configurationKey, null); 120 } 121 122 // --- get&set -------------------------------------------------------------- 123 124 // --- business ------------------------------------------------------------- 125 126 // --- object basics -------------------------------------------------------- 127 128 }