當前位置: 首頁>>代碼示例>>Java>>正文


Java Nonnull類代碼示例

本文整理匯總了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();
}
 
開發者ID:VoxelGamesLib,項目名稱:VoxelGamesLibv2,代碼行數:19,代碼來源:Lang.java

示例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;
    };
}
 
開發者ID:n15g,項目名稱:spring-boot-gae,代碼行數:22,代碼來源:SearchRepository.java

示例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;
}
 
開發者ID:objectbox,項目名稱:objectbox-java,代碼行數:20,代碼來源:ReflectionCache.java

示例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();
}
 
開發者ID:OrdnanceSurvey,項目名稱:vt-support,代碼行數:22,代碼來源:StorageImpl.java

示例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;
}
 
開發者ID:jenkinsci,項目名稱:envinject-api-plugin,代碼行數:27,代碼來源:EnvVarsResolver.java

示例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;
                                                  });
                         });
}
 
開發者ID:commercetools,項目名稱:commercetools-sync-java,代碼行數:18,代碼來源:ProductSync.java

示例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);
    }
}
 
開發者ID:TeamNewPipe,項目名稱:NewPipeExtractor,代碼行數:27,代碼來源:YoutubeStreamExtractor.java

示例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;
}
 
開發者ID:gdrouet,項目名稱:nightclazz-graphql,代碼行數:23,代碼來源:SearchQuery.java

示例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());
    }
}
 
開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:19,代碼來源:AbstractChainedTask.java

示例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);
    }
}
 
開發者ID:zachbr,項目名稱:Debuggery,代碼行數:17,代碼來源:InputFormatter.java

示例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);
    }
}
 
開發者ID:lucko,項目名稱:helper,代碼行數:8,代碼來源:Configs.java

示例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);
}
 
開發者ID:shazam,項目名稱:reflow-animator,代碼行數:12,代碼來源:ReflowTextAnimatorHelper.java

示例13: toString

import javax.annotation.Nonnull; //導入依賴的package包/類
@Override
@Nonnull
public String toString() {
    return "GameDefinition{" +
            "gameMode=" + gameMode +
            ", minPlayers=" + minPlayers +
            ", maxPlayers=" + maxPlayers +
            ", phases=" + phases +
            ", gameData=" + gameData +
            '}';
}
 
開發者ID:VoxelGamesLib,項目名稱:VoxelGamesLibv2,代碼行數:12,代碼來源:GameDefinition.java

示例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;
}
 
開發者ID:elytra,項目名稱:Thermionics,代碼行數:16,代碼來源:CapabilityProvider.java

示例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;
}
 
開發者ID:t28hub,項目名稱:json2java4idea,代碼行數:11,代碼來源:Configuration.java


注:本文中的javax.annotation.Nonnull類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。