/** * Formats the given <code>{@link Description}</code> by surrounding its text value with square brackets and adding a space at * the end. * @param d the description to format. It can be {@code null}. * @return the formatted description, or an empty {@code String} if the {@code Description} is {@code null}. */ public String format(Description d) { String s = (d != null) ? d.value() : null; if (isNullOrEmpty(s)) return ""; return String.format("[%s] ", s); }
/** * Returns whether the text of this object's description was set. * * @return whether the text of this object's description was set. */ public boolean hasDescription() { return description != null && !isNullOrEmpty(description.value()); }
private void validatePropertyOrFieldName(String propertyOrFieldName) { checkArgument(!Strings.isNullOrEmpty(propertyOrFieldName), "The property/field name to filter on should not be null or empty"); }
/** * Formats the given <code>{@link Description}</code> by surrounding its text value with square brackets and adding a space at * the end. * @param d the description to format. It can be {@code null}. * @return the formatted description, or an empty {@code String} if the {@code Description} is {@code null}. */ public String format(Description d) { String s = (d != null) ? d.value() : null; if (isNullOrEmpty(s)) return ""; return String.format("[%s] ", s); }
/** * Returns whether the text of this object's description was set. * * @return whether the text of this object's description was set. */ public boolean hasDescription() { return description != null && !isNullOrEmpty(description.value()); }
protected String navigationDescription(String propertyName) { String text = descriptionText(); if (Strings.isNullOrEmpty(text)) { text = removeAssert(this.getClass().getSimpleName()); } return text + " " + propertyName; }
private static UncheckedIOException cannotCreateNewFile(String path, String reason, Exception cause) { String message = String.format("Unable to create the new file %s", quote(path)); if (!Strings.isNullOrEmpty(reason)) { message = concat(message, ": ", reason); } if (cause == null) { throw new RuntimeException(message); } if (cause instanceof IOException) { throw new UncheckedIOException(message, (IOException) cause); } throw new RuntimeException(message, cause); }
private void validatePropertyOrFieldName(String propertyOrFieldName) { checkArgument(!Strings.isNullOrEmpty(propertyOrFieldName), "The property/field name to filter on should not be null or empty"); }
private static UncheckedIOException cannotCreateNewFile(String path, String reason, Exception cause) { String message = String.format("Unable to create the new file %s", quote(path)); if (!Strings.isNullOrEmpty(reason)) { message = concat(message, ": ", reason); } if (cause == null) { throw new RuntimeException(message); } if (cause instanceof IOException) { throw new UncheckedIOException(message, (IOException) cause); } throw new RuntimeException(message, cause); }
protected String navigationDescription(String propertyName) { String text = descriptionText(); if (Strings.isNullOrEmpty(text)) { text = removeAssert(this.getClass().getSimpleName()); } return text + " " + propertyName; }
public static String mostRelevantDescription(Description existingDescription, String newDescription) { boolean isDescriptionSet = existingDescription != null && !isNullOrEmpty(existingDescription.value()); return isDescriptionSet ? existingDescription.value() : newDescription; }
public OnFieldsComparator(Map<String, Comparator<?>> comparatorByPropertyOrField, TypeComparators comparatorByType, String... fields) { super(comparatorByPropertyOrField, comparatorByType); checkArgument(!isNullOrEmpty(fields), "No fields/properties specified"); for (String field : fields) { checkArgument(!isNullOrEmpty(field) && !isNullOrEmpty(field.trim()), "Null/blank fields/properties are invalid, fields/properties were %s", CONFIGURATION_PROVIDER.representation().toStringOf(fields)); } this.fields = fields; }
public static ErrorMessageFactory shouldHavePath(URL actual, String expectedPath) { return isNullOrEmpty(expectedPath) ? new ShouldHavePath(actual) : new ShouldHavePath(actual, expectedPath); }
public static String mostRelevantDescription(Description existingDescription, String newDescription) { boolean isDescriptionSet = existingDescription != null && !isNullOrEmpty(existingDescription.value()); return isDescriptionSet ? existingDescription.value() : newDescription; }
public static ErrorMessageFactory shouldHavePath(URL actual, String expectedPath) { return isNullOrEmpty(expectedPath) ? new ShouldHavePath(actual) : new ShouldHavePath(actual, expectedPath); }
public OnFieldsComparator(Map<String, Comparator<?>> comparatorByPropertyOrField, TypeComparators comparatorByType, String... fields) { super(comparatorByPropertyOrField, comparatorByType); checkArgument(!isNullOrEmpty(fields), "No fields/properties specified"); for (String field : fields) { checkArgument(!isNullOrEmpty(field) && !isNullOrEmpty(field.trim()), "Null/blank fields/properties are invalid, fields/properties were %s", CONFIGURATION_PROVIDER.representation().toStringOf(fields)); } this.fields = fields; }
public AssertionError failureIfErrorMessageIsOverridden(AssertionInfo info) { String overridingErrorMessage = info.overridingErrorMessage(); return isNullOrEmpty(overridingErrorMessage) ? null : failure(MessageFormatter.instance().format(info.description(), info.representation(), overridingErrorMessage)); }
public AssertionError failureIfErrorMessageIsOverridden(AssertionInfo info) { String overridingErrorMessage = info.overridingErrorMessage(); return isNullOrEmpty(overridingErrorMessage) ? null : failure(MessageFormatter.instance().format(info.description(), info.representation(), overridingErrorMessage)); }
protected String assertionErrorMessage(AssertionInfo info, ErrorMessageFactory messageFactory) { String overridingErrorMessage = info.overridingErrorMessage(); String message = isNullOrEmpty(overridingErrorMessage) ? messageFactory.create(info.description(), info.representation()) : MessageFormatter.instance().format(info.description(), info.representation(), overridingErrorMessage); return message; }
protected String assertionErrorMessage(AssertionInfo info, ErrorMessageFactory messageFactory) { String overridingErrorMessage = info.overridingErrorMessage(); String message = isNullOrEmpty(overridingErrorMessage) ? messageFactory.create(info.description(), info.representation()) : MessageFormatter.instance().format(info.description(), info.representation(), overridingErrorMessage); return message; }