/** * Returns a builder for creating a derived subject but without providing information about how * the derived subject will relate to the current subject. In most cases, you should provide such * information by using {@linkplain #check(String, Object...) the other overload}. */ protected final StandardSubjectBuilder check() { return new StandardSubjectBuilder(metadata.updateForCheckCall()); }
/** * Returns a new instance that invokes the given {@code FailureStrategy} when a check fails. Most * users should not need this. If you think you do, see the documentation on {@link * FailureStrategy}. */ public static StandardSubjectBuilder forCustomFailureStrategy(FailureStrategy failureStrategy) { return new StandardSubjectBuilder(FailureMetadata.forFailureStrategy(failureStrategy)); }
private StandardSubjectBuilder doCheck( OldAndNewValuesAreSimilar valuesAreSimilar, String format, Object[] args) { checkNotNull(format); // Probably LazyMessage itself should be this strict, but it isn't yet. final LazyMessage message = new LazyMessage(format, args); Function<String, String> descriptionUpdate = new Function<String, String>() { @Override public String apply(String input) { return input + "." + message; } }; return new StandardSubjectBuilder( metadata.updateForCheckCall(valuesAreSimilar, descriptionUpdate)); }
/** * Returns a new instance that will output the given message before the main failure message. If * this method is called multiple times, the messages will appear in the order that they were * specified. * * <p><b>Note:</b> the arguments will be substituted into the format template using {@link * com.google.common.base.Strings#lenientFormat Strings.lenientFormat}. Note this only supports * the {@code %s} specifier. * * @throws IllegalArgumentException if the number of placeholders in the format string does not * equal the number of given arguments */ public final StandardSubjectBuilder withMessage( @NullableDecl String format, Object /* @NullableDeclType */... args) { return new StandardSubjectBuilder(metadata().withMessage(format, args)); }