| 1 4 package com.nightlabs.ipanema.accounting; 5 6 import java.io.Serializable ; 7 8 import com.nightlabs.inheritance.NotWritableException; 9 10 20 public class ProductInfoFieldMetaData 21 implements com.nightlabs.inheritance.FieldMetaData, Serializable  22 { 23 27 private String organisationID; 28 29 33 private String productID; 34 35 39 private String fieldName; 40 41 private ProductInfo productInfo; 42 43 46 private byte writableByChildren = ProductInfoFieldMetaData.WRITABLEBYCHILDREN_YES; 47 48 52 private boolean writable = true; 53 54 58 private boolean valueInherited = true; 59 60 protected ProductInfoFieldMetaData() { } 61 public ProductInfoFieldMetaData(ProductInfo productInfo, String fieldName) 62 { 63 setProductInfo(productInfo); 64 setFieldName(fieldName); 65 } 66 67 70 public String getOrganisationID() 71 { 72 return organisationID; 73 } 74 75 78 public String getProductID() 79 { 80 return productID; 81 } 82 83 86 public String getFieldName() 87 { 88 return fieldName; 89 } 90 93 protected void setFieldName(String fieldName) 94 { 95 this.fieldName = fieldName; 96 } 97 98 101 public ProductInfo getProductInfo() 102 { 103 return productInfo; 104 } 105 108 protected void setProductInfo(ProductInfo productInfo) 109 { 110 if (productInfo == null) 111 throw new NullPointerException ("productInfo must not be null!"); 112 if (productInfo.getOrganisationID() == null) 113 throw new NullPointerException ("productInfo.organisationID must not be null!"); 114 if (productInfo.getProductID() == null) 115 throw new NullPointerException ("productInfo.productID must not be null!"); 116 this.organisationID = productInfo.getOrganisationID(); 117 this.productID = productInfo.getProductID(); 118 this.productInfo = productInfo; 119 } 120 121 124 public byte getWritableByChildren() 125 { 126 return writableByChildren; 127 } 128 131 public void setWritableByChildren(byte writableByChildren) 132 { 133 this.writableByChildren = writableByChildren; 134 } 135 136 139 public boolean isWritable() 140 { 141 return writable; 142 } 143 146 public void setWritable(boolean writable) 147 { 148 this.writable = writable; 149 } 150 153 public void assertWritable() throws NotWritableException 154 { 155 if (!isWritable()) 156 throw new NotWritableException("Field \""+getFieldName()+"\" is not writeable!"); 157 } 158 159 162 public boolean isValueInherited() 163 { 164 return valueInherited; 165 } 166 169 public void setValueInherited(boolean valueInherited) 170 { 171 if (!writable && !valueInherited) 172 throw new IllegalStateException ("The field is not writable, thus the value must be inherited. Cannot set valueInherited to false!"); 173 174 this.valueInherited = valueInherited; 175 } 176 177 } 178 | Popular Tags |