Java 类javax.annotation.Nonnull 实例源码

项目:VoxelGamesLibv2    文件:Lang.java   
@Nonnull
public static String legacyColors(@Nonnull String message) {
    StringBuilder result = new StringBuilder();
    String[] tokens = message.split("\\{|}");
    outer:
    for (String token : tokens) {
        for (TextColor color : TextColor.values()) {
            if (color.name().equalsIgnoreCase(token)) {
                result.append(color);
                continue outer;
            }
        }

        result.append(token);
    }

    return result.toString();
}
项目:spring-boot-gae    文件:SearchRepository.java   
@Nonnull
@Override
default Supplier<E> saveAsync(final E entity) {
    boolean needsId = hasNoId(entity);

    final Supplier<E> saveOperation = SaveRepository.super.saveAsync(entity);

    // if the entity has no id we need the save to complete so we can index by the generated id.
    if (needsId) {
        saveOperation.get();
    }

    final Runnable indexOperation = index(entity);

    return () -> {
        indexOperation.run();

        saveOperation.get();
        return entity;
    };
}
项目:objectbox-java    文件:ReflectionCache.java   
@Nonnull
public synchronized Field getField(Class clazz, String name) {
    Map<String, Field> fieldsForClass = fields.get(clazz);
    if (fieldsForClass == null) {
        fieldsForClass = new HashMap<>();
        fields.put(clazz, fieldsForClass);
    }
    Field field = fieldsForClass.get(name);
    if (field == null) {
        try {
            field = clazz.getDeclaredField(name);
            field.setAccessible(true);
        } catch (NoSuchFieldException e) {
            throw new IllegalStateException(e);
        }
        fieldsForClass.put(name, field);
    }
    return field;
}
项目:vt-support    文件:StorageImpl.java   
private static synchronized Single<HashMap<String, String>> queryMetadata(Database dataSource) {
  final URL url = Resources.getResource("metadata_key_value.sql");
  String query;
  try {
    query = Resources.toString(url, Charsets.UTF_8);
  } catch (final IOException ex) {
    return Single.error(ex);
  }
  return dataSource.select(query).get(new ResultSetMapper<HashMap<String, String>>() {
    @Override
    public HashMap<String, String> apply(@Nonnull ResultSet rs) throws SQLException {
      final HashMap<String, String> metadata = new LinkedHashMap<>();

      while (rs.getRow() != 0) {
        metadata.put(rs.getString("name"), rs.getString("value"));
        rs.next();
      }
      return metadata;
    }
  }).singleOrError();
}
项目:envinject-api-plugin    文件:EnvVarsResolver.java   
/**
 * Retrieves variables describing the Run cause. 
 * @param run Run
 * @return Set of environment variables, which depends on the cause type. 
 */
@Nonnull
public static Map<String, String> getCauseEnvVars(@Nonnull Run<?, ?> run) {
    CauseAction causeAction = run.getAction(CauseAction.class);
    Map<String, String> env = new HashMap<>();
    List<String> directCauseNames = new ArrayList<>();
    Set<String> rootCauseNames = new LinkedHashSet<>();

    if (causeAction != null) {
        List<Cause> buildCauses = causeAction.getCauses();
        for (Cause cause : buildCauses) {
            directCauseNames.add(CauseHelper.getTriggerName(cause));
            CauseHelper.insertRootCauseNames(rootCauseNames, cause, 0);
        }
    } else {
        directCauseNames.add("UNKNOWN");
        rootCauseNames.add("UNKNOWN");
    }
    env.putAll(CauseHelper.buildCauseEnvironmentVariables(ENV_CAUSE, directCauseNames));
    env.putAll(CauseHelper.buildCauseEnvironmentVariables(ENV_ROOT_CAUSE, rootCauseNames));
    return env;
}
项目:commercetools-sync-java    文件:ProductSync.java   
@Override
protected CompletionStage<ProductSyncStatistics> processBatch(@Nonnull final List<ProductDraft> batch) {
    productsToSync = new HashMap<>();
    draftsToCreate = new HashSet<>();
    return productService.cacheKeysToIds()
                         .thenCompose(keyToIdCache -> {
                             final Set<String> productDraftKeys = getProductDraftKeys(batch);
                             return productService.fetchMatchingProductsByKeys(productDraftKeys)
                                                  .thenAccept(matchingProducts ->
                                                      processFetchedProducts(matchingProducts, batch))
                                                  .thenCompose(result -> createOrUpdateProducts())
                                                  .thenApply(result -> {
                                                      statistics.incrementProcessed(batch.size());
                                                      return statistics;
                                                  });
                         });
}
项目:NewPipeExtractor    文件:YoutubeStreamExtractor.java   
@Override
public void onFetchPage(@Nonnull Downloader downloader) throws IOException, ExtractionException {
    final String pageContent = getPageHtml(downloader);
    doc = Jsoup.parse(pageContent, getCleanUrl());

    final String playerUrl;
    // TODO: use embedded videos to fetch DASH manifest for all videos
    // Check if the video is age restricted
    if (pageContent.contains("<meta property=\"og:restrictions:age")) {
        final EmbeddedInfo info = getEmbeddedInfo();
        final String videoInfoUrl = getVideoInfoUrl(getId(), info.sts);
        final String infoPageResponse = downloader.download(videoInfoUrl);
        videoInfoPage.putAll(Parser.compatParseMap(infoPageResponse));
        playerUrl = info.url;
        isAgeRestricted = true;
    } else {
        final JsonObject ytPlayerConfig = getPlayerConfig(pageContent);
        playerArgs = getPlayerArgs(ytPlayerConfig);
        playerUrl = getPlayerUrl(ytPlayerConfig);
        isAgeRestricted = false;
    }

    if (decryptionCode.isEmpty()) {
        decryptionCode = loadDecryptionCode(playerUrl);
    }
}
项目:nightclazz-graphql    文件:SearchQuery.java   
public NearestAntennaFromFree3(@Nonnull String __typename, @Nullable Coordinates15 coordinates,
    @Nullable String generation, @Nullable String provider, @Nullable String lastUpdate,
    @Nullable String status, @Nullable Integer dist, @Nullable String insee,
    @Nullable String city, @Nullable String addressLabel, @Nonnull Fragments fragments) {
  if (__typename == null) {
    throw new NullPointerException("__typename can't be null");
  }
  this.__typename = __typename;
  this.coordinates = coordinates;
  this.generation = generation;
  this.provider = provider;
  this.lastUpdate = lastUpdate;
  this.status = status;
  this.dist = dist;
  this.insee = insee;
  this.city = city;
  this.addressLabel = addressLabel;
  if (fragments == null) {
    throw new NullPointerException("fragments can't be null");
  }
  this.fragments = fragments;
}
项目:Elasticsearch    文件:AbstractChainedTask.java   
@Override
public void start() {
    if (!this.upstreamResult.isEmpty()) {
        Futures.addCallback(Futures.allAsList(this.upstreamResult), new FutureCallback<List<TaskResult>>() {
            @Override
            public void onSuccess(@Nullable List<TaskResult> result) {
                doStart(result);
            }

            @Override
            public void onFailure(@Nonnull Throwable t) {
                result.setException(t);
            }
        });
    } else {
        doStart(ImmutableList.<TaskResult>of());
    }
}
项目:Debuggery    文件:InputFormatter.java   
@Nonnull
private static UUID getUUID(String input, CommandSender sender) throws InputException {
    try {
        return UUID.fromString(input);
    } catch (IllegalArgumentException ex) {
        if (sender instanceof Player) {
            Entity entity = getEntity(input, sender);

            if (entity != null) {
                return entity.getUniqueId();
            }
        }

        throw new InputException(ex);
    }
}
项目:helper    文件:Configs.java   
public static void gsonSave(@Nonnull File file, @Nonnull ConfigurationNode node) {
    try {
        gson(file).save(node);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
项目:reflow-animator    文件:ReflowTextAnimatorHelper.java   
private static void drawLayerBounds(@Nonnull Canvas canvas,
                                    @Nonnull Rect bounds,
                                    int sectionNumber,
                                    @Nonnull Paint fillPaint,
                                    @Nonnull Paint outlinePaint,
                                    @Nonnull Paint textPaint) {
    Rect startRect = new Rect(bounds.left + 1, bounds.top + 1, bounds.right - 1, bounds.bottom - 1);
    canvas.drawRect(startRect, fillPaint);
    canvas.drawRect(startRect, outlinePaint);
    canvas.drawText("" + sectionNumber, bounds.left + 6, bounds.top + 21, textPaint);
}
项目:VoxelGamesLibv2    文件:GameDefinition.java   
@Override
@Nonnull
public String toString() {
    return "GameDefinition{" +
            "gameMode=" + gameMode +
            ", minPlayers=" + minPlayers +
            ", maxPlayers=" + maxPlayers +
            ", phases=" + phases +
            ", gameData=" + gameData +
            '}';
}
项目:Thermionics    文件:CapabilityProvider.java   
@SuppressWarnings("unchecked")
@Nullable
public <T> T provide(@Nonnull RelativeDirection side, @Nonnull Capability<T> capability) {
    Validate.notNull(capability);

    for(Entry<?> entry : entries) {
        //if (side!=null) {
            if (entry.directions.contains(side) && capability.equals(entry.capability)) return (T)entry.provide();
        //} else {
        //  if (capability.equals(entry.capability)) return (T)entry.provide();
        //}
    }

    return null;
}
项目:json2java4idea    文件:Configuration.java   
private Configuration(@Nonnull Builder builder) {
    style = builder.style;
    classNamePolicy = builder.classNamePolicy;
    fieldNamePolicy = builder.fieldNamePolicy;
    methodNamePolicy = builder.methodNamePolicy;
    parameterNamePolicy = builder.parameterNamePolicy;
    annotationPolicies = ImmutableSet.copyOf(builder.annotationPolicies);
    jsonParser = builder.jsonParser;
    javaBuilder = builder.javaBuilder;
}
项目:VoxelGamesLibv2    文件:TextureCommands.java   
@Subcommand("get")
@CommandPermission("%admin")
public void getById(@Nonnull User user, @Nonnull Integer id) {
    Lang.msg(user, LangKey.TEXTURE_FETCHING_TEXTURE);
    textureHandler.fetchSkin(id, skin -> {
        ItemStack skull = textureHandler.getSkull(skin);
        user.getPlayer().getInventory().addItem(skull);
        Lang.msg(user, LangKey.TEXTURE_TEXTURE_APPLIED);
    });
}
项目:lokalized-java    文件:NumberUtils.java   
/**
 * Is the first number less than the second number?
 *
 * @param number1 the first number to compare, not null
 * @param number2 the second number to compare, not null
 * @return true if the first number is less than the second number, not null
 */
@Nonnull
static Boolean lessThan(@Nonnull BigInteger number1, @Nonnull BigInteger number2) {
  requireNonNull(number1);
  requireNonNull(number2);

  return number1.compareTo(number2) < 0;
}
项目:shibboleth-idp-oidc-extension    文件:AbstractOIDCEncoderParser.java   
/** {@inheritDoc} */
@Override
protected void doParse(@Nonnull final Element config, @Nonnull final ParserContext parserContext,
        @Nonnull final BeanDefinitionBuilder builder) {

    super.doParse(config, parserContext, builder);
    if (config.hasAttributeNS(null, AS_ARRAY_ATTRIBUTE_NAME)) {
        builder.addPropertyValue("asArray",
                StringSupport.trimOrNull(config.getAttributeNS(null, AS_ARRAY_ATTRIBUTE_NAME)));
    }
    if (config.hasAttributeNS(null, AS_INT_ATTRIBUTE_NAME)) {
        builder.addPropertyValue("asInt",
                StringSupport.trimOrNull(config.getAttributeNS(null, AS_INT_ATTRIBUTE_NAME)));
    }
    if (config.hasAttributeNS(null, STRING_DELIMETER_ATTRIBUTE_NAME)) {
        builder.addPropertyValue("stringDelimiter",
                StringSupport.trimOrNull(config.getAttributeNS(null, STRING_DELIMETER_ATTRIBUTE_NAME)));
    }
    if (config.hasAttributeNS(null, AS_OBJECT_ATTRIBUTE_NAME)) {
        builder.addPropertyValue("asObject",
                StringSupport.trimOrNull(config.getAttributeNS(null, AS_OBJECT_ATTRIBUTE_NAME)));
    }
    if (config.hasAttributeNS(null, FIELD_NAME_ATTRIBUTE_NAME)) {
        builder.addPropertyValue("fieldName",
                StringSupport.trimOrNull(config.getAttributeNS(null, FIELD_NAME_ATTRIBUTE_NAME)));
    }
    if (config.hasAttributeNS(null, AS_BOOLEAN_ATTRIBUTE_NAME)) {
        builder.addPropertyValue("asBoolean",
                StringSupport.trimOrNull(config.getAttributeNS(null, AS_BOOLEAN_ATTRIBUTE_NAME)));
    }
}
项目:pnc-repressurized    文件:IOHelper.java   
/**
 * Extracts an exact item (including size) from the given tile entity, trying all sides.
 *
 * @param tile the tile to extract from
 * @param itemStack the precise item stack to extract (size matters)
 * @param simulate true if extraction should only be simulated
 * @return the extracted item stack
 */
@Nonnull
public static ItemStack extract(TileEntity tile, ItemStack itemStack, boolean simulate) {
    for (EnumFacing d : EnumFacing.VALUES) {
        IItemHandler handler = getInventoryForTE(tile, d);
        if (handler != null) {
            ItemStack extracted = extract(handler, itemStack, true, simulate);
            if (!extracted.isEmpty()) {
                return extracted;
            }
        }
    }
    return ItemStack.EMPTY;
}
项目:helper    文件:Configs.java   
@Nonnull
public static <T> ObjectMapper<T>.BoundInstance objectMapper(@Nonnull T object) {
    try {
        return ObjectMapper.forObject(object);
    } catch (ObjectMappingException e) {
        throw new RuntimeException(e);
    }
}
项目:Debuggery    文件:OutputFormatter.java   
@Nonnull
private static String handleHelpMap(HelpMap helpMap) {
    StringBuilder returnString = new StringBuilder("[");

    for (HelpTopic topic : helpMap.getHelpTopics()) {
        returnString.append("{").append(topic.getName()).append(", ").append(topic.getShortText()).append("}\n");
    }

    return returnString.append("]").toString();
}
项目:arez    文件:ComputedDescriptor.java   
void setOnStale( @Nonnull final ExecutableElement onStale )
  throws ArezProcessorException
{
  MethodChecks.mustBeLifecycleHook( Constants.ON_STALE_ANNOTATION_CLASSNAME, onStale );
  if ( null != _onStale )
  {
    throw new ArezProcessorException( "@OnStale target duplicates existing method named " +
                                      _onStale.getSimpleName(),
                                      onStale );
  }
  else
  {
    _onStale = Objects.requireNonNull( onStale );
  }
}
项目:graphiak    文件:MetricStore.java   
/**
 * Constructor
 *
 * @param client
 *            Riak client
 */
public MetricStore(@Nonnull final RiakClient client) {
    this.client = Objects.requireNonNull(client);

    final MetricRegistry registry = SharedMetricRegistries
            .getOrCreate("default");
    this.queryTimer = registry
            .timer(MetricRegistry.name(MetricStore.class, "query"));
    this.storeTimer = registry
            .timer(MetricRegistry.name(MetricStore.class, "store"));
    this.deleteTimer = registry
            .timer(MetricRegistry.name(MetricStore.class, "delete"));
}
项目:GardenStuff    文件:BlockBloomeryFurnace.java   
@Override
public void onBlockPlacedBy (World world, BlockPos pos, IBlockState state, EntityLivingBase placer, @Nonnull ItemStack stack) {
    world.setBlockState(pos, state.withProperty(FACING, placer.getHorizontalFacing().getOpposite()), 2);

    if (stack.hasDisplayName()) {
        TileEntity tile = world.getTileEntity(pos);
        if (tile instanceof TileBloomeryFurnace)
            ((TileBloomeryFurnace)tile).setInventoryName(stack.getDisplayName());
    }
}
项目:Lanolin    文件:RecipeLanolinFactory.java   
@Override
@Nonnull
public ItemStack getCraftingResult(InventoryCrafting inv) {
    int lanolinCount = 0;
    ItemStack craftStack = null;
    for(int i = 0; i < inv.getSizeInventory(); i++){
        ItemStack tempStack = inv.getStackInSlot(i);
        if(tempStack.getItem().getRegistryName().equals(ModItems.itemLanolin.getRegistryName()))
            lanolinCount++;
        else if(ItemLanolin.canCraftWith(tempStack) && craftStack == null) {
            craftStack = tempStack.copy();
        }
        else if(tempStack != ItemStack.EMPTY)
            return ItemStack.EMPTY;
    }
    if (craftStack == ItemStack.EMPTY || !ItemLanolin.canCraftWith(craftStack)) {
        return ItemStack.EMPTY;
    }
    // Copy Existing NBT
    if(craftStack.hasTagCompound()) {
        if(craftStack.getTagCompound().hasKey("lanolin")){
            // Increase existing lanolin count
            lanolinCount += craftStack.getTagCompound().getInteger("lanolin");
        }
    }
    if(craftStack.getItem() instanceof ItemArmor)
        craftStack.setTagInfo("lanolin", new NBTTagByte((byte) clamp(lanolinCount,0, Config.MAX_LANOLIN_ARMOR)));
    else if(craftStack.getItem() instanceof ItemTool)
        craftStack.setTagInfo("lanolin", new NBTTagByte((byte) clamp(lanolinCount,0, Config.MAX_LANOLIN_TOOLS)));
    else // Unconfigured item, that passed
        craftStack.setTagInfo("lanolin", new NBTTagByte((byte) clamp(lanolinCount,0, 15)));
    return craftStack;
}
项目:rskj    文件:FamilyUtils.java   
public static List<BlockHeader> getUnclesHeaders(@Nonnull  BlockStore store, long blockNumber, byte[] parentHash, int levels) {
    List<BlockHeader> uncles = new ArrayList<>();
    Set<ByteArrayWrapper> unclesHeaders = getUncles(store, blockNumber, parentHash, levels);

    for (ByteArrayWrapper uncleHash : unclesHeaders) {
        Block uncle = store.getBlockByHash(uncleHash.getData());

        if (uncle != null) {
            uncles.add(uncle.getHeader());
        }
    }

    return uncles;
}
项目:andbg    文件:PoolClassDef.java   
PoolClassDef(@Nonnull ClassDef classDef) {
    this.classDef = classDef;

    interfaces = new TypeListPool.Key<SortedSet<String>>(ImmutableSortedSet.copyOf(classDef.getInterfaces()));
    staticFields = ImmutableSortedSet.copyOf(classDef.getStaticFields());
    instanceFields = ImmutableSortedSet.copyOf(classDef.getInstanceFields());
    directMethods = ImmutableSortedSet.copyOf(
            Iterables.transform(classDef.getDirectMethods(), PoolMethod.TRANSFORM));
    virtualMethods = ImmutableSortedSet.copyOf(
            Iterables.transform(classDef.getVirtualMethods(), PoolMethod.TRANSFORM));
}
项目:GitHub    文件:BuilderMutableMethodImplementation.java   
@Nonnull
private BuilderInstruction51l newBuilderInstruction51l(@Nonnull Instruction51l instruction) {
    return new BuilderInstruction51l(
            instruction.getOpcode(),
            instruction.getRegisterA(),
            instruction.getWideLiteral());
}
项目:creacoinj    文件:DaemonThreadFactory.java   
@Override
public Thread newThread(@Nonnull Runnable runnable) {
    Thread thread = Executors.defaultThreadFactory().newThread(runnable);
    thread.setDaemon(true);
    if (name != null)
        thread.setName(name);
    return thread;
}
项目:GitHub    文件:ColumnIndices.java   
/**
 * Returns the {@link ColumnInfo} for the passed class.
 *
 * @param clazz the class for which to get the ColumnInfo.
 * @return the corresponding {@link ColumnInfo} object.
 * @throws io.realm.exceptions.RealmException if the class cannot be found in the schema.
 */
@Nonnull
public ColumnInfo getColumnInfo(Class<? extends RealmModel> clazz) {
    ColumnInfo columnInfo = classToColumnInfoMap.get(clazz);
    if (columnInfo == null) {
        columnInfo = mediator.createColumnInfo(clazz, osSchemaInfo);
        classToColumnInfoMap.put(clazz, columnInfo);
    }
    return columnInfo;
}
项目:andbg    文件:EncodedArrayItem.java   
@Nonnull
public static SectionAnnotator makeAnnotator(@Nonnull DexAnnotator annotator, @Nonnull MapItem mapItem) {
    return new SectionAnnotator(annotator, mapItem) {
        @Nonnull @Override public String getItemName() {
            return "encoded_array_item";
        }

        @Override
        protected void annotateItem(@Nonnull AnnotatedBytes out, int itemIndex, @Nullable String itemIdentity) {
            DexReader reader = dexFile.readerAt(out.getCursor());
            EncodedValue.annotateEncodedArray(out, reader);
        }
    };
}
项目:arez    文件:ArezContext.java   
/**
 * Return the map for components of specified type.
 *
 * @param type the component type.
 * @return the map for components of specified type.
 */
@Nonnull
private HashMap<Object, Component> getComponentByTypeMap( @Nonnull final String type )
{
  assert null != _components;
  return _components.computeIfAbsent( type, t -> new HashMap<>() );
}
项目:arez    文件:DuplicateRefMethodModel.java   
@Nonnull
@ComputedValueRef
public arez.ComputedValue getTimeComputedValue()
{
  throw new IllegalStateException();
}
项目:helper    文件:SingleHandlerList.java   
@Nonnull
@Override
SingleHandlerList<T> biConsumer(@Nonnull BiConsumer<SingleSubscription<T>, ? super T> handler);
项目:yadi    文件:SimpleRegistry.java   
public SimpleRegistry(@Nonnull final Map<String, ServiceDefinition<?>> serviceDefinitionMap) {
    this.serviceDefinitionMap = requireNonNull(serviceDefinitionMap);
}
项目:rskj    文件:NodeMessageHandler.java   
private void processBlockHashResponseMessage(@Nonnull final MessageChannel sender, @Nonnull final BlockHashResponseMessage message) {
    this.syncProcessor.processBlockHashResponse(sender, message);
}
项目:andbg    文件:TryBlockRewriter.java   
public RewrittenTryBlock(@Nonnull TryBlock<? extends ExceptionHandler> tryBlock) {
    this.tryBlock = tryBlock;
}
项目:SqlBuilder    文件:InputDataImpl.java   
InputDataImpl(@Nonnull String input) {
    prepare(input);
}
项目:McHeliPrivacyShield    文件:ClientProxy.java   
@Override
public void postInit(final @Nonnull FMLPostInitializationEvent event) {
    super.postInit(event);
}
项目:json2java4idea    文件:NewClassAction.java   
@Override
public void onCancel(@Nonnull NewClassDialog dialog) {
    dialog.cancel();
}