예제 #1
0
 private void checkConstructability(ValueType type) {
   if (!type.isUseBuilder() || type.isUseConstructor()) {
     for (ValueAttribute a : type.getConstructorExcluded()) {
       if (a.isMandatory()) {
         a.report()
             .error(
                 "Attribute '%s' is mandatory and should be a constructor"
                     + " @Value.Parameter when builder is disabled or"
                     + " there are other constructor parameters",
                 a.name());
       }
     }
   }
   if (!type.isUseBuilder() && !type.isUseCopyMethods()) {
     for (ValueAttribute a : type.getConstructorExcluded()) {
       if (!a.isMandatory()) {
         a.report()
             .warning(
                 "There is no way to initialize '%s' attribute to non-default value."
                     + " Enable builder=true or copy=true or add it as a constructor @Value.Parameter",
                 a.name());
       }
     }
   }
   if (type.isUseSingleton() && !type.getMandatoryAttributes().isEmpty()) {
     for (ValueAttribute a : type.getMandatoryAttributes()) {
       if (a.isMandatory()) {
         a.report()
             .error(
                 "Attribute '%s' is mandatory and cannot be used with singleton enabled."
                     + " Singleton instance require all attributes to have default value, otherwise"
                     + " default instance could not be created",
                 a.name());
       }
     }
   }
 }