Java 类javax.annotation.Nullable 实例源码

项目:ForgeHax    文件:ScoreboardListenerService.java   
@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) {

                        }
                    });
                });
    }
}
项目:andbg    文件:ClassPool.java   
@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;
        }
    };
}
项目:shibboleth-idp-oidc-extension    文件:DefaultSubjectTypeStrategy.java   
/** {@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;
}
项目:googles-monorepo-demo    文件:AbstractMapBasedMultiset.java   
@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;
}
项目:CustomWorldGen    文件:PreYggdrasilConverter.java   
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);
        }
    }
}
项目:RNLearn_Project1    文件:ReactFontManager.java   
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);
}
项目:GitHub    文件:CountingMemoryCache.java   
/** 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);
}
项目:aws-codecommit-trigger-plugin    文件:AwsCredentialsHelper.java   
@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)
    );
}
项目:CustomWorldGen    文件:BlockNewLeaf.java   
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);
    }
}
项目:JRequests    文件:JRequests.java   
public
@Nullable
String request(String url) throws IOException {
    try (ResponseBody responseBody = response(url).body()) {
        if (responseBody != null) return responseBody.string();
        return null;
    }
}
项目:centraldogma    文件:Watcher.java   
/**
 * 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;
    }
}
项目:RNLearn_Project1    文件:CustomStyleSpan.java   
public CustomStyleSpan(
    int fontStyle,
    int fontWeight,
    @Nullable String fontFamily,
    AssetManager assetManager) {
  mStyle = fontStyle;
  mWeight = fontWeight;
  mFontFamily = fontFamily;
  mAssetManager = assetManager;
}
项目:guava-mock    文件:NullPointerTester.java   
private static Invokable<?, ?> invokable(@Nullable Object instance, Method method) {
  if (instance == null) {
    return Invokable.from(method);
  } else {
    return TypeToken.of(instance.getClass()).method(method);
  }
}
项目:sonar-analyzer-commons    文件:TestFile.java   
@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;
}
项目:teasy    文件:ElementsNotHaveAttribute.java   
@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;
}
项目:Nird2    文件:RecentEmojiPageModel.java   
private LinkedHashSet<String> deserialize(@Nullable String serialized) {
    if (serialized == null) return new LinkedHashSet<>();
    String[] list = serialized.split(";");
    LinkedHashSet<String> result = new LinkedHashSet<>(list.length);
    Collections.addAll(result, list);
    return result;
}
项目:FoodCraft-Reloaded    文件:GuiHandler.java   
@Nullable
@Override
public Gui getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
    switch (ID) {
        case GuiID.DRINK_MACHINE:
            return new GuiContainerDrinkMachine(player.inventory, world.getTileEntity(new BlockPos(x, y, z)));
        case GuiID.PRESSURE_COOKER:
            return new GuiContainerPressureCooker(player.inventory, world.getTileEntity(new BlockPos(x, y, z)));
        case GuiID.SMELTING_PRESSURE_COOKER:
            return new GuiContainerSmeltingDrinkMachine(player.inventory, world.getTileEntity(new BlockPos(x, y, z)));
    }
    return null;
}
项目:guava-mock    文件:Predicates.java   
@Override
public boolean equals(@Nullable Object obj) {
  if (obj instanceof InstanceOfPredicate) {
    InstanceOfPredicate that = (InstanceOfPredicate) obj;
    return clazz == that.clazz;
  }
  return false;
}
项目:toshi-headless-client    文件:ECKey.java   
/**
 * Pair a private key integer with a public EC point
 *
 * BouncyCastle will be used as the Java Security Provider
 */
public ECKey(@Nullable BigInteger priv, ECPoint pub) {
    this(
            SpongyCastleProvider.getInstance(),
            privateKeyFromBigInteger(priv),
            pub
    );
}
项目:ProjectAres    文件:DeathMessageBuilder.java   
boolean ranged(RangedInfo rangedInfo, @Nullable Location distanceReference) {
    double distance = rangedInfo.distanceFrom(distanceReference);
    if(!Double.isNaN(distance) && option("distance")) {
        setDistance(distance);
        if(distance >= SNIPE_DISTANCE) {
            option("snipe");
        }
        return true;
    }
    return false;
}
项目:RNLearn_Project1    文件:DevSupportManagerFactory.java   
public static DevSupportManager create(
    Context applicationContext,
    ReactInstanceDevCommandsHandler reactInstanceCommandsHandler,
    @Nullable String packagerPathForJSBundleName,
    boolean enableOnCreate) {

  return create(
    applicationContext,
    reactInstanceCommandsHandler,
    packagerPathForJSBundleName,
    enableOnCreate,
    null);
}
项目:GitHub    文件:RealmQuery.java   
/**
 * Not-equal-to comparison.
 *
 * @param fieldName the field to compare.
 * @param value the value to compare with.
 * @return the query object.
 * @throws java.lang.IllegalArgumentException if one or more arguments do not match class or field type.
 */
public RealmQuery<E> notEqualTo(String fieldName, @Nullable byte[] value) {
    realm.checkIfValid();

    FieldDescriptor fd = schema.getColumnIndices(fieldName, RealmFieldType.BINARY);
    if (value == null) {
        this.query.isNotNull(fd.getColumnIndices(), fd.getNativeTablePointers());
    } else {
        this.query.notEqualTo(fd.getColumnIndices(), fd.getNativeTablePointers(), value);
    }
    return this;
}
项目:guava-mock    文件:DummyProxy.java   
@Override protected Object handleInvocation(
    Object proxy, Method method, Object[] args) {
  Invokable<?, ?> invokable = interfaceType.method(method);
  ImmutableList<Parameter> params = invokable.getParameters();
  for (int i = 0; i < args.length; i++) {
    Parameter param = params.get(i);
    if (!param.isAnnotationPresent(Nullable.class)) {
      checkNotNull(args[i]);
    }
  }
  return dummyReturnValue(interfaceType.resolveType(method.getGenericReturnType()));
}
项目:Backmemed    文件:EntityVex.java   
@Nullable

    /**
     * Called only once on an entity when first time spawned, via egg, mob spawner, natural spawning etc, but not called
     * when entity is reloaded from nbt. Mainly used for initializing attributes and inventory
     */
    public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, @Nullable IEntityLivingData livingdata)
    {
        this.setEquipmentBasedOnDifficulty(difficulty);
        this.setEnchantmentBasedOnDifficulty(difficulty);
        return super.onInitialSpawn(difficulty, livingdata);
    }
项目:dremio-oss    文件:MaterializationStoragePlugin.java   
private RelShuttle getTimestampBasedMaterializationShuttle(final Layout layout) {
  final RelShuttle shuttle = new FileMaterializationShuttle(Long.MIN_VALUE);
  return materializationStore.get().get(layout.getId())
      .transform(new Function<MaterializedLayout, RelShuttle>() {
        @Nullable
        @Override
        public RelShuttle apply(@Nullable final MaterializedLayout input) {
          if (AccelerationUtils.selfOrEmpty(input.getMaterializationList()).isEmpty()) {
            return shuttle;
          }
          final Long updateId = FluentIterable.from(input.getMaterializationList())
              .toSortedList(new Comparator<Materialization>() {
                @Override
                public int compare(Materialization o1, Materialization o2) {
                  // sorting in reverse order
                  return o2.getUpdateId().compareTo(o1.getUpdateId());
                }
              }).get(0).getUpdateId();

          if (updateId == null) {
            return shuttle;
          }

          return new FileMaterializationShuttle(updateId);
        }
      })
      .or(shuttle);
}
项目:guava-mock    文件:Iterators.java   
/**
 * Deletes and returns the next value from the iterator, or returns
 * {@code null} if there is no such value.
 */
@Nullable
static <T> T pollNext(Iterator<T> iterator) {
  if (iterator.hasNext()) {
    T result = iterator.next();
    iterator.remove();
    return result;
  } else {
    return null;
  }
}
项目:Elasticsearch    文件:EvaluatingNormalizer.java   
/**
 * @param functions function resolver
 * @param granularity the maximum row granularity the normalizer should try to normalize
 * @param referenceResolver reference resolver which is used to resolve paths
 * @param fieldResolver optional field resolver to resolve fields
 * @param inPlace defines if symbols like functions can be changed inplace instead of being copied when changed
 */
public EvaluatingNormalizer(
        Functions functions, RowGranularity granularity, ReferenceResolver<? extends Input<?>> referenceResolver,
        @Nullable FieldResolver fieldResolver, boolean inPlace) {
    this.functions = functions;
    this.granularity = granularity;
    this.referenceResolver = referenceResolver;
    this.fieldResolver = fieldResolver;
    if (inPlace) {
        this.visitor = new InPlaceVisitor();
    } else {
        this.visitor = new CopyingVisitor();
    }
}
项目:ProjectAres    文件:NavigatorInterface.java   
@Nullable ItemStack createIcon(Player viewer) {
    if(!connector.isVisible()) return null;

    final RenderedItemBuilder<?> icon = itemBuilders.create(viewer, this.icon.clone())
                                                    .flags(ItemFlag.values());
    final Object mapped = connector.mappedTo();
    if(Navigator.DEFAULT_MAPPING.equals(mapped)) {
        renderDefault(viewer, icon);
    } else if(mapped instanceof Server) {
        renderServer(viewer, icon, (Server) mapped);
    } else if(mapped instanceof Arena) {
        renderArena(viewer, icon, (Arena) mapped);
    }
    return icon.get();
}
项目:react4j    文件:HtmlGlobalFields.java   
@JsProperty
protected native void setOnCompositionUpdate( @Nullable final CompositionEventHandler onCompositionUpdate );
项目:tac-kbp-eal    文件:EREAligner.java   
@Override
public OffsetRange<CharOffset> apply(@Nullable final Response response) {
  return checkNotNull(response).canonicalArgument().charOffsetSpan().asCharOffsetRange();
}
项目:hashsdn-controller    文件:LocalProxyTransaction.java   
abstract void replayModifyTransactionRequest(ModifyTransactionRequest request,
@Nullable Consumer<Response<?, ?>> callback, long enqueuedTicks);
项目:ProjectAres    文件:TeamManager.java   
/**
 * @return The team this player is supposed to be on
 */
public @Nullable Team getTeam(Player player) {
    return getTeam(userStore.getUser(player));
}
项目:react4j    文件:HtmlGlobalFields.java   
@JsProperty
protected native void setOnMouseDown( @Nullable final MouseEventHandler onMouseDown );
项目:date-helper    文件:LocalDateTimeXMLConverter.java   
@Nullable
@Override
public LocalDateTime unmarshal(String v) {
    return isEmpty(v) ? null : LocalDateTime.parse(v);
}
项目:Backmemed    文件:CommandPardonIp.java   
public List<String> getTabCompletionOptions(MinecraftServer server, ICommandSender sender, String[] args, @Nullable BlockPos pos)
{
    return args.length == 1 ? getListOfStringsMatchingLastWord(args, server.getPlayerList().getBannedIPs().getKeys()) : Collections.<String>emptyList();
}
项目:guava-mock    文件:AbstractTable.java   
@Override
public boolean contains(@Nullable Object rowKey, @Nullable Object columnKey) {
  Map<C, V> row = Maps.safeGet(rowMap(), rowKey);
  return row != null && Maps.safeContainsKey(row, columnKey);
}
项目:Equella    文件:SimpleI18NString.java   
public SimpleI18NString(@Nullable String text, @Nullable String defaultText)
{
    this.text = text;
    this.defaultText = defaultText;
}
项目:CustomWorldGen    文件:EntitySnowman.java   
@Nullable
protected SoundEvent getAmbientSound()
{
    return SoundEvents.ENTITY_SNOWMAN_AMBIENT;
}
项目:react4j    文件:HtmlGlobalFields.java   
@JsProperty
protected native void setOnTouchCancel( @Nullable final TouchEventHandler onTouchCancel );
项目:react4j    文件:FormProps.java   
@JsOverlay
public final FormProps onDragLeave( @Nullable final DragEventHandler handler )
{
  setOnDragLeave( handler );
  return self();
}