/** * This is used when there are only default constructors. It will check to see if any of the * annotated fields or methods is read only. If a read only method or field is found then this * will throw an exception to indicate that it is not valid. * * @param map this is the map of values that is to be validated */ private void validateConstructors(LabelMap map) throws Exception { for (Label label : map) { if (label != null) { Contact contact = label.getContact(); if (contact.isReadOnly()) { throw new ConstructorException( "Default constructor can not accept read only %s in %s", label, detail); } } } }
/** * This is used to ensure that final methods and fields have a constructor parameter that allows * the value to be injected in to. Validating the constructor in this manner ensures that the * class schema remains fully serializable and deserializable. * * @param label this is the variable to check in constructors * @param list this is the list of builders to validate */ private void validateConstructor(Label label, List<Creator> list) throws Exception { Iterator<Creator> iterator = list.iterator(); while (iterator.hasNext()) { Creator instantiator = iterator.next(); Signature signature = instantiator.getSignature(); Contact contact = label.getContact(); Object key = label.getKey(); if (contact.isReadOnly()) { Parameter value = signature.get(key); if (value == null) { iterator.remove(); } } } }