コード例 #1
0
 private void checkStyleConflicts(ValueType type, Protoclass protoclass) {
   if (protoclass.features().prehash() && protoclass.styles().style().privateNoargConstructor()) {
     protoclass
         .report()
         .annotationNamed(ImmutableMirror.simpleName())
         .warning(
             "'prehash' feature is automatically disabled when 'privateNoargConstructor' style is turned on");
   }
   if (type.isUseConstructor() && protoclass.constitution().factoryOf().isNew()) {
     if (type.isUseValidation()) {
       protoclass
           .report()
           .annotationNamed(ImmutableMirror.simpleName())
           .error(
               "interning, singleton and validation will not work correctly with 'new' constructor configured in style");
     } else if (type.constitution.isImplementationHidden()
         && (type.kind().isEnclosing() || type.kind().isNested())) {
       protoclass
           .report()
           .annotationNamed(ImmutableMirror.simpleName())
           .error(
               "Enclosing with hidden implementation do not mix with 'new' constructor configured in style");
     }
   }
 }
コード例 #2
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());
       }
     }
   }
 }