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 arrays.
023 *
024 * <h5 class='section'>Example:</h5>
025 * <p class='bjava'>
026 *    <jk>int</jk>[] <jv>array</jv> = {1};
027 *    <jsm>assertArray</jsm>(<jv>array</jv>).exists().isSize(1);
028 * </p>
029 *
030 *
031 * <h5 class='section'>Test Methods:</h5>
032 * <p>
033 * <ul class='javatree'>
034 *    <li class='jc'>{@link FluentPrimitiveArrayAssertion}
035 *    <ul class='javatreec'>
036 *       <li class='jm'>{@link FluentPrimitiveArrayAssertion#isHas(Object...) isHas(Object...)}
037 *       <li class='jm'>{@link FluentPrimitiveArrayAssertion#is(Predicate) is(Predicate)}
038 *       <li class='jm'>{@link FluentPrimitiveArrayAssertion#isAny(Predicate) isAny(Predicate)}
039 *       <li class='jm'>{@link FluentPrimitiveArrayAssertion#isAll(Predicate) isAll(Predicate)}
040 *       <li class='jm'>{@link FluentPrimitiveArrayAssertion#isEmpty() isEmpty()}
041 *       <li class='jm'>{@link FluentPrimitiveArrayAssertion#isNotEmpty() isNotEmpty()}
042 *       <li class='jm'>{@link FluentPrimitiveArrayAssertion#isSize(int) isSize(int)}
043 *       <li class='jm'>{@link FluentPrimitiveArrayAssertion#isContains(Object) isContains(Object)}
044 *       <li class='jm'>{@link FluentPrimitiveArrayAssertion#isNotContains(Object) isNotContains(Object)}
045 *    </ul>
046 *    <li class='jc'>{@link FluentObjectAssertion}
047 *    <ul class='javatreec'>
048 *       <li class='jm'>{@link FluentObjectAssertion#isExists() isExists()}
049 *       <li class='jm'>{@link FluentObjectAssertion#is(Object) is(Object)}
050 *       <li class='jm'>{@link FluentObjectAssertion#is(Predicate) is(Predicate)}
051 *       <li class='jm'>{@link FluentObjectAssertion#isNot(Object) isNot(Object)}
052 *       <li class='jm'>{@link FluentObjectAssertion#isAny(Object...) isAny(Object...)}
053 *       <li class='jm'>{@link FluentObjectAssertion#isNotAny(Object...) isNotAny(Object...)}
054 *       <li class='jm'>{@link FluentObjectAssertion#isNull() isNull()}
055 *       <li class='jm'>{@link FluentObjectAssertion#isNotNull() isNotNull()}
056 *       <li class='jm'>{@link FluentObjectAssertion#isString(String) isString(String)}
057 *       <li class='jm'>{@link FluentObjectAssertion#isJson(String) isJson(String)}
058 *       <li class='jm'>{@link FluentObjectAssertion#isSame(Object) isSame(Object)}
059 *       <li class='jm'>{@link FluentObjectAssertion#isSameJsonAs(Object) isSameJsonAs(Object)}
060 *       <li class='jm'>{@link FluentObjectAssertion#isSameSortedJsonAs(Object) isSameSortedJsonAs(Object)}
061 *       <li class='jm'>{@link FluentObjectAssertion#isSameSerializedAs(Object, WriterSerializer) isSameSerializedAs(Object, WriterSerializer)}
062 *       <li class='jm'>{@link FluentObjectAssertion#isType(Class) isType(Class)}
063 *       <li class='jm'>{@link FluentObjectAssertion#isExactType(Class) isExactType(Class)}
064 *    </ul>
065 * </ul>
066 *
067 * <h5 class='section'>Transform Methods:</h5>
068 * <p>
069 * <ul class='javatree'>
070 *    <li class='jc'>{@link FluentPrimitiveArrayAssertion}
071 *    <ul class='javatreec'>
072 *       <li class='jm'>{@link FluentPrimitiveArrayAssertion#asItem(int) asItem(int)}
073 *       <li class='jm'>{@link FluentPrimitiveArrayAssertion#asLength() asLength()}
074 *    </ul>
075 *    <li class='jc'>{@link FluentObjectAssertion}
076 *    <ul class='javatreec'>
077 *       <li class='jm'>{@link FluentObjectAssertion#asString() asString()}
078 *       <li class='jm'>{@link FluentObjectAssertion#asString(WriterSerializer) asString(WriterSerializer)}
079 *       <li class='jm'>{@link FluentObjectAssertion#asString(Function) asString(Function)}
080 *       <li class='jm'>{@link FluentObjectAssertion#asJson() asJson()}
081 *       <li class='jm'>{@link FluentObjectAssertion#asJsonSorted() asJsonSorted()}
082 *       <li class='jm'>{@link FluentObjectAssertion#asTransformed(Function) asApplied(Function)}
083 *       <li class='jm'>{@link FluentObjectAssertion#asAny() asAny()}
084 * </ul>
085 * </ul>
086 *
087 * <h5 class='section'>Configuration Methods:</h5>
088 * <p>
089 * <ul class='javatree'>
090 *    <li class='jc'>{@link Assertion}
091 *    <ul class='javatreec'>
092 *       <li class='jm'>{@link Assertion#setMsg(String, Object...) setMsg(String, Object...)}
093 *       <li class='jm'>{@link Assertion#setOut(PrintStream) setOut(PrintStream)}
094 *       <li class='jm'>{@link Assertion#setSilent() setSilent()}
095 *       <li class='jm'>{@link Assertion#setStdOut() setStdOut()}
096 *       <li class='jm'>{@link Assertion#setThrowable(Class) setThrowable(Class)}
097 *    </ul>
098 * </ul>
099 *
100 * <h5 class='section'>See Also:</h5><ul>
101 *    <li class='link'><a class="doclink" href="../../../../index.html#ja.Overview">Overview &gt; juneau-assertions &gt; Overview</a>
102 * </ul>
103 *
104 * @param <E> The array element type.
105 * @param <T> The array type.
106 */
107@FluentSetters(returns="PrimitiveArrayAssertion<E,T>")
108public class PrimitiveArrayAssertion<E,T> extends FluentPrimitiveArrayAssertion<E,T,PrimitiveArrayAssertion<E,T>> {
109
110   //-----------------------------------------------------------------------------------------------------------------
111   // Static
112   //-----------------------------------------------------------------------------------------------------------------
113
114   /**
115    * Static creator.
116    *
117    * @param <E> The element type.
118    * @param <T> The value type.
119    * @param value
120    *    The object being tested.
121    *    <br>Can be <jk>null</jk>.
122    * @return A new assertion object.
123    */
124   public static <E,T> PrimitiveArrayAssertion<E,T> create(T value) {
125      return new PrimitiveArrayAssertion<>(value);
126   }
127
128   //-----------------------------------------------------------------------------------------------------------------
129   // Instance
130   //-----------------------------------------------------------------------------------------------------------------
131
132   /**
133    * Constructor.
134    *
135    * @param value
136    *    The object being tested.
137    *    <br>Can be <jk>null</jk>.
138    */
139   public PrimitiveArrayAssertion(T value) {
140      super(value, null);
141   }
142
143   //-----------------------------------------------------------------------------------------------------------------
144   // Fluent setters
145   //-----------------------------------------------------------------------------------------------------------------
146
147   // <FluentSetters>
148
149   @Override /* GENERATED - org.apache.juneau.assertions.Assertion */
150   public PrimitiveArrayAssertion<E,T> setMsg(String msg, Object...args) {
151      super.setMsg(msg, args);
152      return this;
153   }
154
155   @Override /* GENERATED - org.apache.juneau.assertions.Assertion */
156   public PrimitiveArrayAssertion<E,T> setOut(PrintStream value) {
157      super.setOut(value);
158      return this;
159   }
160
161   @Override /* GENERATED - org.apache.juneau.assertions.Assertion */
162   public PrimitiveArrayAssertion<E,T> setSilent() {
163      super.setSilent();
164      return this;
165   }
166
167   @Override /* GENERATED - org.apache.juneau.assertions.Assertion */
168   public PrimitiveArrayAssertion<E,T> setStdOut() {
169      super.setStdOut();
170      return this;
171   }
172
173   @Override /* GENERATED - org.apache.juneau.assertions.Assertion */
174   public PrimitiveArrayAssertion<E,T> setThrowable(Class<? extends java.lang.RuntimeException> value) {
175      super.setThrowable(value);
176      return this;
177   }
178
179   // </FluentSetters>
180}