001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.juneau.bct.assertions; 018 019import java.io.*; 020import java.util.function.*; 021 022 023/** 024 * Used for assertion calls against comparable objects. 025 * 026 * <h5 class='section'>Test Methods:</h5> 027 * <p> 028 * <ul class='javatree'> 029 * <li class='jc'>{@link FluentComparableAssertion} 030 * <ul class='javatreec'> 031 * <li class='jm'>{@link FluentComparableAssertion#isGt(Comparable) isGt(Comparable)} 032 * <li class='jm'>{@link FluentComparableAssertion#isGte(Comparable) isGte(Comparable)} 033 * <li class='jm'>{@link FluentComparableAssertion#isLt(Comparable) isLt(Comparable)} 034 * <li class='jm'>{@link FluentComparableAssertion#isLte(Comparable) isLte(Comparable)} 035 * <li class='jm'>{@link FluentComparableAssertion#isBetween(Comparable,Comparable) isBetween(Comparable,Comparable)} 036 * </ul> 037 * <li class='jc'>{@link FluentObjectAssertion} 038 * <ul class='javatreec'> 039 * <li class='jm'>{@link FluentObjectAssertion#isExists() isExists()} 040 * <li class='jm'>{@link FluentObjectAssertion#is(Object) is(Object)} 041 * <li class='jm'>{@link FluentObjectAssertion#is(Predicate) is(Predicate)} 042 * <li class='jm'>{@link FluentObjectAssertion#isNot(Object) isNot(Object)} 043 * <li class='jm'>{@link FluentObjectAssertion#isAny(Object...) isAny(Object...)} 044 * <li class='jm'>{@link FluentObjectAssertion#isNotAny(Object...) isNotAny(Object...)} 045 * <li class='jm'>{@link FluentObjectAssertion#isNull() isNull()} 046 * <li class='jm'>{@link FluentObjectAssertion#isNotNull() isNotNull()} 047 * <li class='jm'>{@link FluentObjectAssertion#isString(String) isString(String)} 048 * <li class='jm'>{@link FluentObjectAssertion#isSame(Object) isSame(Object)} 049 * <li class='jm'>{@link FluentObjectAssertion#isType(Class) isType(Class)} 050 * <li class='jm'>{@link FluentObjectAssertion#isExactType(Class) isExactType(Class)} 051 * </ul> 052 * </ul> 053 * 054 * <h5 class='section'>Transform Methods:</h5> 055 * <p> 056 * <ul class='javatree'> 057 * <li class='jc'>{@link FluentObjectAssertion} 058 * <ul class='javatreec'> 059 * <li class='jm'>{@link FluentObjectAssertion#asString() asString()} 060 * <li class='jm'>{@link FluentObjectAssertion#asString(ThrowingFunction) asString(ThrowingFunction)} 061 * <li class='jm'>{@link FluentObjectAssertion#asTransformed(UnaryOperator) asTransformed(UnaryOperator)} 062 * <li class='jm'>{@link FluentObjectAssertion#asAny() asAny()} 063 * </ul> 064 * </ul> 065 * 066 * <h5 class='section'>Configuration Methods:</h5> 067 * <p> 068 * <ul class='javatree'> 069 * <li class='jc'>{@link Assertion} 070 * <ul class='javatreec'> 071 * <li class='jm'>{@link Assertion#setMsg(String, Object...) setMsg(String, Object...)} 072 * <li class='jm'>{@link Assertion#setOut(PrintStream) setOut(PrintStream)} 073 * <li class='jm'>{@link Assertion#setSilent() setSilent()} 074 * <li class='jm'>{@link Assertion#setStdOut() setStdOut()} 075 * <li class='jm'>{@link Assertion#setThrowable(Class) setThrowable(Class)} 076 * </ul> 077 * </ul> 078 * 079 * <h5 class='section'>See Also:</h5><ul> 080 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauEcosystemOverview">Juneau Ecosystem</a> 081 * </ul> 082 * 083 * @param <T> The comparable type. 084 */ 085public class ComparableAssertion<T extends Comparable<T>> extends FluentComparableAssertion<T,ComparableAssertion<T>> { 086 087 /** 088 * Static creator. 089 * 090 * @param <T> The value type. 091 * @param value 092 * The object being tested. 093 * <br>Can be <jk>null</jk> (assertions such as {@code isNull()} then operate on the absence of a value). 094 * @return A new assertion object. 095 */ 096 public static <T extends Comparable<T>> ComparableAssertion<T> create(T value) { 097 return new ComparableAssertion<>(value); 098 } 099 100 /** 101 * Constructor. 102 * 103 * @param value 104 * The object being tested. 105 * <br>Can be <jk>null</jk> (assertions such as {@code isNull()} then operate on the absence of a value). 106 */ 107 public ComparableAssertion(T value) { 108 super(value, null); 109 } 110 111 @Override /* Overridden from Assertion */ 112 public ComparableAssertion<T> setMsg(String msg, Object...args) { 113 super.setMsg(msg, args); 114 return this; 115 } 116 117 @Override /* Overridden from Assertion */ 118 public ComparableAssertion<T> setOut(PrintStream value) { 119 super.setOut(value); 120 return this; 121 } 122 123 @Override /* Overridden from Assertion */ 124 public ComparableAssertion<T> setSilent() { 125 super.setSilent(); 126 return this; 127 } 128 129 @Override /* Overridden from Assertion */ 130 public ComparableAssertion<T> setStdOut() { 131 super.setStdOut(); 132 return this; 133 } 134 135 @Override /* Overridden from Assertion */ 136 public ComparableAssertion<T> setThrowable(Class<? extends RuntimeException> value) { 137 super.setThrowable(value); 138 return this; 139 } 140}