private static ComponentBuilder<?> builderFromGenerator(
     Generator<?> source, ComponentDescriptor descriptor, BeneratorContext context) {
   boolean nullability = DescriptorUtil.isNullable(descriptor, context);
   Double nullQuota = descriptor.getNullQuota();
   if (nullQuota != null && nullQuota != 0)
     source = context.getGeneratorFactory().applyNullSettings(source, nullability, nullQuota);
   TypeDescriptor typeDescriptor = descriptor.getTypeDescriptor();
   String scope = (typeDescriptor != null ? typeDescriptor.getScope() : null);
   if (descriptor instanceof ArrayElementDescriptor) {
     int index = ((ArrayElementDescriptor) descriptor).getIndex();
     return new ArrayElementBuilder(index, source, scope);
   } else return new PlainEntityComponentBuilder(descriptor.getName(), source, scope);
 }
  public static ComponentBuilder<?> createComponentBuilder(
      ComponentDescriptor descriptor, Uniqueness ownerUniqueness, BeneratorContext context) {
    LOGGER.debug("createComponentBuilder({})", descriptor.getName());

    ComponentBuilder<?> result = null;
    if (descriptor instanceof ArrayElementDescriptor)
      result = createPartBuilder(descriptor, ownerUniqueness, context);
    else if (descriptor instanceof PartDescriptor) {
      TypeDescriptor type = descriptor.getTypeDescriptor();
      if (type instanceof AlternativeGroupDescriptor)
        result =
            createAlternativeGroupBuilder(
                (AlternativeGroupDescriptor) type, ownerUniqueness, context);
      else result = createPartBuilder(descriptor, ownerUniqueness, context);
    } else if (descriptor instanceof ReferenceDescriptor)
      result = createReferenceBuilder((ReferenceDescriptor) descriptor, context);
    else if (descriptor instanceof IdDescriptor)
      result = createIdBuilder((IdDescriptor) descriptor, ownerUniqueness, context);
    else throw new ConfigurationError("Not a supported element: " + descriptor.getClass());
    result = wrapWithCondition(descriptor, result);
    return result;
  }