com.android.annotations.NonNull类的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(154)

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

NonNull介绍

暂无

代码示例

代码示例来源:origin: simpligility/android-maven-plugin

public static Collection< Artifact > filterArtifacts( @NonNull Iterable< Artifact > artifacts,
    final boolean skipDependencies, @Nullable final Collection< String > includeArtifactTypes,
    @Nullable final Collection< String > excludeArtifactTypes,
    @Nullable final Collection< String > includeArtifactQualifiers,
    @Nullable final Collection< String > excludeArtifactQualifiers )

代码示例来源:origin: yigit/android-priority-jobqueue

@Override
  public AstVisitor createJavaVisitor(@NonNull final JavaContext context) {
    return new ForwardingAstVisitor() {
      @Override
      public boolean visitMethodInvocation(MethodInvocation node) {
        Expression operand = node.astOperand();
        if (node.astName().toString().equals("sleep") && operand.toString().equals("Thread") && !context.isSuppressedWithComment(node, ISSUE)) {
          context.report(ISSUE, node, context.getLocation(node), "Don't call sleep. Use MockTimer instead.");
        }
        return super.visitMethodInvocation(node);
      }
    };
  }
}

代码示例来源:origin: yigit/android-priority-jobqueue

@Override
  public AstVisitor createJavaVisitor(@NonNull final JavaContext context) {
    return new ForwardingAstVisitor() {
      @Override
      public boolean visitMethodInvocation(MethodInvocation node) {
        Expression operand = node.astOperand();
        if (node.astName().toString().equals("wait")
            && !context.isSuppressedWithComment(node, ISSUE)) {
          context.report(ISSUE, context.getLocation(node), "Don't wait on object. Use Timer's wait instead.");
        }
        return super.visitMethodInvocation(node);
      }
    };
  }
}

代码示例来源:origin: com.android.tools.lint/lint-api

public ReportedEntry(@NonNull Issue issue, @Nullable Project project,
    @NonNull Location location, @NonNull String message) {
  this.issue = issue;
  this.location = location;
  this.project = project;
  this.message = message;
}

代码示例来源:origin: yigit/android-priority-jobqueue

@Override
  public AstVisitor createJavaVisitor(@NonNull final JavaContext context) {
    return new ForwardingAstVisitor() {

      @Override
      public boolean visitMethodInvocation(MethodInvocation node) {
        Expression operand = node.astOperand();
        String methodName = node.astName().toString();
        if (BAD_METHODS.contains(methodName) && !context.isSuppressedWithComment(node, ISSUE)) {
          context.report(ISSUE, context.getLocation(node), "Don't call " + methodName + " directly. Use" +
              " Timer instead.");
        }
        return super.visitMethodInvocation(node);
      }
    };
  }
}

代码示例来源:origin: com.android.tools.lint/lint-api

public Entry(
      @NonNull String issueId,
      @NonNull String message,
      @NonNull String path,
      @Nullable String line) {
    this.issueId = issueId;
    this.message = message;
    this.path = path;
    this.line = line;
  }
}

代码示例来源:origin: yigit/android-priority-jobqueue

@Override
  public AstVisitor createJavaVisitor(@NonNull final JavaContext context) {
    return new ForwardingAstVisitor() {

      @Override
      public boolean visitMethodInvocation(MethodInvocation node) {
        Expression operand = node.astOperand();
        String methodName = node.astName().toString();
        if (BAD_METHODS.contains(methodName) && operand.toString().equals("System") && !context.isSuppressedWithComment(node, ISSUE)) {
          context.report(ISSUE, context.getLocation(node), "Don't call " + methodName + " on system. Use" +
              " Timer instead.");
        }
        return super.visitMethodInvocation(node);
      }
    };
  }
}

代码示例来源:origin: com.android.tools.lint/lint

public ExternalPsiNameValuePair(
    @Nullable String name,
    @NonNull String literal,
    @NonNull PsiAnnotationMemberValue value) {
  //noinspection ConstantConditions
  super(null);
  mName = name;
  mLiteral = literal;
  mMemberValue = value;
}

代码示例来源:origin: simpligility/android-maven-plugin

public MavenErrorReporter( ILogger logger, @NonNull EvaluationMode mode )
{
 super( mode );
 this.logger = logger;
}

代码示例来源:origin: com.android.tools.lint/lint

protected EcjPsiMember(@NonNull EcjPsiManager manager, @NonNull EcjPsiClass containingClass,
    @Nullable ASTNode ecjNode) {
  super(manager, ecjNode);
  mContainingClass = containingClass;
}

代码示例来源:origin: uber/okbuck

private static File checkPath(@NonNull String path) throws FileNotFoundException {
 File file = new File(path);
 if (!file.exists()) {
  System.err.println(path + " does not exist");
  throw new FileNotFoundException(path);
 }
 return file;
}

代码示例来源:origin: com.android.tools.build/builder

/**
   * Installs an Android Sdk Tool if it's not already installed.
   *
   * @param sdkLibData contains all the components for downloading.
   * @param packageId the package/id path of the required Tool component.
   * @return a {@code File} representing the locations to the directory where the Tool component
   *         is installed or null if we haven't managed to find such a component.
   **/
  @Nullable
  File installSdkTool(@NonNull SdkLibData sdkLibData, @NonNull String packageId);
}

代码示例来源:origin: simpligility/android-maven-plugin

@Override
public void warning( @NonNull String s, Object... objects )
{
  final Formatter formatter = new Formatter();
  log.warn( formatter.format( s, objects ).out().toString() );
}

代码示例来源:origin: com.android.tools.lint/lint-tests

protected TestConfiguration(
    @NonNull LintClient client,
    @NonNull Project project,
    @Nullable Configuration parent) {
  super(client, project, parent);
}

代码示例来源:origin: simpligility/android-maven-plugin

@Override
  public void verbose( @NonNull String s, Object... objects )
  {
    final Formatter formatter = new Formatter();
    log.debug( formatter.format( s, objects ).out().toString() );
  }
}

代码示例来源:origin: com.android.tools.build/gradle-api

/**
 * @deprecated replaced by {@link #transform(TransformInvocation)}.
 */
@Deprecated
@SuppressWarnings("UnusedParameters")
public void transform(
    @NonNull Context context,
    @NonNull Collection<TransformInput> inputs,
    @NonNull Collection<TransformInput> referencedInputs,
    @Nullable TransformOutputProvider outputProvider,
    boolean isIncremental) throws IOException, TransformException, InterruptedException {
}

代码示例来源:origin: uber/okbuck

private static ILogger createLogger(@NonNull StdLogger.Level level) {
  return new StdLogger(level);
 }
}

代码示例来源:origin: com.android.tools.build/gradle-core

ProductFlavorData(
    @NonNull T productFlavor,
    @NonNull DefaultAndroidSourceSet sourceSet,
    @Nullable DefaultAndroidSourceSet androidTestSourceSet,
    @Nullable DefaultAndroidSourceSet unitTestSourceSet,
    @NonNull Project project) {
  super(sourceSet, androidTestSourceSet, unitTestSourceSet, project);
  this.productFlavor = productFlavor;
}

代码示例来源:origin: Tencent/QMUI_Android

@Override
  public void visitAttribute(@NonNull XmlContext context, @NonNull Attr attribute) {
    // 判断资源文件夹是否存在
    Project project = context.getProject();
    List<File> resourceFolder = project.getResourceFolders();
    if (resourceFolder.isEmpty()) {
      return;
    }

    // 获取项目资源文件夹路径
    String resourcePath = resourceFolder.get(0).getAbsolutePath();
    // 获取 drawable 名字
    String drawableName = attribute.getValue().replace("@drawable/", "");
    try {
      // 若 drawable 为 Vector Drawable,则文件后缀为 xml,根据 resource 路径,drawable 名字,文件后缀拼接出完整路径
      FileInputStream fileInputStream = new FileInputStream(resourcePath + "/drawable/" + drawableName + ".xml");
      BufferedReader reader = new BufferedReader(new InputStreamReader(fileInputStream));
      String line = reader.readLine();
      if (line.contains("vector")) {
        // 若文件存在,并且包含首行包含 vector,则为 Vector Drawable,抛出警告
        context.report(ISSUE_XML_VECTOR_DRAWABLE, attribute, context.getLocation(attribute), attribute.getValue() + " 为 Vector Drawable,请使用 Vector 属性进行设置,避免 4.0 及以下版本的系统产生 Crash");
      }
      fileInputStream.close();
    } catch (Exception ignored) {
    }
  }
}

代码示例来源:origin: com.android.tools.build/gradle-core

FlatDependencyContainer(
    @NonNull DependencyGraph dependencyGraph,
    @NonNull List<Dependency> allDependencies,
    @NonNull List<Dependency> directDependencies,
    @Nullable AtomDependency baseAtom,
    @NonNull MutableDependencyDataMap mutableDependencyDataMap) {
  this.dependencyGraph = dependencyGraph;
  this.allDependencies = ImmutableList.copyOf(allDependencies);
  this.directDependencies = ImmutableList.copyOf(directDependencies);
  this.baseAtom = baseAtom;
  this.mutableDependencyDataMap = mutableDependencyDataMap;
}

相关文章

NonNull类方法