当前位置: 首页>>代码示例>>Java>>正文


Java Nullable类代码示例

本文整理汇总了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;
        }
    };
}
 
开发者ID:CvvT,项目名称:andbg,代码行数:26,代码来源:ClassPool.java

示例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;
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:27,代码来源:AbstractMapBasedMultiset.java

示例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);
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:25,代码来源:PreYggdrasilConverter.java

示例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);
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:24,代码来源:ReactFontManager.java

示例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) {

                        }
                    });
                });
    }
}
 
开发者ID:fr1kin,项目名称:ForgeHax,代码行数:27,代码来源:ScoreboardListenerService.java

示例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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:CountingMemoryCache.java

示例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)
    );
}
 
开发者ID:riboseinc,项目名称:aws-codecommit-trigger-plugin,代码行数:12,代码来源:AwsCredentialsHelper.java

示例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);
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:13,代码来源:BlockNewLeaf.java

示例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;
    }
}
 
开发者ID:tomoncle,项目名称:JRequests,代码行数:9,代码来源:JRequests.java

示例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;
}
 
开发者ID:CSCfi,项目名称:shibboleth-idp-oidc-extension,代码行数:24,代码来源:DefaultSubjectTypeStrategy.java

示例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;
    }
}
 
开发者ID:line,项目名称:centraldogma,代码行数:15,代码来源:Watcher.java

示例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;
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:11,代码来源:CustomStyleSpan.java

示例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);
  }
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:8,代码来源:NullPointerTester.java

示例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;
}
 
开发者ID:SonarSource,项目名称:sonar-analyzer-commons,代码行数:9,代码来源:TestFile.java

示例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;
}
 
开发者ID:WileyLabs,项目名称:teasy,代码行数:14,代码来源:ElementsNotHaveAttribute.java


注:本文中的javax.annotation.Nullable类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。