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.core.domain; 17 18 import java.io.Serializable; 19 20 21 /** 22 * The comment to a property. 23 */ 24 public final class PropertyComment implements Serializable 25 { 26 // ********************************* Fields ********************************* 27 28 // --- constants ------------------------------------------------------------ 29 30 /** 31 * The class version identifier. 32 */ 33 private static final long serialVersionUID = 1L; 34 35 /** 36 * The empty comment instance. Can be used if no comment for a property is 37 * accessible. 38 */ 39 public static final PropertyComment EMPTY_COMMENT = new PropertyComment( 40 new Builder()); 41 42 // --- members -------------------------------------------------------------- 43 44 /** 45 * The text of the comment. 46 * 47 * @serial 48 */ 49 private final String text; 50 51 /** 52 * The comment of the property values. 53 * 54 * @serial 55 */ 56 private final PropertyValueComment valueComment; 57 58 // ****************************** Initializer ******************************* 59 60 // ****************************** Constructors ****************************** 61 62 private PropertyComment(final Builder builder) 63 { 64 this.text = builder.text; 65 this.valueComment = builder.valueComment; 66 } 67 68 // ****************************** Inner Classes ***************************** 69 70 /** 71 * The property comment instance builder. 72 */ 73 public static final class Builder 74 { 75 // ******************************** Fields ******************************** 76 77 // --- constants ---------------------------------------------------------- 78 79 // --- members ------------------------------------------------------------ 80 81 /** 82 * The text of the comment. 83 */ 84 private String text; 85 86 /** 87 * The comment of the property values. 88 */ 89 private PropertyValueComment valueComment; 90 91 // ***************************** Initializer ****************************** 92 93 // ***************************** Constructors ***************************** 94 95 // ***************************** Inner Classes **************************** 96 97 // ******************************** Methods ******************************* 98 99 // --- init --------------------------------------------------------------- 100 101 // --- get&set ------------------------------------------------------------ 102 103 /** 104 * Sets the text of the comment. 105 * 106 * @param text the text of the comment. 107 * @return the reference to the builder instance. 108 */ 109 public Builder withText(final String text) 110 { 111 this.text = text; 112 return this; 113 } 114 115 /** 116 * Sets the comment of the property values. 117 * 118 * @param valueComment the comment of the property values. 119 * @return the reference to the builder instance. 120 */ 121 public Builder withValueComment(final PropertyValueComment valueComment) 122 { 123 this.valueComment = valueComment; 124 return this; 125 } 126 127 // --- business ----------------------------------------------------------- 128 129 /** 130 * Creates the property comment instance. 131 * 132 * @return the property comment instance. 133 */ 134 public PropertyComment build() 135 { 136 return new PropertyComment(this); 137 } 138 139 // --- object basics ------------------------------------------------------ 140 } 141 142 // ********************************* Methods ******************************** 143 144 // --- init ----------------------------------------------------------------- 145 146 // --- get&set -------------------------------------------------------------- 147 148 /** 149 * Returns the text of the comment. 150 * 151 * @return the text of the comment. 152 */ 153 public String getText() 154 { 155 return text; 156 } 157 158 /** 159 * Returns the comment of the property values. 160 * 161 * @return the comment of the property values. 162 */ 163 public PropertyValueComment getValueComment() 164 { 165 return valueComment; 166 } 167 168 // --- business ------------------------------------------------------------- 169 170 // --- object basics -------------------------------------------------------- 171 172 /** 173 * Returns the comment text. 174 * 175 * @return the comment text. 176 */ 177 @Override 178 public String toString() 179 { 180 return text; 181 } 182 }