001    /*
002     * Created on Jul 19, 2010
003     *
004     * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
005     * the License. You may obtain a copy of the License at
006     *
007     * http://www.apache.org/licenses/LICENSE-2.0
008     *
009     * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
010     * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
011     * specific language governing permissions and limitations under the License.
012     *
013     * Copyright @2010-2011 the original author or authors.
014     */
015    package org.fest.assertions.core;
016    
017    import org.fest.assertions.description.*;
018    
019    /**
020     * An object that has a description.
021     * @param <S> the "self" type of this assertion class. Please read
022     * &quot;<a href="http://bit.ly/anMa4g" target="_blank">Emulating 'self types' using Java Generics to simplify fluent
023     * API implementation</a>&quot; for more details.
024     *
025     * @author Alex Ruiz
026     * @author Yvonne Wang
027     */
028    public interface Descriptable<S> {
029    
030      /**
031       * Sets the description of this object.
032       * @param description the new description to set.
033       * @return {@code this} object.
034       * @throws NullPointerException if the description is {@code null}.
035       * @see #describedAs(String)
036       */
037      S as(String description);
038    
039      /**
040       * Sets the description of this object. To remove or clear the description, pass a
041       * <code>{@link EmptyTextDescription}</code> as argument.
042       * <p>
043       * This overloaded version of "describedAs" offers more flexibility than the one taking a {@code String} by allowing
044       * users to pass their own implementation of a description. For example, a description that creates its value lazily,
045       * only when an assertion failure occurs.
046       * </p>
047       * @param description the new description to set.
048       * @return {@code this} object.
049       * @throws NullPointerException if the description is {@code null}.
050       * @see #describedAs(Description)
051       */
052      S as(Description description);
053    
054      /**
055       * Alias for <code>{@link #as(String)}</code> since "as" is a keyword in <a href="http://groovy.codehaus.org/"
056       * target="_blank">Groovy</a>.
057       * @param description the new description to set.
058       * @return {@code this} object.
059       * @throws NullPointerException if the description is {@code null}.
060       */
061      S describedAs(String description);
062    
063      /**
064       * Alias for <code>{@link #as(String)}</code> since "as" is a keyword in <a href="http://groovy.codehaus.org/"
065       * target="_blank">Groovy</a>. To remove or clear the description, pass a <code>{@link EmptyTextDescription}</code> as
066       * argument.
067       * <p>
068       * This overloaded version of "describedAs" offers more flexibility than the one taking a {@code String} by allowing
069       * users to pass their own implementation of a description. For example, a description that creates its value lazily,
070       * only when an assertion failure occurs.
071       * </p>
072       * @param description the new description to set.
073       * @return {@code this} object.
074       * @throws NullPointerException if the description is {@code null}.
075       */
076      S describedAs(Description description);
077    }