@Override public String toString() { if (mode == Mode.CALL_BASED) { return Strings.apply("Every %d calls: %d to go...", interval, state); } long delta = interval - (System.currentTimeMillis() - state); if (delta > 0) { return Strings.apply("Every %d ms: %d ms to go...", interval, delta); } else { return Strings.apply("Every %d ms: Ready to go...", interval); } } }
/** * Writes a debug message to the monitor. * <p> * If no monitor is available, the <tt>async</tt> logger will be used. * * @param message the message to log * @param args the parameters used to format the message (see {@link Strings#apply(String, Object...)}) */ public void trace(String message, Object... args) { adapter.trace(Strings.apply(message, args)); }
private void processCharacterWithoutQuotation(char currentChar, StringBuilder effectiveValue) { if (currentChar == separator) { if (isEscapeEmpty) { throw new IllegalArgumentException(Strings.apply( "Cannot output a column which contains the separator character '%s' " + "without an escape or quotation character.", separator)); } else { effectiveValue.append(escape).append(currentChar); } } else if (currentChar == '\r' || currentChar == '\n') { throw new IllegalArgumentException( "Cannot output a column which contains a line break without an quotation character."); } else { effectiveValue.append(currentChar); } }
/** * Sets the new state of the current task. * * @param newState the message to set as state * @param args the parameters used to format the state message (see {@link Strings#apply(String, Object...)}) */ public void setState(String newState, Object... args) { adapter.setState(Strings.apply(newState, args)); }
private Block endBlock(List<Block> blocks, Block currentBlock, int index) { if (blocks.size() == 1) { throw new IllegalArgumentException(Strings.apply("Unexpected ']' at index %d in '%s'", index + 1, pattern)); } if (currentBlock.replacementFound) { Block next = blocks.get(blocks.size() - 2); next.output.append(currentBlock.output); next.replacementFound = true; } currentBlock = blocks.get(blocks.size() - 2); blocks.remove(blocks.size() - 1); return currentBlock; }
@Override public <P> P findPart(String uniqueName, Class<P> clazz) { P part = getPart(uniqueName, clazz); if (part == null) { throw new NoSuchElementException(Strings.apply("Cannot find %s of type %s", uniqueName, clazz.getName())); } return part; }
@SuppressWarnings("unchecked") @Override public <A> A as(@Nonnull Class<A> adapterType) { if (adapterType.isAssignableFrom(source.getClass())) { return (A) this; } return tryAs(adapterType).orElseThrow(() -> { return new IllegalArgumentException(Strings.apply("Cannot transform %s into %s", getClass().getName(), adapterType.getName())); }); }
private <T> T continueCoerceWithConversion(Class<T> targetClazz, T defaultValue) { if (data instanceof String) { try { return NLS.parseMachineString(targetClazz, data.toString().trim()); } catch (Exception e) { Exceptions.ignore(e); return defaultValue; } } throw new IllegalArgumentException(Strings.apply("Cannot convert '%s' to target class: %s ", data, targetClazz)); }
/** * Formats the given message at the WARN level using the supplied parameters. * <p> * The WARN level can be used to signal unexpected situations which do not (yet) result in an error or problem. * * @param msg the message containing placeholders as understood by {@link Strings#apply(String, Object...)} * @param params the parameters used to format the resulting log message */ public void WARN(String msg, Object... params) { msg = Strings.apply(msg, params); fixMDC(); logger.warn(msg); tap(msg, true, Level.WARN); }
@Override public String toString() { return Strings.apply("%s (%d/%d)", name, getNumActive(), getSize()); } }
/** * Formats the given message at the INFO level using the supplied parameters. * <p> * The INFO level should be used for informative messages to the system operator which occur at a low rate * * @param msg the message containing placeholders as understood by {@link Strings#apply(String, Object...)} * @param params the parameters used to format the resulting log message */ public void INFO(String msg, Object... params) { msg = Strings.apply(msg, params); if (logger.isInfoEnabled()) { fixMDC(); logger.info(msg); tap(msg, true, Level.INFO); } else { tap(msg, false, Level.INFO); } }
/** * Formats the given message at the FINE level using the supplied parameters. * <p> * The FINE level can be used for in depth debug or trace messages used when developing a system. * Sill the rate should be kept bearable to enable this level in production systems to narrow down errors. * * @param msg the message containing placeholders as understood by {@link Strings#apply(String, Object...)} * @param params the parameters used to format the resulting log message */ public void FINE(String msg, Object... params) { msg = Strings.apply(msg, params); if (logger.isDebugEnabled()) { fixMDC(); logger.debug(msg); tap(msg, true, Level.DEBUG); } else { tap(msg, false, Level.DEBUG); } }
/** * Returns the property for the given column. * * @param column the name of the property given as column * @return the property which belongs to the given column */ public Property getProperty(Mapping column) { if (column.getParent() != null) { throw new IllegalArgumentException(Strings.apply("Cannot fetch joined property: %s", column)); } return getProperty(column.getName()); }
@Override public String toString() { return Strings.apply("%s - Active: %d, Queued: %d, Executed: %d, Blocked: %d, Rejected: %d", category, getActiveCount(), getQueue().size(), executed.getCount(), blocked.getCount(), dropped.getCount()); }
/** * Loads all properties from the fields being present in the target type. */ protected void initialize() { addFields(this, AccessPath.IDENTITY, type, p -> { if (properties.containsKey(p.getName())) { Mixing.LOG.SEVERE(Strings.apply( "A property named '%s' already exists for the type '%s'. Skipping redefinition: %s", p.getName(), type.getSimpleName(), p.getDefinition())); } else { properties.put(p.getName(), p); } }); }
private String getIntType(TableColumn column) { if (column.getLength() == 1) { return "Int8"; } else if (column.getLength() == 2) { return "Int16"; } else if (column.getLength() == 4) { return "Int32"; } else { throw new IllegalArgumentException(Strings.apply("Property: %s has an invalid length for an int type (%s)!", column.getSource(), column.getLength())); } }
/** * Returns a detailed description of the version of this module * * @return a string containing the version, build number and VCS tag of this module */ public String getDetails() { return Strings.apply("Version: %s, Build: %s (%s), Revision: %s", fix(version, "DEV"), fix(build, "-"), fix(date, NLS.toMachineString(LocalDate.now())), fix(vcs, "-")); }
/** * Adds a complex filter which determines which documents should be selected. * * @param filter the filter to apply * @return the builder itself for fluent method calls */ @SuppressWarnings("unchecked") public S where(MongoConstraint filter) { if (filterObject.containsField(filter.getKey())) { throw new IllegalArgumentException(Strings.apply("A constraint for %s was already specified. " + "Please use Filter.and to combine multiple constraints " + "on one field. Filter: %s", filter.getKey(), filterObject.toString())); } filterObject.put(filter.getKey(), filter.getObject()); return (S) this; }
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(); } }