com.squareup.javapoet.ClassName.equals()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(9.7k)|赞(0)|评价(0)|浏览(113)

本文整理了Java中com.squareup.javapoet.ClassName.equals()方法的一些代码示例,展示了ClassName.equals()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ClassName.equals()方法的具体详情如下:
包路径:com.squareup.javapoet.ClassName
类名称:ClassName
方法名:equals

ClassName.equals介绍

暂无

代码示例

代码示例来源:origin: square/wire

@Override public boolean equals(Object o) {
 return o instanceof AdapterConstant
   && ((AdapterConstant) o).className.equals(className)
   && ((AdapterConstant) o).memberName.equals(memberName);
}

代码示例来源:origin: facebook/litho

private static boolean isOutputType(TypeName type) {
 return type.equals(OUTPUT) ||
   (type instanceof ParameterizedTypeName &&
    ((ParameterizedTypeName) type).rawType.equals(OUTPUT));
}

代码示例来源:origin: facebook/litho

private static boolean isStateValueType(TypeName type) {
 return type.equals(STATE_VALUE) ||
   (type instanceof ParameterizedTypeName &&
     ((ParameterizedTypeName) type).rawType.equals(STATE_VALUE));
}

代码示例来源:origin: facebook/litho

private static TypeName[] getBuilderGenericTypes(TypeName type, ClassName builderClass) {
 if (builderClass.equals(ClassNames.COMPONENT_BUILDER)
   || builderClass.equals(ClassNames.SECTION_BUILDER)) {
  return new TypeName[] {WildcardTypeName.subtypeOf(TypeName.OBJECT)};
 } else {
  final TypeName typeParameter =
    type instanceof ParameterizedTypeName
        && !((ParameterizedTypeName) type).typeArguments.isEmpty()
      ? ((ParameterizedTypeName) type).typeArguments.get(0)
      : WildcardTypeName.subtypeOf(ClassNames.COMPONENT);
  return new TypeName[]{typeParameter};
 }
}

代码示例来源:origin: ACRA/acra

@NonNull
private static Pair<List<AnnotationSpec>, Set<ClassName>> getAnnotations(@NonNull ExecutableElement method) {
  final List<AnnotationSpec> specs = method.getAnnotationMirrors().stream().map(AnnotationSpec::get).collect(Collectors.toList());
  final Set<ClassName> markerAnnotations = new HashSet<>();
  for (final Iterator<AnnotationSpec> iterator = specs.iterator(); iterator.hasNext(); ) {
    final AnnotationSpec spec = iterator.next();
    for (ClassName a : org.acra.processor.util.Types.MARKER_ANNOTATIONS) {
      if (a.equals(spec.type)) {
        iterator.remove();
        markerAnnotations.add(a);
      }
    }
  }
  return Pair.of(specs, markerAnnotations);
}

代码示例来源:origin: ACRA/acra

@NonNull
public static TypeName getImmutableType(TypeName type) {
  if (type instanceof ParameterizedTypeName) {
    final TypeName genericType = ((ParameterizedTypeName) type).rawType;
    if (MAP.equals(genericType)) {
      type = getWithParams(IMMUTABLE_MAP, (ParameterizedTypeName) type);
    } else if (SET.equals(genericType)) {
      return getWithParams(IMMUTABLE_SET, (ParameterizedTypeName) type);
    } else if (LIST.equals(genericType)) {
      type = getWithParams(IMMUTABLE_LIST, (ParameterizedTypeName) type);
    }
  } else if (type instanceof ArrayTypeName) {
    type = ParameterizedTypeName.get(IMMUTABLE_LIST, ((ArrayTypeName) type).componentType);
  }
  return type;
}

代码示例来源:origin: facebook/litho

private static TypeName[] getBuilderGenericTypes(
  final TypeName type, final ClassName builderClass) {
 final TypeName typeParameter =
   type instanceof ParameterizedTypeName
       && !((ParameterizedTypeName) type).typeArguments.isEmpty()
     ? ((ParameterizedTypeName) type).typeArguments.get(0)
     : WildcardTypeName.subtypeOf(ClassNames.COMPONENT_LIFECYCLE);
 if (builderClass.equals(ClassNames.COMPONENT_BUILDER)) {
  return new TypeName[] {WildcardTypeName.subtypeOf(TypeName.OBJECT)};
 } else {
  return new TypeName[] {typeParameter};
 }
}

代码示例来源:origin: ACRA/acra

private void handleBaseBuilder() {
  if (!MoreTypes.isTypeOf(Object.class, baseBuilder.asType())) {
    final List<ExecutableElement> constructors = ElementFilter.constructorsIn(baseBuilder.getEnclosedElements());
    Optional<ExecutableElement> constructor = constructors.stream().filter(c -> c.getParameters().size() == 0).findAny();
    if (constructor.isPresent()) {
      elements.add(modelFactory.fromDelegateConstructor(constructor.get(), false));
    } else {
      constructor = constructors.stream().filter(c -> c.getParameters().size() == 1 && Types.CONTEXT.equals(TypeName.get(c.getParameters().get(0).asType()))).findAny();
      if (constructor.isPresent()) {
        elements.add(modelFactory.fromDelegateConstructor(constructor.get(), true));
      } else {
        final AnnotationMirror mirror = baseAnnotation.getAnnotationMirrors().stream()
            .filter(m -> MoreTypes.isTypeOf(Configuration.class, m.getAnnotationType()))
            .findAny().orElseThrow(IllegalArgumentException::new);
        messager.printMessage(Diagnostic.Kind.ERROR, "Classes used as base builder must have a constructor which takes no arguments, " +
            "or exactly one argument of type Class", baseAnnotation, mirror, mirror.getElementValues().entrySet().stream()
            .filter(entry -> entry.getKey().getSimpleName().toString().equals("builderSuperClass")).findAny().map(Map.Entry::getValue).orElse(null));
        throw new IllegalArgumentException();
      }
    }
    handleBaseBuilderMethods();
  }
}

代码示例来源:origin: facebook/litho

ClassName.bestGuess(qualifiedName).equals(ClassNames.DIFF)
    || superinterfaces
      .stream()

代码示例来源:origin: airbnb/epoxy

if (annotationClass.equals(ClassName.get(EpoxyAttribute.class))) {

代码示例来源:origin: JakeWharton/butterknife

Id(int value, @Nullable Symbol rSymbol) {
 this.value = value;
 if (rSymbol != null) {
  ClassName className = ClassName.get(rSymbol.packge().getQualifiedName().toString(), R,
    rSymbol.enclClass().name.toString());
  String resourceName = rSymbol.name.toString();
  this.code = className.topLevelClassName().equals(ANDROID_R)
   ? CodeBlock.of("$L.$N", className, resourceName)
   : CodeBlock.of("$T.$N", className, resourceName);
  this.qualifed = true;
 } else {
  this.code = CodeBlock.of("$L", value);
  this.qualifed = false;
 }
}

代码示例来源:origin: facebook/litho

private static boolean hasMatchingInterStageOutput(
  SpecMethodModel<DelegateMethod, Void> method, MethodParamModel interStageInput) {
 for (MethodParamModel methodParam : method.methodParams) {
  if (methodParam.getName().equals(interStageInput.getName()) &&
    methodParam.getTypeName() instanceof ParameterizedTypeName &&
    ((ParameterizedTypeName) methodParam.getTypeName()).rawType.equals(ClassNames.OUTPUT) &&
    ((ParameterizedTypeName) methodParam.getTypeName()).typeArguments.size() == 1 &&
    ((ParameterizedTypeName) methodParam.getTypeName()).typeArguments.get(0).equals(
      interStageInput.getTypeName().box())) {
   return true;
  }
 }
 return false;
}

代码示例来源:origin: facebook/litho

public static boolean isPropOutput(SpecModel specModel, MethodParamModel methodParamModel) {
 final PropModel prop = getPropWithName(specModel, methodParamModel.getName());
 return prop != null &&
   methodParamModel.getTypeName() instanceof ParameterizedTypeName &&
   ((ParameterizedTypeName) methodParamModel.getTypeName()).rawType.equals(OUTPUT) &&
   ((ParameterizedTypeName) methodParamModel.getTypeName()).typeArguments.size() == 1 &&
   ((ParameterizedTypeName) methodParamModel.getTypeName()).typeArguments.get(0)
     .equals(prop.getTypeName().box());
}

代码示例来源:origin: facebook/litho

/**
 * Generate a dispatchOnEvent() implementation for the component.
 */
static MethodSpec generateDispatchOnEvent(SpecModel specModel) {
 final MethodSpec.Builder methodBuilder = MethodSpec.methodBuilder("dispatchOnEvent")
   .addModifiers(Modifier.PUBLIC)
   .addAnnotation(Override.class)
   .returns(TypeName.OBJECT)
   .addParameter(
     ParameterSpec.builder(EVENT_HANDLER, "eventHandler", Modifier.FINAL)
       .build())
   .addParameter(
     ParameterSpec.builder(OBJECT, "eventState", Modifier.FINAL).build());
 methodBuilder.addStatement("int id = eventHandler.id");
 methodBuilder.beginControlFlow("switch ($L)", "id");
 EventCaseGenerator.builder()
   .contextClass(specModel.getContextClass())
   .eventMethodModels(specModel.getEventMethods())
   // For now, Sections are not supported for error propagation
   .withErrorPropagation(specModel.getComponentClass().equals(ClassNames.COMPONENT))
   .writeTo(methodBuilder);
 return methodBuilder.addStatement("default:\nreturn null")
   .endControlFlow()
   .build();
}

代码示例来源:origin: facebook/litho

public static boolean isStateOutput(SpecModel specModel, MethodParamModel methodParamModel) {
 final StateParamModel stateValue =
   SpecModelUtils.getStateValueWithName(specModel, methodParamModel.getName());
 return stateValue != null &&
   methodParamModel.getTypeName() instanceof ParameterizedTypeName &&
   ((ParameterizedTypeName) methodParamModel.getTypeName()).rawType.equals(OUTPUT) &&
   ((ParameterizedTypeName) methodParamModel.getTypeName()).typeArguments.size() == 1 &&
   ((ParameterizedTypeName) methodParamModel.getTypeName()).typeArguments.get(0)
     .equals(stateValue.getTypeName().box());
}

代码示例来源:origin: facebook/litho

public static boolean isStateValue(SpecModel specModel, MethodParamModel methodParamModel) {
 final StateParamModel stateValue =
   SpecModelUtils.getStateValueWithName(specModel, methodParamModel.getName());
 return stateValue != null &&
   methodParamModel.getTypeName() instanceof ParameterizedTypeName &&
   ((ParameterizedTypeName) methodParamModel.getTypeName()).rawType
     .equals(ClassNames.STATE_VALUE) &&
   ((ParameterizedTypeName) methodParamModel.getTypeName()).typeArguments.size() == 1 &&
   ((ParameterizedTypeName) methodParamModel.getTypeName()).typeArguments.get(0)
     .equals(stateValue.getTypeName().box());
}

代码示例来源:origin: facebook/litho

!(((ParameterizedTypeName) methodParam.getTypeName()).rawType.equals(STATE_VALUE))) {
validationErrors.add(
  new SpecModelValidationError(

代码示例来源:origin: facebook/litho

case INTER_STAGE_OUTPUT:
 return methodParamModel.getTypeName() instanceof ParameterizedTypeName &&
   ((ParameterizedTypeName) methodParamModel.getTypeName()).rawType.equals(ClassNames.OUTPUT);
case PROP_OUTPUT:
 return SpecModelUtils.isPropOutput(specModel, methodParamModel);

代码示例来源:origin: facebook/litho

if (typeName instanceof ParameterizedTypeName) {
 ParameterizedTypeName parameterizedTypeName = (ParameterizedTypeName) typeName;
 if (!parameterizedTypeName.rawType.equals(ClassNames.LIST)) {
  validationErrors.add(
    new SpecModelValidationError(

代码示例来源:origin: facebook/litho

&& ((ParameterizedTypeName) field.getTypeName()).rawType.equals(ClassNames.EVENT_HANDLER)) {
return Comparable.EVENT_HANDLER_IN_PARAMETERIZED_TYPE;

相关文章