@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(); }
@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; }; }
@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; }
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(); }
/** * 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; }
@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; }); }); }
@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); } }
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; }
@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()); } }
@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); } }
public static void gsonSave(@Nonnull File file, @Nonnull ConfigurationNode node) { try { gson(file).save(node); } catch (IOException e) { throw new RuntimeException(e); } }
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); }
@Override @Nonnull public String toString() { return "GameDefinition{" + "gameMode=" + gameMode + ", minPlayers=" + minPlayers + ", maxPlayers=" + maxPlayers + ", phases=" + phases + ", gameData=" + gameData + '}'; }
@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; }
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; }
@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); }); }
/** * 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; }
/** {@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))); } }
/** * 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; }
@Nonnull public static <T> ObjectMapper<T>.BoundInstance objectMapper(@Nonnull T object) { try { return ObjectMapper.forObject(object); } catch (ObjectMappingException e) { throw new RuntimeException(e); } }
@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(); }
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 ); } }
/** * 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")); }
@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()); } }
@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; }
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; }
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)); }
@Nonnull private BuilderInstruction51l newBuilderInstruction51l(@Nonnull Instruction51l instruction) { return new BuilderInstruction51l( instruction.getOpcode(), instruction.getRegisterA(), instruction.getWideLiteral()); }
@Override public Thread newThread(@Nonnull Runnable runnable) { Thread thread = Executors.defaultThreadFactory().newThread(runnable); thread.setDaemon(true); if (name != null) thread.setName(name); return thread; }
/** * 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; }
@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); } }; }
/** * 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<>() ); }
@Nonnull @ComputedValueRef public arez.ComputedValue getTimeComputedValue() { throw new IllegalStateException(); }
@Nonnull @Override SingleHandlerList<T> biConsumer(@Nonnull BiConsumer<SingleSubscription<T>, ? super T> handler);
public SimpleRegistry(@Nonnull final Map<String, ServiceDefinition<?>> serviceDefinitionMap) { this.serviceDefinitionMap = requireNonNull(serviceDefinitionMap); }
private void processBlockHashResponseMessage(@Nonnull final MessageChannel sender, @Nonnull final BlockHashResponseMessage message) { this.syncProcessor.processBlockHashResponse(sender, message); }
public RewrittenTryBlock(@Nonnull TryBlock<? extends ExceptionHandler> tryBlock) { this.tryBlock = tryBlock; }
InputDataImpl(@Nonnull String input) { prepare(input); }
@Override public void postInit(final @Nonnull FMLPostInitializationEvent event) { super.postInit(event); }
@Override public void onCancel(@Nonnull NewClassDialog dialog) { dialog.cancel(); }