本文整理汇总了Java中com.google.api.client.util.Strings.isNullOrEmpty方法的典型用法代码示例。如果您正苦于以下问题:Java Strings.isNullOrEmpty方法的具体用法?Java Strings.isNullOrEmpty怎么用?Java Strings.isNullOrEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.api.client.util.Strings
的用法示例。
在下文中一共展示了Strings.isNullOrEmpty方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newBaseOperation
import com.google.api.client.util.Strings; //导入方法依赖的package包/类
private static Operation.Builder newBaseOperation(String logName, int responseCode) {
Operation.Builder res = Operation
.newBuilder()
.setConsumerId("api_key:" + TEST_API_KEY)
.setImportance(Importance.LOW)
.setOperationId(TEST_OPERATION_ID)
.setOperationName(TEST_OPERATION_NAME)
.setEndTime(REALLY_EARLY)
.setStartTime(REALLY_EARLY)
.putLabels(OperationInfo.SCC_USER_AGENT, "ESP")
.putLabels(OperationInfo.SCC_SERVICE_AGENT, KnownLabels.SERVICE_AGENT)
.putLabels(KnownLabels.SCC_PLATFORM.getName(), "Unknown");
if (!Strings.isNullOrEmpty(logName)) {
res.addLogEntries(newTestLogEntry(logName, responseCode));
}
return res;
}
示例2: start
import com.google.api.client.util.Strings; //导入方法依赖的package包/类
/**
* Starts the server, which will listen to the given path going forward.
* @throws Exception
*/
public void start() throws Exception {
logger.info("Starting API server on {}:{}{}", HOST, port, contextPath);
server = new Server();
server.addListener(String.format("%s:%d", HOST, port));
ServletHttpContext context = (ServletHttpContext) server.getContext(contextPath);
context.addServlet(SERVLET_NAME, SERVLET_PATH, ServletContainer.class.getName());
context.getServletHandler().getServletHolder(SERVLET_NAME)
.setInitParameter(INIT_PARAM_PACKAGES, getClass().getPackage().getName());
if (!Strings.isNullOrEmpty(adsPropertiesPath)) {
context.getServletHandler().getServletHolder(SERVLET_NAME)
.setInitParameter(INIT_PARAM_ADS_PROPERTIES, adsPropertiesPath);
}
if (!Strings.isNullOrEmpty(propertiesPath)) {
context.getServletHandler().getServletHolder(SERVLET_NAME)
.setInitParameter(INIT_PARAM_PROPERTIES, propertiesPath);
}
server.start();
}
示例3: checkIssuerAudiences
import com.google.api.client.util.Strings; //导入方法依赖的package包/类
private static String checkIssuerAudiences(
ApiIssuerConfigs issuerConfigs, ApiIssuerAudienceConfig issuerAudiences) {
if (!issuerAudiences.isEmpty()) {
return null;
}
for (Map.Entry<String, Collection<String>> entry : issuerAudiences.asMap().entrySet()) {
if (!issuerConfigs.hasIssuer(entry.getKey())) {
return "cannot specify audiences for unknown issuer '" + entry.getKey() + "'";
}
for (String audience : entry.getValue()) {
if (Strings.isNullOrEmpty(audience)) {
return "issuer '" + entry.getKey() + "' cannot have null or blank audiences";
}
}
}
return null;
}
示例4: retrieveReferenceBases
import com.google.api.client.util.Strings; //导入方法依赖的package包/类
private String retrieveReferenceBases(Genomics genomics, Annotation annotation) throws IOException {
StringBuilder b = new StringBuilder();
String pageToken = "";
while (true) {
// TODO: Support full request parameterization for Paginator.References.Bases.
ListBasesResponse response = genomics.references().bases()
.list(annotation.getReferenceId())
.setStart(annotation.getStart())
.setEnd(annotation.getEnd())
.setPageToken(pageToken)
.execute();
b.append(response.getSequence());
pageToken = response.getNextPageToken();
if (Strings.isNullOrEmpty(pageToken)) {
break;
}
}
return b.toString();
}
示例5: attemptAuthentication
import com.google.api.client.util.Strings; //导入方法依赖的package包/类
@Override
public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) {
final String authToken = request.getHeader(TOKEN_HEADER);
if (Strings.isNullOrEmpty(authToken)) {
throw new RuntimeException("Invaild auth token");
}
return getAuthenticationManager().authenticate(new FirebaseAuthenticationToken(authToken));
}
示例6: requireParam
import com.google.api.client.util.Strings; //导入方法依赖的package包/类
/**
* Tests if a URL parameter is empty and throws an exception if that's the case. Empty here means
* either <code>null</code>, an empty string or and empty list.
*/
private static void requireParam(String name, Object value) throws KeywordOptimizerException {
if (value == null
|| (value instanceof Collection<?> && ((Collection<?>) value).isEmpty())
|| (value instanceof String && Strings.isNullOrEmpty((String) value))) {
throw new KeywordOptimizerException("Parameter '" + name + "' is required");
}
}
示例7: checkIssuers
import com.google.api.client.util.Strings; //导入方法依赖的package包/类
private static String checkIssuers(ApiIssuerConfigs issuers) {
if (!issuers.isSpecified()) {
return null;
}
for (IssuerConfig issuer : issuers.asMap().values()) {
if (Strings.isNullOrEmpty(issuer.getName())) {
return "issuer name cannot be blank";
} else if (Strings.isNullOrEmpty(issuer.getIssuer())) {
return "issuer '" + issuer.getName() + "' cannot have a blank issuer value";
}
}
return null;
}
示例8: adapt
import com.google.api.client.util.Strings; //导入方法依赖的package包/类
/**
* <p>Adapt a single instance of an HBase {@link HColumnDescriptor} to
* an instance of {@link com.google.bigtable.admin.table.v1.ColumnFamily.Builder}.</p>
*
* <p>NOTE: This method does not set the name of the ColumnFamily.Builder. The assumption is
* that the CreateTableRequest or CreateColumFamilyRequest takes care of the naming. As of now
* (3/11/2015), the server insists on having a blank name.</p>
*/
public ColumnFamily.Builder adapt(HColumnDescriptor columnDescriptor) {
throwIfRequestingUnknownFeatures(columnDescriptor);
throwIfRequestingUnsupportedFeatures(columnDescriptor);
ColumnFamily.Builder resultBuilder = ColumnFamily.newBuilder();
String gcExpression = buildGarbageCollectionExpression(columnDescriptor);
if (!Strings.isNullOrEmpty(gcExpression)) {
resultBuilder.setGcExpression(gcExpression);
}
return resultBuilder;
}
示例9: AppEngineLocationSelectorItem
import com.google.api.client.util.Strings; //导入方法依赖的package包/类
public AppEngineLocationSelectorItem(@NotNull Location location) {
this.location = location;
// TODO(alexsloan) when b/33458530 is addressed, we can just use location.getLocationId()
String locationIdLabel =
location.getLabels() != null
? location.getLabels().get("cloud.googleapis.com/region")
: null;
if (Strings.isNullOrEmpty(location.getLocationId())
&& !Strings.isNullOrEmpty(locationIdLabel)) {
location.setLocationId(locationIdLabel);
}
}
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-intellij,代码行数:14,代码来源:AppEngineLocationSelectorItem.java
示例10: processElement
import com.google.api.client.util.Strings; //导入方法依赖的package包/类
@ProcessElement
public void processElement(DoFn<String, String>.ProcessContext c) throws Exception {
String readGroupSetId = c.element();
String referenceSetId = GenomicsUtils.getReferenceSetId(readGroupSetId, auth);
if (Strings.isNullOrEmpty(referenceSetId)) {
throw new IllegalArgumentException("No ReferenceSetId associated with ReadGroupSetId "
+ readGroupSetId
+ ". All ReadGroupSets in given input must have an associated ReferenceSet.");
}
if (!referenceSetIdForAllReadGroupSets.equals(referenceSetId)) {
throw new IllegalArgumentException("ReadGroupSets in given input must all be associated with"
+ " the same ReferenceSetId : " + referenceSetId);
}
c.output(readGroupSetId);
}
示例11: filter
import com.google.api.client.util.Strings; //导入方法依赖的package包/类
/**
* Matches Google Cloud Storage's delimiter filtering.
*
* @param items the mutable list of items to filter. Items matching the filter conditions will be
* removed from this list.
* @param bucketName the bucket name to filter for.
* @param prefix the object name prefix to filter for.
* @param delimiter the delimiter to filter on.
*/
private void filter(
List<GoogleCloudStorageItemInfo> items,
String bucketName,
@Nullable String prefix,
@Nullable String delimiter) {
prefix = prefix == null ? "" : prefix;
if (Strings.isNullOrEmpty(delimiter)) {
return;
}
HashSet<String> dirs = new HashSet<String>();
Iterator<GoogleCloudStorageItemInfo> itr = items.iterator();
while (itr.hasNext()) {
String objectName = itr.next().getObjectName();
// Remove if doesn't start with the prefix.
if (!objectName.startsWith(prefix)) {
itr.remove();
} else {
// Retain if missing the delimiter after the prefix.
int firstIndex = objectName.indexOf(delimiter, prefix.length());
if (firstIndex != -1) {
// Remove if the first occurrence of the delimiter after the prefix isn't the last.
// Remove if the last occurrence of the delimiter isn't the end of the string.
int lastIndex = objectName.lastIndexOf(delimiter);
if (firstIndex != lastIndex) {
itr.remove();
dirs.add(objectName.substring(0, firstIndex + 1));
} else if (lastIndex != objectName.length() - 1) {
itr.remove();
dirs.add(objectName.substring(0, firstIndex + 1));
}
}
}
}
if (inferImplicitDirectoriesEnabled) {
for (String dir : dirs) {
items.add(
GoogleCloudStorageImpl.createItemInfoForInferredDirectory(
new StorageResourceId(bucketName, dir)));
}
}
}
开发者ID:GoogleCloudPlatform,项目名称:bigdata-interop,代码行数:53,代码来源:PerformanceCachingGoogleCloudStorage.java
示例12: hasPermission
import com.google.api.client.util.Strings; //导入方法依赖的package包/类
@PreAuthorize("hasRole('ROLE_ADMIN') or hasPermission(#groupCode, 'users_create')")
@RequestMapping(value = "/{groupCode}/users", method = RequestMethod.POST)
public List<CreateUsersView> createUsers(@PathVariable("groupCode") String groupCode,
@RequestParam(value = "preview", required = false) Boolean preview,
@RequestBody String usersInfo) throws FormException {
final ArrayList<CreateUsersView> usersViews = new ArrayList<>();
final ArrayList<String> wrongLines = new ArrayList<>();
for (final String line : usersInfo.split("\\r?\\n")) {
final CreateUsersView teamView = new CreateUsersView();
for (final String part : line.split("(?<=[^\\\\]);")) {
String cleanPart = part.trim().replaceAll("\\\\;", ";");
if (cleanPart.startsWith("@TAG:")) {
final String tags = cleanPart.replace("@TAG:", "").trim();
teamView.getTags().addAll(Arrays.asList(tags.split(" +")));
} else if (Strings.isNullOrEmpty(teamView.getName())) {
teamView.setName(cleanPart);
} else {
teamView.getUsers().add(cleanPart);
}
}
if (Strings.isNullOrEmpty(teamView.getName()) || teamView.getUsers().isEmpty()) {
wrongLines.add(line);
} else {
final int lastIndex = teamView.getUsers().size() - 1;
teamView.setCode(teamPrefix + teamView.getUsers().get(lastIndex));
teamView.getUsers().remove(lastIndex);
usersViews.add(teamView);
}
}
if (!wrongLines.isEmpty()) {
throw new FormException().addError("usersdata", wrongLines.stream().collect(Collectors.joining("\n")));
}
if (preview == null || !preview) {
return groupsDao.createUsersForGroup(groupCode, usersViews);
}
return usersViews;
}