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()));
}