@Override public AWSCredentials getCredentials() { File credentials = new File(Objects.firstNonNull(H2O.OPT_ARGS.aws_credentials, DEFAULT_CREDENTIALS_LOCATION)); try { return new PropertiesCredentials(credentials); } catch (IOException e) { throw new AmazonClientException("Unable to load AWS credentials from file " + credentials); } }
public static JsonElement escape(JsonElement v) { if( v.isJsonObject() ) return escape(v.getAsJsonObject()); if( v.isJsonArray() ) return escape(v.getAsJsonArray()); return Objects.firstNonNull(SPECIAL.get(v), v); }
String version = Objects.firstNonNull(H2O.OPT_ARGS.hdfs_version, DEFAULT_HDFS_VERSION);
@Override public String getMessage() { return Objects.firstNonNull(super.getMessage(),"") + " " + FAILURE_MSG + failures; } }
@Override public String getMessage() { return Objects.firstNonNull(super.getMessage(), "") + " " + DISABLE_INDEX_ON_FAILURE_MSG + disableIndexOnFailure + ","; } }
@Override public String getMessage() { return Objects.firstNonNull(super.getMessage(), "") + " " + FAILED_MSG + "\n\t table: " + this.table + "\n\t edits: " + mutationsMsg + "\n\tcause: " + getCause() == null ? "UNKNOWN" : getCause().getMessage(); } }
public void setType(final Type type) { this.type = Objects.firstNonNull(type, this.type); } }
public static String getFullModuleKey(final String pluginKey, final String moduleKey) { if (pluginKey == null && moduleKey == null) { return StringUtils.EMPTY; } return pluginKey + Objects.firstNonNull(moduleKey, StringUtils.EMPTY); }
private String getRequestCharset() { String charset = Objects.firstNonNull(request.getHeader("Accept-Charset"), "UTF-8"); return charset.split(",")[0]; } }
public ConstantClassLoaderProvider(@Nullable ClassLoader classLoader) { this.classLoader = classLoader == null ? Objects.firstNonNull(Thread.currentThread().getContextClassLoader(), getClass().getClassLoader()) : classLoader; }
@Override public TopicMetadata getTopic(TopicId topicId) throws TopicNotFoundException, IOException { try { return topicCache.get(topicId); } catch (ExecutionException e) { Throwable cause = Objects.firstNonNull(e.getCause(), e); Throwables.propagateIfPossible(cause, TopicNotFoundException.class, IOException.class); throw Throwables.propagate(e.getCause()); } }
SystemDatasetInstantiator(DatasetFramework datasetFramework, @Nullable ClassLoader parentClassLoader, DatasetClassLoaderProvider classLoaderProvider, @Nullable Iterable<? extends EntityId> owners) { this.owners = owners; this.classLoaderProvider = classLoaderProvider; this.datasetFramework = datasetFramework; this.parentClassLoader = parentClassLoader == null ? Objects.firstNonNull(Thread.currentThread().getContextClassLoader(), getClass().getClassLoader()) : parentClassLoader; }
@Override public String toString() { return Objects.toStringHelper(this) .add("id", id) .add("type", type) .add("name", name) .add("description", description) .add("entities", "[" + firstNonNull(entities.size(), emptyList()) + "]") .toString(); } }
@Override protected T doNewComponent(SatisfiedBOM satisfiedBOM) { // in case the system property has been nullified, we return an empty string as value, rather than null // which would break the component building return (T) Objects.firstNonNull(System.getProperty(name.getName()), ""); } };
private Map<String, String> getFieldValues() { final ImmutableMap.Builder<String, String> builder = ImmutableMap.builder(); builder.put("jdbcHostname", Objects.firstNonNull(getJdbcHostname(), "")); builder.put("jdbcPort", Objects.firstNonNull(getJdbcPort(), "")); builder.put("jdbcDatabase", Objects.firstNonNull(getJdbcDatabase(), "")); builder.put("jdbcSid", Objects.firstNonNull(getJdbcSid(), "")); builder.put("jdbcUsername", Objects.firstNonNull(getJdbcUsername(), "")); builder.put("jdbcPassword", Objects.firstNonNull(getJdbcPassword(), "")); builder.put("schemaName", Objects.firstNonNull(getSchemaName(), "")); return builder.build(); }
@Override public L getAt(int index) { if (size != Integer.MAX_VALUE) { Preconditions.checkElementIndex(index, size()); } // else no check necessary, all index values are valid L existing = locks.get(index); if (existing != null) { return existing; } L created = supplier.get(); existing = locks.putIfAbsent(index, created); return firstNonNull(existing, created); }
@Override public void storePayload(StoreRequest request) throws TopicNotFoundException, IOException { try { TopicMetadata metadata = topicCache.get(request.getTopicId()); payloadTableWriterCache.get(request.getTopicId()).persist(request, metadata); } catch (ExecutionException e) { Throwable cause = Objects.firstNonNull(e.getCause(), e); Throwables.propagateIfPossible(cause, TopicNotFoundException.class, IOException.class); throw Throwables.propagate(e); } }
@Override public Optional<UserIdentity> getUserIdentityByKey(final String key) { return getUserIdentityByUsername(Objects.firstNonNull(mockUserKeyService.getUsernameForKey(key), key)); }
private void logWithTrace(HttpRequest request, Throwable t) { LOG.trace("Error in handling request={} {} for user={}:", request.method().name(), request.getUri(), Objects.firstNonNull(SecurityRequestContext.getUserId(), "<null>"), t); } }
private void logWithTrace(HttpRequest request, Throwable t) { LOG.trace("Error in handling request={} {} for user={}:", request.method().name(), request.uri(), Objects.firstNonNull(SecurityRequestContext.getUserId(), "<null>"), t); } })