@Override public boolean apply( String t ) { return !Strings.isNullOrEmpty( t ); } }
/** * Construct from Google Books model */ public BookDetails(Volume vol) { Volume.VolumeInfo info = vol.getVolumeInfo(); subtitle = info.getSubtitle(); description = info.getDescription(); if (info.getImageLinks() != null) { String full = info.getImageLinks().getLarge(); if (Strings.isNullOrEmpty(full)) { full = info.getImageLinks().getSmallThumbnail(); } fullPicture = full; } else { fullPicture = null; } if (vol.getSaleInfo() != null) { purchaseUrl = vol.getSaleInfo().getBuyLink(); } else { purchaseUrl = null; } this.publisher = info.getPublisher(); this.publishedDate = info.getPublishedDate(); String preview = info.getPreviewLink(); if (Strings.nullToEmpty(preview).equals(Strings.nullToEmpty(purchaseUrl))) { // No need to repeat the same. preview = null; } this.previewUrl = preview; }
@Override public void init(ServletConfig config) { logger.info("Initializing ..."); sctx = config.getServletContext(); componentPrefix = Strings.nullToEmpty(config.getInitParameter("componentPrefix")); logger.info("Initialized"); } }
public String createTimeline() throws IOException { TimelineCreateResponse timelineCreateResponse = makeRequest( ImmutableMap.of("method", RememberTheMilkMethods.TIMELINES_CREATE.getMethodName()), TimelineCreateResponse.class); checkState(!Strings.isNullOrEmpty(timelineCreateResponse.timeline)); return timelineCreateResponse.timeline; }
/** * Performs all necessary setup steps for running requests against the API. * * @param applicationName the name of the application: com.example.app * @param serviceAccountEmail the Service Account Email (empty if using * installed application) * @return the {@Link AndroidPublisher} service * @throws GeneralSecurityException * @throws IOException */ public static AndroidPublisher init( String applicationName, @Nullable String serviceAccountEmail ) throws IOException, GeneralSecurityException { Preconditions.checkArgument( !Strings.isNullOrEmpty( applicationName ), "applicationName cannot be null or empty!" ); // Authorization. newTrustedTransport(); Credential credential; credential = authorizeWithServiceAccount( serviceAccountEmail ); // Set up and return API client. return new AndroidPublisher.Builder( httpTransport, JSON_FACTORY, credential ).setApplicationName( applicationName ) .build(); }
@Override protected Icon getSetIcon(boolean isMuted) { if (!Strings.isNullOrEmpty(errorMessage)) { return StackdriverDebuggerIcons.CLOUD_BREAKPOINT_ERROR; } if (isVerified) { return StackdriverDebuggerIcons.CLOUD_BREAKPOINT_CHECKED; } return StackdriverDebuggerIcons.CLOUD_BREAKPOINT; }
/** * Adds a child item to be pushed * * @param id for item to be pushed * @param item {@link PushItem} to be pushed */ public Builder addChildId(String id, PushItem item) { checkArgument(!Strings.isNullOrEmpty(id), "id can not be null"); this.childIds.put(id, checkNotNull(item, "item can not be null")); return this; }
@Override public void onClick(View v) { try { if (!Strings.isNullOrEmpty(purchaseUrl)) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(purchaseUrl)); startActivity(browserIntent); } } catch (Exception e) { Log.d(TAG, "Broken purchase URL " + purchaseLink); } } });
@Override public void onClick(View v) { try { Log.i(TAG, "Preview "+previewUrl); if (!Strings.isNullOrEmpty(previewUrl)) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(previewUrl)); startActivity(browserIntent); } } catch (Exception e) { Log.d(TAG, "Broken preview URL " + previewUrl); } } });
public boolean hasError() { return !Strings.isNullOrEmpty(getErrorMessage()); }
@Nullable private static CredentialedUser getUserFromEmail(@Nullable String email) { if (Strings.isNullOrEmpty(email)) { return null; } for (CredentialedUser user : Services.getLoginService().getAllUsers().values()) { if (email != null && email.equalsIgnoreCase(user.getEmail())) { return user; } } return null; }
public PubsubAcknowledgement(GooglePubsubEndpoint endpoint) { super(); this.endpoint = endpoint; this.subscriptionFullName = String.format("projects/%s/subscriptions/%s", endpoint.getProjectId(), endpoint.getDestinationName()); String loggerId = endpoint.getLoggerId(); if (Strings.isNullOrEmpty(loggerId)) { loggerId = this.getClass().getName(); } logger = LoggerFactory.getLogger(loggerId); }
/** This is a helper routine that converts a server {@link StatusMessage} to descriptive text. */ @Nullable public static String getUserErrorMessage(@Nullable StatusMessage statusMessage) { if (statusMessage == null || !Boolean.TRUE.equals(statusMessage.getIsError())) { return null; } String errorDescription = getUserMessage(statusMessage); return !Strings.isNullOrEmpty(errorDescription) ? errorDescription : StackdriverDebuggerBundle.getString("clouddebug.fallbackerrormessage"); }
public void afterPropertiesSet() throws Exception { if (Strings.isNullOrEmpty(loggerId)) { log = LoggerFactory.getLogger(this.getClass().getName()); } else { log = LoggerFactory.getLogger(loggerId); } // Default pubsub connection. // With the publisher endpoints - the main publisher // with the consumer endpoints - the ack client pubsub = getConnectionFactory().getDefaultClient(); log.trace("Credential file location : {}", getConnectionFactory().getCredentialsFileLocation()); log.trace("Project ID: {}", this.projectId); log.trace("Destination Name: {}", this.destinationName); }
private static boolean isSourceLocationValid(SourceLocation sourceLocation) { if (sourceLocation == null) { return false; } if (Strings.isNullOrEmpty(sourceLocation.getPath())) { return false; } if (sourceLocation.getLine() == null) { return false; } return true; }
@Override public void computePresentation(@NotNull XValueNode node, @NotNull XValuePlace place) { String status = BreakpointUtil.getUserMessage(variable.getStatus()); String value = !Strings.isNullOrEmpty(status) ? String.format("%s (%s)", variable.getValue(), status) : variable.getValue(); node.setPresentation( null, members != null && members.size() > 0 ? "..." : null, value != null ? value : "", members != null && members.size() > 0); }
/** Returns the currently selected user. */ @NotNull public String getSelectedUser() { if (!Strings.isNullOrEmpty(selectedUser)) { return selectedUser; } return login.getSelectedUser() != null ? login.getSelectedUser().getEmail() : ""; }
private void updateRepositorySelector(@NotNull CloudProject selectedProject) { if (defaultDirectoryName.equals(directoryName.getText()) || directoryName.getText().length() == 0) { // modify field if it was unmodified or blank String projectDescription = selectedProject.projectName(); if (!Strings.isNullOrEmpty(projectDescription)) { defaultDirectoryName = projectDescription.replaceAll(INVALID_FILENAME_CHARS, ""); defaultDirectoryName = defaultDirectoryName.replaceAll("\\s", ""); } else { defaultDirectoryName = ""; } directoryName.setText(defaultDirectoryName); } repositorySelector.setCloudProject(selectedProject); repositorySelector.setText(""); repositorySelector.loadRepositories(); updateButtons(); }
GooglePubsubConsumer(GooglePubsubEndpoint endpoint, Processor processor) throws Exception { super(endpoint, processor); this.endpoint = endpoint; this.processor = processor; this.ackStrategy = new ExchangeAckTransaction(this.endpoint); pubsub = endpoint.getConnectionFactory().getMultiThreadClient(this.endpoint.getConcurrentConsumers()); String loggerId = endpoint.getLoggerId(); if (Strings.isNullOrEmpty(loggerId)) { loggerId = this.getClass().getName(); } localLog = LoggerFactory.getLogger(loggerId); }
public static AndroidPublisher init(Context context, String fileName) throws IOException { Preconditions.checkArgument(!Strings.isNullOrEmpty(context.getPackageName()), "applicationId cannot be null or empty!"); newTrustedTransport(); GoogleCredential credential = GoogleCredential.fromStream(context.getAssets().open(fileName), HTTP_TRANSPORT, JSON_FACTORY); credential = credential.createScoped(Collections.singleton(AndroidPublisherScopes.ANDROIDPUBLISHER)); return new AndroidPublisher.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential) .setApplicationName(context.getPackageName()) .build(); }