001// ***************************************************************************************************************************
002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *
003// * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file        *
004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance            *
005// * with 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 an  *
010// * "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// ***************************************************************************************************************************
013package org.apache.juneau.assertions;
014
015import java.io.*;
016import java.util.function.*;
017
018import org.apache.juneau.internal.*;
019import org.apache.juneau.serializer.*;
020
021/**
022 * Used for assertion calls against comparable objects.
023 *
024 * <h5 class='section'>Test Methods:</h5>
025 * <p>
026 * <ul class='javatree'>
027 *    <li class='jc'>{@link FluentComparableAssertion}
028 *    <ul class='javatreec'>
029 *       <li class='jm'>{@link FluentComparableAssertion#isGt(Comparable) isGt(Comparable)}
030 *       <li class='jm'>{@link FluentComparableAssertion#isGte(Comparable) isGte(Comparable)}
031 *       <li class='jm'>{@link FluentComparableAssertion#isLt(Comparable) isLt(Comparable)}
032 *       <li class='jm'>{@link FluentComparableAssertion#isLte(Comparable) isLte(Comparable)}
033 *       <li class='jm'>{@link FluentComparableAssertion#isBetween(Comparable,Comparable) isBetween(Comparable,Comparable)}
034  *   </ul>
035 *    <li class='jc'>{@link FluentObjectAssertion}
036 *    <ul class='javatreec'>
037 *       <li class='jm'>{@link FluentObjectAssertion#isExists() isExists()}
038 *       <li class='jm'>{@link FluentObjectAssertion#is(Object) is(Object)}
039 *       <li class='jm'>{@link FluentObjectAssertion#is(Predicate) is(Predicate)}
040 *       <li class='jm'>{@link FluentObjectAssertion#isNot(Object) isNot(Object)}
041 *       <li class='jm'>{@link FluentObjectAssertion#isAny(Object...) isAny(Object...)}
042 *       <li class='jm'>{@link FluentObjectAssertion#isNotAny(Object...) isNotAny(Object...)}
043 *       <li class='jm'>{@link FluentObjectAssertion#isNull() isNull()}
044 *       <li class='jm'>{@link FluentObjectAssertion#isNotNull() isNotNull()}
045 *       <li class='jm'>{@link FluentObjectAssertion#isString(String) isString(String)}
046 *       <li class='jm'>{@link FluentObjectAssertion#isJson(String) isJson(String)}
047 *       <li class='jm'>{@link FluentObjectAssertion#isSame(Object) isSame(Object)}
048 *       <li class='jm'>{@link FluentObjectAssertion#isSameJsonAs(Object) isSameJsonAs(Object)}
049 *       <li class='jm'>{@link FluentObjectAssertion#isSameSortedJsonAs(Object) isSameSortedJsonAs(Object)}
050 *       <li class='jm'>{@link FluentObjectAssertion#isSameSerializedAs(Object, WriterSerializer) isSameSerializedAs(Object, WriterSerializer)}
051 *       <li class='jm'>{@link FluentObjectAssertion#isType(Class) isType(Class)}
052 *       <li class='jm'>{@link FluentObjectAssertion#isExactType(Class) isExactType(Class)}
053 *    </ul>
054 * </ul>
055 *
056 * <h5 class='section'>Transform Methods:</h5>
057 * <p>
058 * <ul class='javatree'>
059 *    <li class='jc'>{@link FluentObjectAssertion}
060 *    <ul class='javatreec'>
061 *       <li class='jm'>{@link FluentObjectAssertion#asString() asString()}
062 *       <li class='jm'>{@link FluentObjectAssertion#asString(WriterSerializer) asString(WriterSerializer)}
063 *       <li class='jm'>{@link FluentObjectAssertion#asString(Function) asString(Function)}
064 *       <li class='jm'>{@link FluentObjectAssertion#asJson() asJson()}
065 *       <li class='jm'>{@link FluentObjectAssertion#asJsonSorted() asJsonSorted()}
066 *       <li class='jm'>{@link FluentObjectAssertion#asTransformed(Function) asApplied(Function)}
067 *       <li class='jm'>{@link FluentObjectAssertion#asAny() asAny()}
068 * </ul>
069 * </ul>
070 *
071 * <h5 class='section'>Configuration Methods:</h5>
072 * <p>
073 * <ul class='javatree'>
074 *    <li class='jc'>{@link Assertion}
075 *    <ul class='javatreec'>
076 *       <li class='jm'>{@link Assertion#setMsg(String, Object...) setMsg(String, Object...)}
077 *       <li class='jm'>{@link Assertion#setOut(PrintStream) setOut(PrintStream)}
078 *       <li class='jm'>{@link Assertion#setSilent() setSilent()}
079 *       <li class='jm'>{@link Assertion#setStdOut() setStdOut()}
080 *       <li class='jm'>{@link Assertion#setThrowable(Class) setThrowable(Class)}
081 *    </ul>
082 * </ul>
083 *
084 * <h5 class='section'>See Also:</h5><ul>
085 *    <li class='link'><a class="doclink" href="../../../../index.html#ja.Overview">Overview &gt; juneau-assertions &gt; Overview</a>
086 * </ul>
087 *
088 * @param <T> The comparable type.
089 */
090@FluentSetters(returns="ComparableAssertion<T>")
091public class ComparableAssertion<T extends Comparable<T>> extends FluentComparableAssertion<T,ComparableAssertion<T>> {
092
093   //-----------------------------------------------------------------------------------------------------------------
094   // Static
095   //-----------------------------------------------------------------------------------------------------------------
096
097   /**
098    * Static creator.
099    *
100    * @param <T> The value type.
101    * @param value
102    *    The object being tested.
103    *    <br>Can be <jk>null</jk>.
104    * @return A new assertion object.
105    */
106   public static <T extends Comparable<T>> ComparableAssertion<T> create(T value) {
107      return new ComparableAssertion<>(value);
108   }
109
110   //-----------------------------------------------------------------------------------------------------------------
111   // Instance
112   //-----------------------------------------------------------------------------------------------------------------
113
114   /**
115    * Constructor.
116    *
117    * @param value
118    *    The object being tested.
119    *    <br>Can be <jk>null</jk>.
120    */
121   public ComparableAssertion(T value) {
122      super(value, null);
123   }
124
125   //-----------------------------------------------------------------------------------------------------------------
126   // Fluent setters
127   //-----------------------------------------------------------------------------------------------------------------
128
129   // <FluentSetters>
130
131   @Override /* GENERATED - org.apache.juneau.assertions.Assertion */
132   public ComparableAssertion<T> setMsg(String msg, Object...args) {
133      super.setMsg(msg, args);
134      return this;
135   }
136
137   @Override /* GENERATED - org.apache.juneau.assertions.Assertion */
138   public ComparableAssertion<T> setOut(PrintStream value) {
139      super.setOut(value);
140      return this;
141   }
142
143   @Override /* GENERATED - org.apache.juneau.assertions.Assertion */
144   public ComparableAssertion<T> setSilent() {
145      super.setSilent();
146      return this;
147   }
148
149   @Override /* GENERATED - org.apache.juneau.assertions.Assertion */
150   public ComparableAssertion<T> setStdOut() {
151      super.setStdOut();
152      return this;
153   }
154
155   @Override /* GENERATED - org.apache.juneau.assertions.Assertion */
156   public ComparableAssertion<T> setThrowable(Class<? extends java.lang.RuntimeException> value) {
157      super.setThrowable(value);
158      return this;
159   }
160
161   // </FluentSetters>
162}