2026-08-13

package org.inferred.freebuilder.processor.property;

import com.google.common.annotations.VisibleForTesting;

import com.google.common.base.Preconditions;

import com.google.common.collect.ImmutableList;

import java.util.ArrayList;

import java.util.Arrays;

import java.util.Collection;

import java.util.Collections;

import java.util.EnumSet;

import java.util.List;

import java.util.Objects;

import java.util.Optional;

import java.util.Spliterator;

import java.util.function.Consumer;

import java.util.function.UnaryOperator;

import java.util.stream.BaseStream;

import javax.annotation.Generated;

import javax.lang.model.type.TypeMirror;

import org.inferred.freebuilder.processor.source.Excerpt;

  public static org.inferred.freebuilder.processor.property.Property.Builder from(

      org.inferred.freebuilder.processor.property.Property value) {

    if (value instanceof Rebuildable) {

      return ((Rebuildable) value).toBuilder();

    } else {

      return new org.inferred.freebuilder.processor.property.Property.Builder().mergeFrom(value);

    }

  }

  private enum Property {

    TYPE("type"),

    NAME("name"),

    CAPITALIZED_NAME("capitalizedName"),

    ALL_CAPS_NAME("allCapsName"),

    USING_BEAN_CONVENTION("usingBeanConvention"),

    GETTER_NAME("getterName"),

    FULLY_CHECKED_CAST("fullyCheckedCast"),

    ;

    private final String name;

    private Property(String name) {

      this.name = name;

    }

    @Override

    public String toString() {

      return name;

    }

  }

  private TypeMirror type;

  // Store a nullable object instead of an Optional. Escape analysis then

  // allows the JVM to optimize away the Optional objects created by and

  // passed to our API.

  private TypeMirror boxedType = null;

  private String name;

  private String capitalizedName;

  private String allCapsName;

  private boolean usingBeanConvention;

  private boolean inToString;

  private boolean inEqualsAndHashCode;

  private String getterName;

  private boolean fullyCheckedCast;

  private List<Excerpt> accessorAnnotations = ImmutableList.of();

  private List<Excerpt> getterAnnotations = ImmutableList.of();

  private List<Excerpt> putAnnotations = ImmutableList.of();

  private final EnumSet<Property> _unsetProperties = EnumSet.allOf(Property.class);

  public org.inferred.freebuilder.processor.property.Property.Builder setType(TypeMirror type) {

    this.type = Objects.requireNonNull(type);

    _unsetProperties.remove(Property.TYPE);

    return (org.inferred.freebuilder.processor.property.Property.Builder) this;

  }

  public org.inferred.freebuilder.processor.property.Property.Builder mapType(

      UnaryOperator<TypeMirror> mapper) {

    Objects.requireNonNull(mapper);

    return setType(mapper.apply(getType()));

  }

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容