本文整理汇总了Java中javax.annotation.Nonnull类的典型用法代码示例。如果您正苦于以下问题:Java Nonnull类的具体用法?Java Nonnull怎么用?Java Nonnull使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Nonnull类属于javax.annotation包,在下文中一共展示了Nonnull类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: legacyColors
import javax.annotation.Nonnull; //导入依赖的package包/类
@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();
}
示例2: saveAsync
import javax.annotation.Nonnull; //导入依赖的package包/类
@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;
};
}
示例3: getField
import javax.annotation.Nonnull; //导入依赖的package包/类
@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;
}
示例4: queryMetadata
import javax.annotation.Nonnull; //导入依赖的package包/类
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();
}
示例5: getCauseEnvVars
import javax.annotation.Nonnull; //导入依赖的package包/类
/**
* 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;
}
示例6: processBatch
import javax.annotation.Nonnull; //导入依赖的package包/类
@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;
});
});
}
示例7: onFetchPage
import javax.annotation.Nonnull; //导入依赖的package包/类
@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);
}
}
示例8: NearestAntennaFromFree3
import javax.annotation.Nonnull; //导入依赖的package包/类
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;
}
示例9: start
import javax.annotation.Nonnull; //导入依赖的package包/类
@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());
}
}
示例10: getUUID
import javax.annotation.Nonnull; //导入依赖的package包/类
@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);
}
}
示例11: gsonSave
import javax.annotation.Nonnull; //导入依赖的package包/类
public static void gsonSave(@Nonnull File file, @Nonnull ConfigurationNode node) {
try {
gson(file).save(node);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
示例12: drawLayerBounds
import javax.annotation.Nonnull; //导入依赖的package包/类
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);
}
示例13: toString
import javax.annotation.Nonnull; //导入依赖的package包/类
@Override
@Nonnull
public String toString() {
return "GameDefinition{" +
"gameMode=" + gameMode +
", minPlayers=" + minPlayers +
", maxPlayers=" + maxPlayers +
", phases=" + phases +
", gameData=" + gameData +
'}';
}
示例14: provide
import javax.annotation.Nonnull; //导入依赖的package包/类
@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;
}
示例15: Configuration
import javax.annotation.Nonnull; //导入依赖的package包/类
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;
}