예제 #1
0
  ValueType compose(Protoclass protoclass) {
    ValueType type = new ValueType();
    type.round = round;
    type.typeMoreObjects = typeMoreObjects;
    type.element = protoclass.sourceElement();
    type.immutableFeatures = protoclass.features();
    type.constitution = protoclass.constitution();

    if (protoclass.kind().isFactory()) {
      new FactoryMethodAttributesCollector(protoclass, type).collect();
    } else if (protoclass.kind().isValue() || protoclass.kind().isModifiable()) {
      Collection<String> violations = Lists.newArrayList();
      // This check is legacy, most such checks should have been done on a higher level?
      if (checkAbstractValueType(type.element, violations)) {

        if (protoclass.kind().isValue()) {
          // essentially skip checks if only kind().isModifiable() and not kind().isValue()
          checkForMutableFields(protoclass, (TypeElement) type.element);
          checkForTypeHierarchy(protoclass, type);
        }

        new AccessorAttributesCollector(protoclass, type).collect();
      } else {
        protoclass
            .report()
            .error(
                "Value type '%s' %s",
                protoclass.sourceElement().getSimpleName(), Joiner.on(", ").join(violations));
        // Do nothing now. kind of way to less blow things up when it happens.
      }

      type.detectSerialization();
    }

    checkAttributeNamesIllegalCharacters(type);
    checkAttributeNamesForDuplicates(type, protoclass);
    checkConstructability(type);
    checkStyleConflicts(type, protoclass);
    return type;
  }