本文整理了Java中org.jetbrains.annotations.Contract
类的一些代码示例,展示了Contract
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Contract
类的具体详情如下:
包路径:org.jetbrains.annotations.Contract
类名称:Contract
暂无
代码示例来源:origin: KronicDeth/intellij-elixir
/**
* Returns the array of definitions for brace pairs that need to be matched when
* editing code in the language.
*
* @return the array of brace pair definitions.
*/
@Contract(pure = true)
@Override
public BracePair[] getPairs() {
return BRACE_PAIRS;
}
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
@Contract("null -> false")
private static boolean isFieldDefinition(@Nullable PsiElement element) {
return element instanceof GoFieldDefinition || element instanceof GoAnonymousFieldDefinition;
}
代码示例来源:origin: iSoron/uhabits
@Contract("null -> fail")
private void check(Long value)
{
if (value == null) throw new RuntimeException("null check failed");
}
}
代码示例来源:origin: apache/ignite
/**
* @return Transaction counters.
* @param createIfAbsent {@code True} if non-null instance is needed.
*/
@Nullable @Contract("true -> !null;") public TxCounters txCounters(boolean createIfAbsent);
}
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
@Contract("_,null->!null")
private static String realValue(@NotNull String value, @Nullable String defaultValue) {
return GoBuildTargetSettings.DEFAULT.equals(value) ? defaultValue : value;
}
}
代码示例来源:origin: KronicDeth/intellij-elixir
/**
* @return Always {@code null} because a no argument call by definition has no arguments, not even an empty list
* of arguments.
*/
@Contract(pure = true, value = "-> null")
@Override
@Nullable
PsiElement[] primaryArguments();
代码示例来源:origin: KronicDeth/intellij-elixir
/**
* @return Always {@code null} because a no argument call doesn't ever have {@link #primaryArguments}, so it can't
* have secondary arguments.
*/
@Contract(pure = true, value = "-> null")
@Override
@Nullable
PsiElement[] secondaryArguments();
}
代码示例来源:origin: KronicDeth/intellij-elixir
@Contract(pure = true)
@NotNull
public static TokenSet operatorTokenSet(@SuppressWarnings("unused") final ElixirDotInfixOperator dotInfixOperator) {
return DOT_OPERATOR_TOKEN_SET;
}
代码示例来源:origin: KronicDeth/intellij-elixir
@Contract(pure = true)
@NotNull
public static TokenSet operatorTokenSet(@SuppressWarnings("unused") final ElixirMultiplicationInfixOperator multiplicationInfixOperator) {
return MULTIPLICATIVE_OPERATOR_TOKEN_SET;
}
代码示例来源:origin: KronicDeth/intellij-elixir
@Contract(pure = true)
@NotNull
public static TokenSet operatorTokenSet(@SuppressWarnings("unused") final ElixirUnaryPrefixOperator unaryPrefixOperator) {
return UNARY_OPERATOR_TOKEN_SET;
}
代码示例来源:origin: KronicDeth/intellij-elixir
@Contract(pure = true)
@NotNull
XSourcePosition getSourcePosition() {
return mySourcePosition;
}
代码示例来源:origin: KronicDeth/intellij-elixir
/**
* Unlike with a base {@link Call}, {@link Parentheses#primaryArguments} are {@code @NotNull} because the first set
* of parentheses has to be there or it wouldn't be a {@link Parentheses}
*/
@Contract(pure = true)
@Override
@NotNull
PsiElement[] primaryArguments();
}
代码示例来源:origin: KronicDeth/intellij-elixir
@Contract(pure = true)
@NotNull
private static <T> T notNullize(@Nullable T nullable, @NotNull T defaultValue) {
T notNull;
if (nullable == null) {
notNull = defaultValue;
} else {
notNull = nullable;
}
return notNull;
}
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
/**
* Use this method in order to check whether the method is appropriate for providing Go-specific code insight
*/
@Contract("null -> false")
public boolean isGoModule(@Nullable Module module) {
return module != null && !module.isDisposed();
}
代码示例来源:origin: ballerina-platform/ballerina-lang
@Contract(pure = true)
public static boolean processDeclarationsDefault(@NotNull BallerinaCompositeElement o,
@NotNull PsiScopeProcessor processor,
@NotNull ResolveState state,
@Nullable PsiElement lastParent,
@NotNull PsiElement place) {
return false;
}
代码示例来源:origin: KronicDeth/intellij-elixir
@Contract(pure = true)
@Nullable
private static <T> T forLanguage(@Nullable IElementType tokenType, @NotNull T forEEx, @Nullable T forElixir) {
T forLanguage;
if (tokenType == ELIXIR) {
forLanguage = forElixir;
} else {
forLanguage = forEEx;
}
return forLanguage;
}
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
@Contract("null -> false")
public static boolean isPackageContext(@Nullable PsiElement contextElement) {
return PsiTreeUtil.getNonStrictParentOfType(contextElement, GoPackageClause.class) != null;
}
代码示例来源:origin: ballerina-platform/ballerina-lang
@Contract("null -> false")
private static boolean isBallerinaTestFile(@Nullable PsiFile psiFile) {
if (psiFile == null) {
return false;
}
return psiFile.getName().endsWith(BallerinaConstants.BALLERINA_TEST_FILE_SUFFIX);
}
代码示例来源:origin: ballerina-platform/ballerina-lang
/**
* Use this method in order to check whether the method is appropriate for providing Ballerina-specific code
* insight.
*/
@Contract("null -> false")
public boolean isBallerinaModule(@Nullable Module module) {
return module != null && !module.isDisposed();
}
代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin
@Contract("null -> false")
public static boolean isBuiltinPackage(@Nullable PsiFileSystemItem directory) {
return directory instanceof PsiDirectory
&& GoConstants.BUILTIN_PACKAGE_NAME.equals(directory.getName())
&& GoConstants.BUILTIN_PACKAGE_NAME.equals(GoSdkUtil.getImportPath((PsiDirectory)directory, false));
}
内容来源于网络,如有侵权,请联系作者删除!