Example #1
0
  /**
   * 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();
        }
      }
    }
  }