br.com.objectos.testable.Equality Maven / Gradle / Ivy
/*
* Copyright 2015 Objectos, Fábrica de Software LTDA.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package br.com.objectos.testable;
/**
* @author [email protected] (Marcio Endo)
*/
public interface Equality {
static EqualityBuilder using(AbstractTester tester) {
return new EqualityBuilder<>(tester);
}
static Equality elementMissing(int index, Object expected) {
return ElementMissing.of(index, expected);
}
static Equality elementNotEqual(int index, Object a, Object b) {
return ElementNotEqual.of(index, a, b);
}
static Equality elementNotExpected(int index, Object found) {
return ElementNotExpected.of(index, found);
}
static Equality equal() {
return Equal.INSTANCE;
}
static Equality fail(String expected, String found) {
return new Fail(expected, found);
}
static Equality instanceOf(Object that, Class> type) {
if (that == null) {
return nullValue();
}
if (!type.isInstance(that)) {
return typeNotEqual(type, that.getClass());
}
return equal();
}
static Equality notEqual(String name, String a, String b) {
return new NotEqual(name, a, b);
}
static Equality nullValue() {
return NullValue.INSTANCE;
}
static Equality typeNotEqual(Class> typeA, Class> typeB) {
return new TypeNotEqual(typeA, typeB);
}
void accept(Reporter reporter);
boolean isEqual();
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy