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 * <h2 class='section'>Test Methods:</h2> 027 * <ul class='javatree'> 028 * <li class='jc'>{@link FluentComparableAssertion} 029 * <ul class='javatreec'> 030 * <li class='jm'>{@link FluentComparableAssertion#isGt(Comparable) isGt(Comparable)} 031 * <li class='jm'>{@link FluentComparableAssertion#isGte(Comparable) isGte(Comparable)} 032 * <li class='jm'>{@link FluentComparableAssertion#isLt(Comparable) isLt(Comparable)} 033 * <li class='jm'>{@link FluentComparableAssertion#isLte(Comparable) isLte(Comparable)} 034 * <li class='jm'>{@link FluentComparableAssertion#isBetween(Comparable,Comparable) isBetween(Comparable,Comparable)} 035 * </ul> 036 * <li class='jc'>{@link FluentObjectAssertion} 037 * <ul class='javatreec'> 038 * <li class='jm'>{@link FluentObjectAssertion#isExists() isExists()} 039 * <li class='jm'>{@link FluentObjectAssertion#is(Object) is(Object)} 040 * <li class='jm'>{@link FluentObjectAssertion#is(Predicate) is(Predicate)} 041 * <li class='jm'>{@link FluentObjectAssertion#isNot(Object) isNot(Object)} 042 * <li class='jm'>{@link FluentObjectAssertion#isAny(Object...) isAny(Object...)} 043 * <li class='jm'>{@link FluentObjectAssertion#isNotAny(Object...) isNotAny(Object...)} 044 * <li class='jm'>{@link FluentObjectAssertion#isNull() isNull()} 045 * <li class='jm'>{@link FluentObjectAssertion#isNotNull() isNotNull()} 046 * <li class='jm'>{@link FluentObjectAssertion#isString(String) isString(String)} 047 * <li class='jm'>{@link FluentObjectAssertion#isSame(Object) isSame(Object)} 048 * <li class='jm'>{@link FluentObjectAssertion#isType(Class) isType(Class)} 049 * <li class='jm'>{@link FluentObjectAssertion#isExactType(Class) isExactType(Class)} 050 * </ul> 051 * </ul> 052 * 053 * <h2 class='section'>Transform Methods:</h2> 054 * <ul class='javatree'> 055 * <li class='jc'>{@link FluentObjectAssertion} 056 * <ul class='javatreec'> 057 * <li class='jm'>{@link FluentObjectAssertion#asString() asString()} 058 * <li class='jm'>{@link FluentObjectAssertion#asString(ThrowingFunction) asString(ThrowingFunction)} 059 * <li class='jm'>{@link FluentObjectAssertion#asTransformed(UnaryOperator) asTransformed(UnaryOperator)} 060 * <li class='jm'>{@link FluentObjectAssertion#asAny() asAny()} 061 * </ul> 062 * </ul> 063 * 064 * <h2 class='section'>Configuration Methods:</h2> 065 * <ul class='javatree'> 066 * <li class='jc'>{@link Assertion} 067 * <ul class='javatreec'> 068 * <li class='jm'>{@link Assertion#setMsg(String, Object...) setMsg(String, Object...)} 069 * <li class='jm'>{@link Assertion#setOut(PrintStream) setOut(PrintStream)} 070 * <li class='jm'>{@link Assertion#setSilent() setSilent()} 071 * <li class='jm'>{@link Assertion#setStdOut() setStdOut()} 072 * <li class='jm'>{@link Assertion#setThrowable(Class) setThrowable(Class)} 073 * </ul> 074 * </ul> 075 * 076 * <h2 class='section'>See Also:</h2><ul> 077 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauEcosystemOverview">Juneau Ecosystem</a> 078 * </ul> 079 * 080 * @param <T> The comparable type. 081 */ 082public class ComparableAssertion<T extends Comparable<T>> extends FluentComparableAssertion<T,ComparableAssertion<T>> { 083 084 /** 085 * Static creator. 086 * 087 * @param <T> The value type. 088 * @param value 089 * The object being tested. 090 * <br>Can be <jk>null</jk> (assertions such as {@code isNull()} then operate on the absence of a value). 091 * @return A new assertion object. 092 */ 093 public static <T extends Comparable<T>> ComparableAssertion<T> create(T value) { 094 return new ComparableAssertion<>(value); 095 } 096 097 /** 098 * Constructor. 099 * 100 * @param value 101 * The object being tested. 102 * <br>Can be <jk>null</jk> (assertions such as {@code isNull()} then operate on the absence of a value). 103 */ 104 public ComparableAssertion(T value) { 105 super(value, null); 106 } 107 108 @Override /* Overridden from Assertion */ 109 public ComparableAssertion<T> setMsg(String msg, Object...args) { 110 super.setMsg(msg, args); 111 return this; 112 } 113 114 @Override /* Overridden from Assertion */ 115 public ComparableAssertion<T> setOut(PrintStream value) { 116 super.setOut(value); 117 return this; 118 } 119 120 @Override /* Overridden from Assertion */ 121 public ComparableAssertion<T> setSilent() { 122 super.setSilent(); 123 return this; 124 } 125 126 @Override /* Overridden from Assertion */ 127 public ComparableAssertion<T> setStdOut() { 128 super.setStdOut(); 129 return this; 130 } 131 132 @Override /* Overridden from Assertion */ 133 public ComparableAssertion<T> setThrowable(Class<? extends RuntimeException> value) { 134 super.setThrowable(value); 135 return this; 136 } 137}