/** * Determines if an entity is referenced by this field or not. * <p> * This is not be confused with {@link #isValueLoaded()} which indicates if the value has already been * loaded from the database. * * @return <tt>true</tt> if an entity is referenced, <tt>false</tt> otherwise */ public boolean isFilled() { return Strings.isFilled(id); }
/** * Determines if an appropriate configuration is available (e.g. a host to connect to). * * @return <tt>true</tt> if a configuration is present, <tt>false</tt> otherwise */ public boolean isConfigured() { return Strings.isFilled(hosts); }
/** * Determines if access to Mongo DB is configured by checking if a host is given. * * @return <tt>true</tt> if access to Mongo DB is configured, <tt>false</tt> otherwise */ public boolean isConfigured() { return Strings.isFilled(dbHosts); }
/** * Sets the current language for the current thread. * <p> * If <tt>null</tt> or an empty string is passed in, the language will not be changed. * </p> * * @param lang the two-letter language code for this thread. */ public void setLang(@Nullable String lang) { if (Strings.isFilled(lang)) { this.lang = lang; this.lazyLanguageInstaller = null; } }
private String detectLogging(String query) { if (Strings.isFilled(query) && query.startsWith("?")) { logQuery = true; return query.substring(1); } return query; }
/** * Checks whether a node or non-empty content is reachable via the given * XPath. * * @param path the xpath to be checked * @return <tt>true</tt> if a node or non empty property was found, <tt>false</tt> otherwise * @throws IllegalArgumentException if an invalid xpath was given */ public boolean isFilled(String path) { return Strings.isFilled(queryString(path)); }
protected Schema(IndexAccess access) { this.access = access; indexPrefix = Sirius.getSettings().getString("index.prefix"); if (indexPrefix.contains("${timestamp}")) { temporaryIndexPrefix = true; indexPrefix = indexPrefix.replace("${timestamp}", String.valueOf(System.currentTimeMillis())); IndexAccess.LOG.INFO("Using unique index prefix: %s", indexPrefix); } if (Strings.isFilled(indexPrefix) && !indexPrefix.endsWith("-")) { indexPrefix = indexPrefix + "-"; } }
@Override public SpanQueryBuilder createSpanQuery() { if (value instanceof String && Strings.isFilled(value)) { return QueryBuilders.spanTermQuery(field, (String) value).boost(boost); } return null; }
private boolean isEnabled() { return Strings.isFilled(Sirius.getSettings().getString("index.host")); }
/** * Adds a textual query across all searchable fields using Lucene syntax. * <p> * Consider using {@link #query(String)} which supports most of the Lucene syntax but will never fail for * a query. * * @param query the query to search for. Does actually support the complete Lucene query syntax like * {@code field:value OR field2:value1} * @return the query itself for fluent method calls */ public Query<E> directQuery(String query) { if (Strings.isFilled(query)) { where(QueryString.query(query)); } return this; }
@Override public QueryBuilder createQuery() { if (Strings.isFilled(value)) { return QueryBuilders.prefixQuery(field, value).rewrite("top_terms_256").boost(boost); } return null; }
private String determineLocalRouting(EntityDescriptor descriptor, Property entityRef) { String routingField = entityRef.getField().getAnnotation(RefType.class).localRouting(); if (Strings.isFilled(routingField)) { return (String) descriptor.getProperty(routingField).writeToSource(this); } return null; }
private ProjectName projectName() { return Strings.isFilled(project) && !Sirius.isStartedAsTest() ? ProjectName.fromString(project) : ProjectName.random(); }
@Override public void execute(Output output, String... params) throws Exception { if (params.length == 1 && Strings.isFilled(params[0])) { parseParameters(output, params[0]); } else { if (Microtiming.isEnabled()) { generateOutput(output); } else { output.line("Microtiming is disabled! Use: 'timing +' to enable."); } } }
private String computeMessage() { if (Strings.isFilled(systemErrorMessage)) { // Generate system error message and prefix with translated info about the system error return NLS.fmtr("HandledException.systemError") .set("error", Strings.apply(systemErrorMessage, extendParams(ex, systemErrorMessageParams))) .format(); } else { // Add exception infos set("errorMessage", ex == null ? NLS.get("HandledException.unknownError") : ex.getMessage()); set("errorClass", ex == null ? "UnknownError" : ex.getClass().getName()); // Format resulting error message return NLS.fmtr(key).set(params).format(); } }
@Override public void addMappingProperties(XContentBuilder builder) throws IOException { super.addMappingProperties(builder); if (Strings.isFilled(getIndexOptions())) { builder.field("index_options", getIndexOptions()); } if (isAnalyzed() && Strings.isFilled(getAnalyzer())) { builder.field("analyzer", getAnalyzer()); } if (isNormsEnabled() != ESOption.ES_DEFAULT) { builder.field("norms", isNormsEnabled()); } } }
private void rejectDeleteIfNecessary(Entity entity) { if (index.select(getLocalClass()) .eq(getName(), entity.getId()) .autoRoute(field.getName(), entity.getId()) .exists()) { throw Exceptions.createHandled() .withNLSKey(Strings.isFilled(refType.onDeleteErrorMsg()) ? refType.onDeleteErrorMsg() : "ForeignKey.restricted") .handle(); } }
private Tuple<String, Integer> parsePort(Tuple<String, String> hostnameAndPort) { if (Strings.isFilled(hostnameAndPort.getSecond())) { try { return Tuple.create(hostnameAndPort.getFirst(), Integer.parseInt(hostnameAndPort.getSecond())); } catch (NumberFormatException e) { Exceptions.handle() .to(LOG) .withSystemErrorMessage("Invalid port in 'elasticsearch.hosts': %s %s", hostnameAndPort.getFirst(), hostnameAndPort.getSecond()) .handle(); } } return Tuple.create(hostnameAndPort.getFirst(), DEFAULT_HTTP_PORT); }