示例#1
0
  private WildcardTypeName(List<TypeName> upperBounds, List<TypeName> lowerBounds) {
    this.upperBounds = Util.immutableList(upperBounds);
    this.lowerBounds = Util.immutableList(lowerBounds);

    checkArgument(this.upperBounds.size() == 1, "unexpected extends bounds: %s", upperBounds);
    for (TypeName upperBound : this.upperBounds) {
      checkArgument(
          !upperBound.isPrimitive() && upperBound != VOID, "invalid upper bound: %s", upperBound);
    }
    for (TypeName lowerBound : this.lowerBounds) {
      checkArgument(
          !lowerBound.isPrimitive() && lowerBound != VOID, "invalid lower bound: %s", lowerBound);
    }
  }
示例#2
0
 private FieldSpec(Builder builder) {
   this.type = checkNotNull(builder.type, "type == null");
   this.name = checkNotNull(builder.name, "name == null");
   this.javadoc = builder.javadoc.build();
   this.annotations = Util.immutableList(builder.annotations);
   this.modifiers = Util.immutableSet(builder.modifiers);
   this.initializer =
       (builder.initializer == null) ? CodeBlock.builder().build() : builder.initializer;
 }
  ParameterizedTypeName(
      ClassName rawType, List<TypeName> typeArguments, List<AnnotationSpec> annotations) {
    super(annotations);
    this.rawType = checkNotNull(rawType, "rawType == null");
    this.typeArguments = Util.immutableList(typeArguments);

    checkArgument(!this.typeArguments.isEmpty(), "no type arguments: %s", rawType);
    for (TypeName typeArgument : this.typeArguments) {
      checkArgument(
          !typeArgument.isPrimitive() && typeArgument != VOID,
          "invalid type parameter: %s",
          typeArgument);
    }
  }
示例#4
0
 private CodeBlock(Builder builder) {
   this.formatParts = Util.immutableList(builder.formatParts);
   this.args = Util.immutableList(builder.args);
 }