@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();
}
java类javax.annotation.Nonnull的实例源码
Lang.java 文件源码
项目:VoxelGamesLibv2
阅读 33
收藏 0
点赞 0
评论 0
SearchRepository.java 文件源码
项目:spring-boot-gae
阅读 35
收藏 0
点赞 0
评论 0
@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;
};
}
ReflectionCache.java 文件源码
项目:objectbox-java
阅读 23
收藏 0
点赞 0
评论 0
@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;
}
StorageImpl.java 文件源码
项目:vt-support
阅读 31
收藏 0
点赞 0
评论 0
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();
}
EnvVarsResolver.java 文件源码
项目:envinject-api-plugin
阅读 34
收藏 0
点赞 0
评论 0
/**
* 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;
}
ProductSync.java 文件源码
项目:commercetools-sync-java
阅读 36
收藏 0
点赞 0
评论 0
@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;
});
});
}
YoutubeStreamExtractor.java 文件源码
项目:NewPipeExtractor
阅读 40
收藏 0
点赞 0
评论 0
@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);
}
}
SearchQuery.java 文件源码
项目:nightclazz-graphql
阅读 41
收藏 0
点赞 0
评论 0
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;
}
AbstractChainedTask.java 文件源码
项目:Elasticsearch
阅读 30
收藏 0
点赞 0
评论 0
@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());
}
}
InputFormatter.java 文件源码
项目:Debuggery
阅读 26
收藏 0
点赞 0
评论 0
@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);
}
}
Configs.java 文件源码
项目:helper
阅读 37
收藏 0
点赞 0
评论 0
public static void gsonSave(@Nonnull File file, @Nonnull ConfigurationNode node) {
try {
gson(file).save(node);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
ReflowTextAnimatorHelper.java 文件源码
项目:reflow-animator
阅读 39
收藏 0
点赞 0
评论 0
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);
}
GameDefinition.java 文件源码
项目:VoxelGamesLibv2
阅读 34
收藏 0
点赞 0
评论 0
@Override
@Nonnull
public String toString() {
return "GameDefinition{" +
"gameMode=" + gameMode +
", minPlayers=" + minPlayers +
", maxPlayers=" + maxPlayers +
", phases=" + phases +
", gameData=" + gameData +
'}';
}
CapabilityProvider.java 文件源码
项目:Thermionics
阅读 24
收藏 0
点赞 0
评论 0
@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;
}
Configuration.java 文件源码
项目:json2java4idea
阅读 25
收藏 0
点赞 0
评论 0
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;
}
TextureCommands.java 文件源码
项目:VoxelGamesLibv2
阅读 46
收藏 0
点赞 0
评论 0
@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);
});
}
NumberUtils.java 文件源码
项目:lokalized-java
阅读 26
收藏 0
点赞 0
评论 0
/**
* 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;
}
AbstractOIDCEncoderParser.java 文件源码
项目:shibboleth-idp-oidc-extension
阅读 35
收藏 0
点赞 0
评论 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)));
}
}
IOHelper.java 文件源码
项目:pnc-repressurized
阅读 36
收藏 0
点赞 0
评论 0
/**
* 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;
}
Configs.java 文件源码
项目:helper
阅读 45
收藏 0
点赞 0
评论 0
@Nonnull
public static <T> ObjectMapper<T>.BoundInstance objectMapper(@Nonnull T object) {
try {
return ObjectMapper.forObject(object);
} catch (ObjectMappingException e) {
throw new RuntimeException(e);
}
}
OutputFormatter.java 文件源码
项目:Debuggery
阅读 27
收藏 0
点赞 0
评论 0
@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();
}
ComputedDescriptor.java 文件源码
项目:arez
阅读 30
收藏 0
点赞 0
评论 0
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 );
}
}
MetricStore.java 文件源码
项目:graphiak
阅读 35
收藏 0
点赞 0
评论 0
/**
* 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"));
}
BlockBloomeryFurnace.java 文件源码
项目:GardenStuff
阅读 34
收藏 0
点赞 0
评论 0
@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());
}
}
RecipeLanolinFactory.java 文件源码
项目:Lanolin
阅读 33
收藏 0
点赞 0
评论 0
@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;
}
FamilyUtils.java 文件源码
项目:rskj
阅读 24
收藏 0
点赞 0
评论 0
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.java 文件源码
项目:andbg
阅读 29
收藏 0
点赞 0
评论 0
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));
}
BuilderMutableMethodImplementation.java 文件源码
项目:GitHub
阅读 38
收藏 0
点赞 0
评论 0
@Nonnull
private BuilderInstruction51l newBuilderInstruction51l(@Nonnull Instruction51l instruction) {
return new BuilderInstruction51l(
instruction.getOpcode(),
instruction.getRegisterA(),
instruction.getWideLiteral());
}
DaemonThreadFactory.java 文件源码
项目:creacoinj
阅读 29
收藏 0
点赞 0
评论 0
@Override
public Thread newThread(@Nonnull Runnable runnable) {
Thread thread = Executors.defaultThreadFactory().newThread(runnable);
thread.setDaemon(true);
if (name != null)
thread.setName(name);
return thread;
}
ColumnIndices.java 文件源码
项目:GitHub
阅读 29
收藏 0
点赞 0
评论 0
/**
* 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;
}