本文整理汇总了Java中javax.annotation.Nullable类的典型用法代码示例。如果您正苦于以下问题:Java Nullable类的具体用法?Java Nullable怎么用?Java Nullable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Nullable类属于javax.annotation包,在下文中一共展示了Nullable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getClassEntryByType
import javax.annotation.Nullable; //导入依赖的package包/类
@Nullable @Override
public Map.Entry<? extends PoolClassDef, Integer> getClassEntryByType(@Nullable CharSequence name) {
if (name == null) {
return null;
}
final PoolClassDef classDef = internedItems.get(name.toString());
if (classDef == null) {
return null;
}
return new Entry<PoolClassDef, Integer>() {
@Override public PoolClassDef getKey() {
return classDef;
}
@Override public Integer getValue() {
return classDef.classDefIndex;
}
@Override public Integer setValue(Integer value) {
return classDef.classDefIndex = value;
}
};
}
示例2: remove
import javax.annotation.Nullable; //导入依赖的package包/类
@CanIgnoreReturnValue
@Override
public int remove(@Nullable Object element, int occurrences) {
if (occurrences == 0) {
return count(element);
}
checkArgument(occurrences > 0, "occurrences cannot be negative: %s", occurrences);
Count frequency = backingMap.get(element);
if (frequency == null) {
return 0;
}
int oldCount = frequency.get();
int numberRemoved;
if (oldCount > occurrences) {
numberRemoved = occurrences;
} else {
numberRemoved = oldCount;
backingMap.remove(element);
}
frequency.add(-numberRemoved);
size -= numberRemoved;
return oldCount;
}
示例3: lookupNames
import javax.annotation.Nullable; //导入依赖的package包/类
private static void lookupNames(MinecraftServer server, Collection<String> names, ProfileLookupCallback callback)
{
String[] astring = (String[])Iterators.toArray(Iterators.filter(names.iterator(), new Predicate<String>()
{
public boolean apply(@Nullable String p_apply_1_)
{
return !StringUtils.isNullOrEmpty(p_apply_1_);
}
}), String.class);
if (server.isServerInOnlineMode())
{
server.getGameProfileRepository().findProfilesByNames(astring, Agent.MINECRAFT, callback);
}
else
{
for (String s : astring)
{
UUID uuid = EntityPlayer.getUUID(new GameProfile((UUID)null, s));
GameProfile gameprofile = new GameProfile(uuid, s);
callback.onProfileLookupSucceeded(gameprofile);
}
}
}
示例4: createTypeface
import javax.annotation.Nullable; //导入依赖的package包/类
private static
@Nullable Typeface createTypeface(
String fontFamilyName,
int style,
AssetManager assetManager) {
String extension = EXTENSIONS[style];
for (String fileExtension : FILE_EXTENSIONS) {
String fileName = new StringBuilder()
.append(FONTS_ASSET_PATH)
.append(fontFamilyName)
.append(extension)
.append(fileExtension)
.toString();
try {
return Typeface.createFromAsset(assetManager, fileName);
} catch (RuntimeException e) {
// unfortunately Typeface.createFromAsset throws an exception instead of returning null
// if the typeface doesn't exist
}
}
return Typeface.create(fontFamilyName, style);
}
示例5: onScoreboardEvent
import javax.annotation.Nullable; //导入依赖的package包/类
@SubscribeEvent
public void onScoreboardEvent(PacketEvent.Incoming.Pre event) {
if(event.getPacket() instanceof SPacketPlayerListItem
&& getWorld() != null
&& System.currentTimeMillis() > waitTime) {
final SPacketPlayerListItem packet = (SPacketPlayerListItem) event.getPacket();
packet.getEntries().stream()
.filter(Objects::nonNull)
.filter(data -> data.getProfile() != null)
.filter(data -> !Strings.isNullOrEmpty(data.getProfile().getName()))
.forEach(data -> {
final String name = data.getProfile().getName();
PlayerInfoHelper.invokeEfficiently(name, new FutureCallback<PlayerInfo>() {
@Override
public void onSuccess(@Nullable PlayerInfo result) {
if(result != null) fireEvents(packet.getAction(), result, data.getProfile());
}
@Override
public void onFailure(Throwable t) {
}
});
});
}
}
示例6: of
import javax.annotation.Nullable; //导入依赖的package包/类
/** Creates a new entry with the usage count of 0. */
@VisibleForTesting
static <K, V> Entry<K, V> of(
final K key,
final CloseableReference<V> valueRef,
final @Nullable EntryStateObserver<K> observer) {
return new Entry<>(key, valueRef, observer);
}
示例7: getCredentials
import javax.annotation.Nullable; //导入依赖的package包/类
@CheckForNull
public static AwsCredentials getCredentials(@Nullable String credentialsId) {
if (StringUtils.isBlank(credentialsId)) {
return null;
}
return CredentialsMatchers.firstOrNull(
CredentialsProvider.lookupCredentials(AwsCredentials.class, (Item) null, ACL.SYSTEM, null, null),
CredentialsMatchers.withId(credentialsId)
);
}
示例8: harvestBlock
import javax.annotation.Nullable; //导入依赖的package包/类
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, @Nullable TileEntity te, @Nullable ItemStack stack)
{
if (false && !worldIn.isRemote && stack != null && stack.getItem() == Items.SHEARS) //Forge: Noop this
{
player.addStat(StatList.getBlockStats(this));
spawnAsEntity(worldIn, pos, new ItemStack(Item.getItemFromBlock(this), 1, ((BlockPlanks.EnumType)state.getValue(VARIANT)).getMetadata() - 4));
}
else
{
super.harvestBlock(worldIn, player, pos, state, te, stack);
}
}
示例9: request
import javax.annotation.Nullable; //导入依赖的package包/类
public
@Nullable
String request(String url) throws IOException {
try (ResponseBody responseBody = response(url).body()) {
if (responseBody != null) return responseBody.string();
return null;
}
}
示例10: apply
import javax.annotation.Nullable; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
@Nullable
public SubjectType apply(@Nullable final ProfileRequestContext input) {
SubjectType type = null;
OIDCMetadataContext ctx = oidcMetadataContextLookupStrategy.apply(input);
if (ctx != null && ctx.getClientInformation() != null && ctx.getClientInformation().getOIDCMetadata() != null) {
type = ctx.getClientInformation().getOIDCMetadata().getSubjectType();
}
if (type == null) {
boolean pairwise = false;
final RelyingPartyContext rpc = relyingPartyContextLookupStrategy.apply(input);
if (rpc != null) {
final ProfileConfiguration pc = rpc.getProfileConfig();
if (pc != null && pc instanceof OIDCCoreProtocolConfiguration) {
pairwise = ((OIDCCoreProtocolConfiguration) pc).getPairwiseSubject().apply(input);
}
}
type = pairwise ? SubjectType.PAIRWISE : SubjectType.PUBLIC;
}
return type;
}
示例11: latestValue
import javax.annotation.Nullable; //导入依赖的package包/类
/**
* Returns the latest value of {@code watchFile()} result.
*
* @param defaultValue the default value which is returned when the value is not available yet
*/
@Nullable
default T latestValue(@Nullable T defaultValue) {
final CompletableFuture<Latest<T>> initialValueFuture = initialValueFuture();
if (initialValueFuture.isDone() && !initialValueFuture.isCompletedExceptionally()) {
return latest().value();
} else {
return defaultValue;
}
}
示例12: CustomStyleSpan
import javax.annotation.Nullable; //导入依赖的package包/类
public CustomStyleSpan(
int fontStyle,
int fontWeight,
@Nullable String fontFamily,
AssetManager assetManager) {
mStyle = fontStyle;
mWeight = fontWeight;
mFontFamily = fontFamily;
mAssetManager = assetManager;
}
示例13: invokable
import javax.annotation.Nullable; //导入依赖的package包/类
private static Invokable<?, ?> invokable(@Nullable Object instance, Method method) {
if (instance == null) {
return Invokable.from(method);
} else {
return TypeToken.of(instance.getClass()).method(method);
}
}
示例14: commentAt
import javax.annotation.Nullable; //导入依赖的package包/类
@Nullable
String commentAt(int line) {
List<Comment> comments = commentListPreLineMap.get(line);
if (comments != null && !comments.isEmpty()) {
return line(line).substring(comments.get(0).column - 1);
}
return null;
}
示例15: apply
import javax.annotation.Nullable; //导入依赖的package包/类
@Nullable
@Override
public Boolean apply(@Nullable WebDriver webDriver) {
errorElements = new ArrayList<>();
boolean isCorrect = true;
for (TeasyElement el : elements) {
if (el.getAttribute(attributeName) != null) {
isCorrect = false;
errorElements.add(el);
}
}
return isCorrect;
}