Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
fr.landel.utils.assertor.AssertorStepMap Maven / Gradle / Ivy
/*-
* #%L
* utils-assertor
* %%
* Copyright (C) 2016 - 2018 Gilles Landel
* %%
* 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.
* #L%
*/
package fr.landel.utils.assertor;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.function.Predicate;
import fr.landel.utils.assertor.commons.MessageAssertor;
import fr.landel.utils.assertor.helper.HelperStep;
import fr.landel.utils.assertor.utils.AssertorMap;
/**
* This class define methods that can be applied on the checked {@link Map}
* object. To provide a result, it's also provide a chain builder by returning a
* {@link StepMap}. The chain looks like:
*
*
* {@link AssertorStepMap} > {@link StepMap} > {@link AssertorStepMap} > {@link StepMap}...
*
*
* This chain always starts with a {@link AssertorStepMap} and ends with
* {@link StepMap}.
*
* @since Aug 3, 2016
* @author Gilles
*
*/
@FunctionalInterface
public interface AssertorStepMap extends AssertorStep, Map> {
/**
* {@inheritDoc}
*/
@Override
default StepMap get(final StepAssertor> result) {
return () -> result;
}
/**
* {@inheritDoc}
*/
@Override
default AssertorStepMap not() {
return () -> HelperStep.not(getStep());
}
/**
* Asserts that the given {@link Map} has the specified {@code size}.
*
*
* precondition: {@link Map} cannot be {@code null} and size cannot be lower
* than zero
*
*
*
* Assertor.that(map).hasSize(size).orElseThrow();
*
*
* @param size
* The wanted size
* @return The operator
* @category no_message
*/
default StepMap hasSize(final int size) {
return this.hasSize(size, null);
}
/**
* Asserts that the given {@link Map} has the specified {@code size}.
*
*
* precondition: {@link Map} cannot be {@code null} and size cannot be lower
* than zero
*
*
*
* Assertor.that(map).hasSize(size, "bad size").orElseThrow();
*
*
* @param size
* The wanted size
* @param message
* The message on mismatch
* @param arguments
* The arguments of the message, use {@link String#format}
* @return The operator
* @category message
*/
default StepMap hasSize(final int size, final CharSequence message, final Object... arguments) {
return this.hasSize(size, null, message, arguments);
}
/**
* Asserts that the given {@link Map} has the specified {@code size}.
*
*
* precondition: {@link Map} cannot be {@code null} and size cannot be lower
* than zero
*
*
*
* Assertor.that(map).hasSize(size, Locale.US, "bad size").orElseThrow();
*
*
* @param size
* The wanted size
* @param locale
* The locale of the message (only used to format this message,
* otherwise use {@link Assertor#setLocale})
* @param message
* The message on mismatch
* @param arguments
* The arguments of the message, use {@link String#format}
* @return The operator
* @category localized_message
*/
default StepMap hasSize(final int size, final Locale locale, final CharSequence message, final Object... arguments) {
return () -> AssertorMap.hasSize(this.getStep(), size, MessageAssertor.of(locale, message, arguments));
}
/**
* Asserts that the given {@link Map} has a size greater than {@code size}.
*
*
* precondition: {@link Map} cannot be {@code null} and size cannot be lower
* than zero
*
*
*
* Assertor.that(map).hasSizeGT(size).orElseThrow();
*
*
* @param size
* The wanted size
* @return The operator
* @category no_message
*/
default StepMap hasSizeGT(final int size) {
return this.hasSizeGT(size, null);
}
/**
* Asserts that the given {@link Map} has a size greater than {@code size}.
*
*
* precondition: {@link Map} cannot be {@code null} and size cannot be lower
* than zero
*
*
*
* Assertor.that(map).hasSizeGT(size, "bad size").orElseThrow();
*
*
* @param size
* The wanted size
* @param message
* The message on mismatch
* @param arguments
* The arguments of the message, use {@link String#format}
* @return The operator
* @category message
*/
default StepMap hasSizeGT(final int size, final CharSequence message, final Object... arguments) {
return this.hasSizeGT(size, null, message, arguments);
}
/**
* Asserts that the given {@link Map} has a size greater than {@code size}.
*
*
* precondition: {@link Map} cannot be {@code null} and size cannot be lower
* than zero
*
*
*
* Assertor.that(map).hasSizeGT(size, Locale.US, "bad size").orElseThrow();
*
*
* @param size
* The wanted size
* @param locale
* The locale of the message (only used to format this message,
* otherwise use {@link Assertor#setLocale})
* @param message
* The message on mismatch
* @param arguments
* The arguments of the message, use {@link String#format}
* @return The operator
* @category localized_message
*/
default StepMap hasSizeGT(final int size, final Locale locale, final CharSequence message, final Object... arguments) {
return () -> AssertorMap.hasSizeGT(this.getStep(), size, MessageAssertor.of(locale, message, arguments));
}
/**
* Asserts that the given {@link Map} has a size greater than or equal to
* {@code size}.
*
*
* precondition: {@link Map} cannot be {@code null} and size cannot be lower
* than zero
*
*
*
* Assertor.that(map).hasSizeGTE(size).orElseThrow();
*
*
* @param size
* The wanted size
* @return The operator
* @category no_message
*/
default StepMap hasSizeGTE(final int size) {
return this.hasSizeGTE(size, null);
}
/**
* Asserts that the given {@link Map} has a size greater than or equal to
* {@code size}.
*
*
* precondition: {@link Map} cannot be {@code null} and size cannot be lower
* than zero
*
*
*
* Assertor.that(map).hasSizeGTE(size, "bad size").orElseThrow();
*
*
* @param size
* The wanted size
* @param message
* The message on mismatch
* @param arguments
* The arguments of the message, use {@link String#format}
* @return The operator
* @category message
*/
default StepMap hasSizeGTE(final int size, final CharSequence message, final Object... arguments) {
return this.hasSizeGTE(size, null, message, arguments);
}
/**
* Asserts that the given {@link Map} has a size greater than or equal to
* {@code size}.
*
*
* precondition: {@link Map} cannot be {@code null} and size cannot be lower
* than zero
*
*
*
* Assertor.that(map).hasSizeGTE(size, Locale.US, "bad size").orElseThrow();
*
*
* @param size
* The wanted size
* @param locale
* The locale of the message (only used to format this message,
* otherwise use {@link Assertor#setLocale})
* @param message
* The message on mismatch
* @param arguments
* The arguments of the message, use {@link String#format}
* @return The operator
* @category localized_message
*/
default StepMap hasSizeGTE(final int size, final Locale locale, final CharSequence message, final Object... arguments) {
return () -> AssertorMap.hasSizeGTE(this.getStep(), size, MessageAssertor.of(locale, message, arguments));
}
/**
* Asserts that the given {@link Map} has a size lower than {@code size}.
*
*
* precondition: {@link Map} cannot be {@code null} and size cannot be lower
* than zero
*
*
*
* Assertor.that(map).hasSizeLT(size).orElseThrow();
*
*
* @param size
* The wanted size
* @return The operator
* @category no_message
*/
default StepMap hasSizeLT(final int size) {
return this.hasSizeLT(size, null);
}
/**
* Asserts that the given {@link Map} has a size lower than {@code size}.
*
*
* precondition: {@link Map} cannot be {@code null} and size cannot be lower
* than zero
*
*
*
* Assertor.that(map).hasSizeLT(size, "bad size").orElseThrow();
*
*
* @param size
* The wanted size
* @param message
* The message on mismatch
* @param arguments
* The arguments of the message, use {@link String#format}
* @return The operator
* @category message
*/
default StepMap hasSizeLT(final int size, final CharSequence message, final Object... arguments) {
return this.hasSizeLT(size, null, message, arguments);
}
/**
* Asserts that the given {@link Map} has a size lower than {@code size}.
*
*
* precondition: {@link Map} cannot be {@code null} and size cannot be lower
* than zero
*
*
*
* Assertor.that(map).hasSizeLT(size, Locale.US, "bad size").orElseThrow();
*
*
* @param size
* The wanted size
* @param locale
* The locale of the message (only used to format this message,
* otherwise use {@link Assertor#setLocale})
* @param message
* The message on mismatch
* @param arguments
* The arguments of the message, use {@link String#format}
* @return The operator
* @category localized_message
*/
default StepMap hasSizeLT(final int size, final Locale locale, final CharSequence message, final Object... arguments) {
return () -> AssertorMap.hasSizeLT(this.getStep(), size, MessageAssertor.of(locale, message, arguments));
}
/**
* Asserts that the given {@link Map} has a size lower than or equal to
* {@code size}.
*
*
* precondition: {@link Map} cannot be {@code null} and size cannot be lower
* than zero
*
*
*
* Assertor.that(map).hasSizeLTE(size).orElseThrow();
*
*
* @param size
* The wanted size
* @return The operator
* @category no_message
*/
default StepMap hasSizeLTE(final int size) {
return this.hasSizeLTE(size, null);
}
/**
* Asserts that the given {@link Map} has a size lower than or equal to
* {@code size}.
*
*
* precondition: {@link Map} cannot be {@code null} and size cannot be lower
* than zero
*
*
*
* Assertor.that(map).hasSizeLTE(size, "bad size").orElseThrow();
*
*
* @param size
* The wanted size
* @param message
* The message on mismatch
* @param arguments
* The arguments of the message, use {@link String#format}
* @return The operator
* @category message
*/
default StepMap hasSizeLTE(final int size, final CharSequence message, final Object... arguments) {
return this.hasSizeLTE(size, null, message, arguments);
}
/**
* Asserts that the given {@link Map} has a size lower than or equal to
* {@code size}.
*
*
* precondition: {@link Map} cannot be {@code null} and size cannot be lower
* than zero
*
*
*
* Assertor.that(map).hasSizeLTE(size, Locale.US, "bad size").orElseThrow();
*
*
* @param size
* The wanted size
* @param locale
* The locale of the message (only used to format this message,
* otherwise use {@link Assertor#setLocale})
* @param message
* The message on mismatch
* @param arguments
* The arguments of the message, use {@link String#format}
* @return The operator
* @category localized_message
*/
default StepMap hasSizeLTE(final int size, final Locale locale, final CharSequence message, final Object... arguments) {
return () -> AssertorMap.hasSizeLTE(this.getStep(), size, MessageAssertor.of(locale, message, arguments));
}
/**
* Asserts that the given {@link Map} is {@code null} or empty.
*
*
* precondition: none
*
*
*
* Assertor.that(map).isEmpty().orElseThrow();
*
*
* @return The operator
* @category no_message
*/
default StepMap isEmpty() {
return this.isEmpty(null);
}
/**
* Asserts that the given {@link Map} is {@code null} or empty.
*
*
* precondition: none
*
*
*
* Assertor.that(map).isEmpty("the map must be null or empty").orElseThrow();
*
*
* @param message
* The message on mismatch
* @param arguments
* The arguments of the message, use {@link String#format}
* @return The operator
* @category message
*/
default StepMap isEmpty(final CharSequence message, final Object... arguments) {
return this.isEmpty(null, message, arguments);
}
/**
* Asserts that the given {@link Map} is {@code null} or empty.
*
*
* precondition: none
*
*
*
* Assertor.that(map).isEmpty(Locale.US, "the map must be null or empty").orElseThrow();
*
*
* @param locale
* The locale of the message (only used to format this message,
* otherwise use {@link Assertor#setLocale})
* @param message
* The message on mismatch
* @param arguments
* The arguments of the message, use {@link String#format}
* @return The operator
* @category localized_message
*/
default StepMap isEmpty(final Locale locale, final CharSequence message, final Object... arguments) {
return () -> AssertorMap.isEmpty(this.getStep(), MessageAssertor.of(locale, message, arguments));
}
/**
* Asserts that the given {@link Map} is not {@code null} and not empty.
*
*
* precondition: none
*
*
*
* Assertor.that(map).isNotEmpty().orElseThrow();
*
*
* @return The operator
* @category no_message
*/
default StepMap isNotEmpty() {
return this.isNotEmpty(null);
}
/**
* Asserts that the given {@link Map} is not {@code null} and not empty.
*
*
* precondition: none
*
*
*
* Assertor.that(map).isNotEmpty("the map cannot be null or empty").orElseThrow();
*
*
* @param message
* The message on mismatch
* @param arguments
* The arguments of the message, use {@link String#format}
* @return The operator
* @category message
*/
default StepMap isNotEmpty(final CharSequence message, final Object... arguments) {
return this.isNotEmpty(null, message, arguments);
}
/**
* Asserts that the given {@link Map} contains the specified {@code key}.
*
*
* precondition: the {@link Map} cannot be {@code null} or empty
*
*
*
* Assertor.that(map).contains(key).orElseThrow();
*
*
* @param key
* The {@link Map} key
* @return The operator
* @category no_message
*/
default StepMap contains(final K key) {
return this.contains(key, (CharSequence) null);
}
/**
* Asserts that the given {@link Map} contains the specified {@code key}.
*
*
* precondition: the {@link Map} cannot be {@code null} or empty
*
*
*
* Assertor.that(map).contains(key, "the key was not found in the map").orElseThrow();
*
*
* @param key
* The {@link Map} key
* @param message
* The message on mismatch
* @param arguments
* The arguments of the message, use {@link String#format}
* @return The operator
* @category message
*/
default StepMap contains(final K key, final CharSequence message, final Object... arguments) {
return this.contains(key, (Locale) null, message, arguments);
}
/**
* Asserts that the given {@link Map} is not {@code null} and not empty.
*
*
* precondition: none
*
*
*
* Assertor.that(map).isNotEmpty(Locale.US, "the map cannot be null or empty").orElseThrow();
*
*
* @param locale
* The locale of the message (only used to format this message,
* otherwise use {@link Assertor#setLocale})
* @param message
* The message on mismatch
* @param arguments
* The arguments of the message, use {@link String#format}
* @return The operator
* @category localized_message
*/
default StepMap isNotEmpty(final Locale locale, final CharSequence message, final Object... arguments) {
return () -> AssertorMap.isNotEmpty(this.getStep(), MessageAssertor.of(locale, message, arguments));
}
/**
* Check if any map's entry matches the predicate.
*
*
* precondition: {@code map} cannot be {@code null} or empty and predicate
* cannot be {@code null}
*
*
*
* Assertor.that(map).anyMatch(e -> Objects.nonNull(e.getValue())).orElseThrow();
*
*
* @param predicate
* the predicate function that validates each element
* @return the assertor step
* @category no_message
*/
default StepMap anyMatch(final Predicate> predicate) {
return this.anyMatch(predicate, null);
}
/**
* Check if any map's entry matches the predicate.
*
*
* precondition: {@code map} cannot be {@code null} or empty and predicate
* cannot be {@code null}
*
*
*
* Assertor.that(map).anyMatch(e -> Objects.nonNull(e.getValue()), "the map must contain at least on non null value").orElseThrow();
*
*
* @param predicate
* the predicate function that validates each element
* @param message
* the message on mismatch
* @param arguments
* the message arguments
* @return the assertor step
* @category message
*/
default StepMap anyMatch(final Predicate> predicate, final CharSequence message, final Object... arguments) {
return this.anyMatch(predicate, null, message, arguments);
}
/**
* Check if any map's entry matches the predicate.
*
*
* precondition: {@code map} cannot be {@code null} or empty and predicate
* cannot be {@code null}
*
*
*
* Assertor.that(map).anyMatch(e -> Objects.nonNull(e.getValue()), Locale.US, "the map must contain at least on non null value")
* .orElseThrow();
*
*
* @param predicate
* the predicate function that validates each element
* @param locale
* the message locale (only used to format this message,
* otherwise use {@link Assertor#setLocale})
* @param message
* the message on mismatch
* @param arguments
* the message arguments
* @return the assertor step
* @category localized_message
*/
default StepMap anyMatch(final Predicate> predicate, final Locale locale, final CharSequence message,
final Object... arguments) {
return () -> AssertorMap.anyMatch(this.getStep(), predicate, MessageAssertor.of(locale, message, arguments));
}
/**
* Check if all map's entries match the predicate.
*
*
* precondition: {@code map} cannot be {@code null} or empty and predicate
* cannot be {@code null}
*
*
*
* Assertor.that(map).allMatch(e -> Objects.nonNull(e.getValue())).orElseThrow();
*
*
* @param predicate
* the predicate function that validates each entry
* @return the assertor step
* @category no_message
*/
default StepMap allMatch(final Predicate> predicate) {
return this.allMatch(predicate, null);
}
/**
* Check if all map's entries match the predicate.
*
*
* precondition: {@code map} cannot be {@code null} or empty and predicate
* cannot be {@code null}
*
*
*
* Assertor.that(map).allMatch(e -> Objects.nonNull(e.getValue()), "the map cannot contain null value").orElseThrow();
*
*
* @param predicate
* the predicate function that validates each entry
* @param message
* the message on mismatch
* @param arguments
* the message arguments
* @return the assertor step
* @category message
*/
default StepMap allMatch(final Predicate> predicate, final CharSequence message, final Object... arguments) {
return this.allMatch(predicate, null, message, arguments);
}
/**
* Check if all map's entries match the predicate.
*
*
* precondition: {@code map} cannot be {@code null} or empty and predicate
* cannot be {@code null}
*
*
*
* Assertor.that(map).allMatch(e -> Objects.nonNull(e.getValue()), Locale.US, "the map cannot contain null value").orElseThrow();
*
*
* @param predicate
* the predicate function that validates each entry
* @param locale
* the message locale (only used to format this message,
* otherwise use {@link Assertor#setLocale})
* @param message
* the message on mismatch
* @param arguments
* the message arguments
* @return the assertor step
* @category localized_message
*/
default StepMap allMatch(final Predicate> predicate, final Locale locale, final CharSequence message,
final Object... arguments) {
return () -> AssertorMap.allMatch(this.getStep(), predicate, MessageAssertor.of(locale, message, arguments));
}
/**
* Asserts that the given {@link Map} contains the specified {@code key}.
*
*
* precondition: the {@link Map} cannot be {@code null} or empty
*
*
*
* Assertor.that(map).contains(key, Locale.US, "the key was not found in the map").orElseThrow();
*
*
* @param key
* The {@link Map} key
* @param locale
* The locale of the message (only used to format this message,
* otherwise use {@link Assertor#setLocale})
* @param message
* The message on mismatch
* @param arguments
* The arguments of the message, use {@link String#format}
* @return The operator
* @category localized_message
*/
default StepMap contains(final K key, final Locale locale, final CharSequence message, final Object... arguments) {
return () -> AssertorMap.contains(this.getStep(), key, MessageAssertor.of(locale, message, arguments));
}
/**
* Asserts that the given {@link Map} contains the specified pair
* {@code key}/{@code value}.
*
*
* precondition: the {@link Map} cannot be {@code null} or empty
*
*
*
* Assertor.that(map).contains(key, value).orElseThrow();
*
*
* @param key
* The {@link Map} key
* @param value
* The {@link Map} value
* @return The operator
* @category no_message
*/
default StepMap contains(final K key, final V value) {
return this.contains(key, value, null);
}
/**
* Asserts that the given {@link Map} contains the specified pair
* {@code key}/{@code value}.
*
*
* precondition: the {@link Map} cannot be {@code null} or empty
*
*
*
* Assertor.that(map).contains(key, value, "the pair key/value was not found in the map").orElseThrow();
*
*
* @param key
* The {@link Map} key
* @param value
* The {@link Map} value
* @param message
* The message on mismatch
* @param arguments
* The arguments of the message, use {@link String#format}
* @return The operator
* @category message
*/
default StepMap contains(final K key, final V value, final CharSequence message, final Object... arguments) {
return this.contains(key, value, null, message, arguments);
}
/**
* Asserts that the given {@link Map} contains the specified pair
* {@code key}/{@code value}.
*
*
* precondition: the {@link Map} cannot be {@code null} or empty
*
*
*
* Assertor.that(map).contains(key, value, Locale.US, "the pair key/value was not found in the map").orElseThrow();
*
*
* @param key
* The {@link Map} key
* @param value
* The {@link Map} value
* @param locale
* The locale of the message (only used to format this message,
* otherwise use {@link Assertor#setLocale})
* @param message
* The message on mismatch
* @param arguments
* The arguments of the message, use {@link String#format}
* @return The operator
* @category localized_message
*/
default StepMap contains(final K key, final V value, final Locale locale, final CharSequence message, final Object... arguments) {
return () -> AssertorMap.contains(this.getStep(), key, value, MessageAssertor.of(locale, message, arguments));
}
/**
* Asserts that the given {@link Map} contains the specified {@code value}.
*
*
* precondition: the {@link Map} cannot be {@code null} or empty
*
*
*
* Assertor.that(map).containsValue(value).orElseThrow();
*
*
* @param value
* The {@link Map} value
* @return The operator
* @category no_message
*/
default StepMap containsValue(final V value) {
return this.containsValue(value, null);
}
/**
* Asserts that the given {@link Map} contains the specified {@code value}.
*
*
* precondition: the {@link Map} cannot be {@code null} or empty
*
*
*
* Assertor.that(map).contains(key, value, "the value was not found in the map").orElseThrow();
*
*
* @param value
* The {@link Map} value
* @param message
* The message on mismatch
* @param arguments
* The arguments of the message, use {@link String#format}
* @return The operator
* @category message
*/
default StepMap containsValue(final V value, final CharSequence message, final Object... arguments) {
return this.containsValue(value, null, message, arguments);
}
/**
* Asserts that the given {@link Map} contains the specified {@code value}.
*
*
* precondition: the {@link Map} cannot be {@code null} or empty
*
*
*
* Assertor.that(map).contains(value, Locale.US, "the value was not found in the map").orElseThrow();
*
*
* @param value
* The {@link Map} value
* @param locale
* The locale of the message (only used to format this message,
* otherwise use {@link Assertor#setLocale})
* @param message
* The message on mismatch
* @param arguments
* The arguments of the message, use {@link String#format}
* @return The operator
* @category localized_message
*/
default StepMap containsValue(final V value, final Locale locale, final CharSequence message, final Object... arguments) {
return () -> AssertorMap.containsValue(this.getStep(), value, MessageAssertor.of(locale, message, arguments));
}
/**
* Asserts that the given {@link Map} contains ALL the specified
* {@code keys}.
*
*
* precondition: neither {@link Map} and {@code keys} can be {@code null} or
* empty
*
*
*
* Assertor.that(map).containsAll(keys).orElseThrow();
*
*
* @param keys
* The {@link Iterable} keys
* @return The operator
* @category no_message
*/
default StepMap containsAll(final Iterable keys) {
return this.containsAll(keys, null);
}
/**
* Asserts that the given {@link Map} contains ALL the specified
* {@code keys}.
*
*
* precondition: neither {@link Map} and {@code keys} can be {@code null} or
* empty
*
*
*
* Assertor.that(map).containsAll(keys, "not all keys can be found in the map").orElseThrow();
*
*
* @param keys
* The {@link Iterable} keys
* @param message
* The message on mismatch
* @param arguments
* The arguments of the message, use {@link String#format}
* @return The operator
* @category message
*/
default StepMap containsAll(final Iterable keys, final CharSequence message, final Object... arguments) {
return this.containsAll(keys, null, message, arguments);
}
/**
* Asserts that the given {@link Map} contains ALL the specified
* {@code keys}.
*
*
* precondition: neither {@link Map} and {@code keys} can be {@code null} or
* empty
*
*
*
* Assertor.that(map).containsAll(keys, Locale.US, "not all keys can be found in the map").orElseThrow();
*
*
* @param keys
* The {@link Iterable} keys
* @param locale
* The locale of the message (only used to format this message,
* otherwise use {@link Assertor#setLocale})
* @param message
* The message on mismatch
* @param arguments
* The arguments of the message, use {@link String#format}
* @return The operator
* @category localized_message
*/
default StepMap containsAll(final Iterable keys, final Locale locale, final CharSequence message, final Object... arguments) {
return () -> AssertorMap.containsAll(this.getStep(), keys, MessageAssertor.of(locale, message, arguments));
}
/**
* Asserts that the given {@link Map} contains ALL entries from the
* specified {@code map}.
*
*
* precondition: neither {@link Map} can be {@code null} or empty
*
*
*
* Assertor.that(map).containsAll(entries).orElseThrow();
*
*
* @param map
* The {@link Map}
* @return The operator
* @category no_message
*/
default StepMap containsAll(final Map map) {
return this.containsAll(map, null);
}
/**
* Asserts that the given {@link Map} contains ALL entries from the
* specified {@code map}.
*
*
* precondition: neither {@link Map} can be {@code null} or empty
*
*
*
* Assertor.that(map).containsAll(entries, "not all pairs key/value can be found in the map").orElseThrow();
*
*
* @param map
* The {@link Map}
* @param message
* The message on mismatch
* @param arguments
* The arguments of the message, use {@link String#format}
* @return The operator
* @category message
*/
default StepMap containsAll(final Map map, final CharSequence message, final Object... arguments) {
return this.containsAll(map, null, message, arguments);
}
/**
* Asserts that the given {@link Map} contains ALL entries from the
* specified {@code map}.
*
*
* precondition: neither {@link Map} can be {@code null} or empty
*
*
*
* Assertor.that(map).containsAll(entries, Locale.US, "not all pairs key/value can be found in the map").orElseThrow();
*
*
* @param map
* The {@link Map}
* @param locale
* The locale of the message (only used to format this message,
* otherwise use {@link Assertor#setLocale})
* @param message
* The message on mismatch
* @param arguments
* The arguments of the message, use {@link String#format}
* @return The operator
* @category localized_message
*/
default StepMap containsAll(final Map map, final Locale locale, final CharSequence message, final Object... arguments) {
return () -> AssertorMap.containsAll(this.getStep(), map, MessageAssertor.of(locale, message, arguments));
}
/**
* Asserts that the given {@link Map} contains ALL the specified
* {@code values}.
*
*
* precondition: neither {@link Map} and {@code values} can be {@code null}
* or empty
*
*
*
* Assertor.that(map).containsAllValues(values).orElseThrow();
*
*
* @param values
* The {@link Iterable} values
* @return The operator
* @category no_message
*/
default StepMap containsAllValues(final Iterable values) {
return this.containsAllValues(values, null);
}
/**
* Asserts that the given {@link Map} contains ALL the specified
* {@code values}.
*
*
* precondition: neither {@link Map} and {@code values} can be {@code null}
* or empty
*
*
*
* Assertor.that(map).containsAllValues(values, "not all values can be found in the map").orElseThrow();
*
*
* @param values
* The {@link Iterable} values
* @param message
* The message on mismatch
* @param arguments
* The arguments of the message, use {@link String#format}
* @return The operator
* @category message
*/
default StepMap containsAllValues(final Iterable values, final CharSequence message, final Object... arguments) {
return this.containsAllValues(values, null, message, arguments);
}
/**
* Asserts that the given {@link Map} contains ALL the specified
* {@code values}.
*
*
* precondition: neither {@link Map} and {@code values} can be {@code null}
* or empty
*
*
*
* Assertor.that(map).containsAllValues(values, Locale.US, "not all values can be found in the map").orElseThrow();
*
*
* @param values
* The {@link Iterable} values
* @param locale
* The locale of the message (only used to format this message,
* otherwise use {@link Assertor#setLocale})
* @param message
* The message on mismatch
* @param arguments
* The arguments of the message, use {@link String#format}
* @return The operator
* @category localized_message
*/
default StepMap containsAllValues(final Iterable values, final Locale locale, final CharSequence message,
final Object... arguments) {
return () -> AssertorMap.containsAllValues(this.getStep(), values, MessageAssertor.of(locale, message, arguments));
}
/**
* Asserts that the given {@link Map} contains ANY key from the specified
* {@link Iterable}.
*
*
* precondition: neither {@link Map} and {@code keys} can be {@code null} or
* empty
*
*
*
* Assertor.that(map).containsAny(keys).orElseThrow();
*
*
* @param keys
* The {@link Iterable} of keys
* @return The operator
* @category no_message
*/
default StepMap containsAny(final Iterable keys) {
return this.containsAny(keys, null);
}
/**
* Asserts that the given {@link Map} contains ANY key from the specified
* {@link Iterable}.
*
*
* precondition: neither {@link Map} and {@code keys} can be {@code null} or
* empty
*
*
*
* Assertor.that(map).containsAny(keys, "no pair key can be found in the map").orElseThrow();
*
*
* @param keys
* The {@link Iterable} of keys
* @param message
* The message on mismatch
* @param arguments
* The arguments of the message, use {@link String#format}
* @return The operator
* @category message
*/
default StepMap containsAny(final Iterable keys, final CharSequence message, final Object... arguments) {
return this.containsAny(keys, null, message, arguments);
}
/**
* Asserts that the given {@link Map} contains ANY key from the specified
* {@link Iterable}.
*
*
* precondition: neither {@link Map} and {@code keys} can be {@code null} or
* empty
*
*
*
* Assertor.that(map).containsAny(keys, Locale.US, "no pair key can be found in the map").orElseThrow();
*
*
* @param keys
* The {@link Iterable} of keys
* @param locale
* The locale of the message (only used to format this message,
* otherwise use {@link Assertor#setLocale})
* @param message
* The message on mismatch
* @param arguments
* The arguments of the message, use {@link String#format}
* @return The operator
* @category localized_message
*/
default StepMap containsAny(final Iterable keys, final Locale locale, final CharSequence message, final Object... arguments) {
return () -> AssertorMap.containsAny(this.getStep(), keys, MessageAssertor.of(locale, message, arguments));
}
/**
* Asserts that the given {@link Map} contains ANY entries from the
* specified {@code map}.
*
*
* precondition: neither {@link Map} can be {@code null} or empty
*
*
*
* Assertor.that(map).containsAny(entries).orElseThrow();
*
*
* @param map
* The {@link Map}
* @return The operator
* @category no_message
*/
default StepMap containsAny(final Map map) {
return this.containsAny(map, null);
}
/**
* Asserts that the given {@link Map} contains ANY entries from the
* specified {@code map}.
*
*
* precondition: neither {@link Map} can be {@code null} or empty
*
*
*
* Assertor.that(map).containsAny(entries, "no pair key/value can be found in the map").orElseThrow();
*
*
* @param map
* The {@link Map}
* @param message
* The message on mismatch
* @param arguments
* The arguments of the message, use {@link String#format}
* @return The operator
* @category message
*/
default StepMap containsAny(final Map map, final CharSequence message, final Object... arguments) {
return this.containsAny(map, null, message, arguments);
}
/**
* Asserts that the given {@link Map} contains ANY entries from the
* specified {@code map}.
*
*
* precondition: neither {@link Map} can be {@code null} or empty
*
*
*
* Assertor.that(map).containsAny(entries, Locale.US, "no pair key/value can be found in the map").orElseThrow();
*
*
* @param map
* The {@link Map}
* @param locale
* The locale of the message (only used to format this message,
* otherwise use {@link Assertor#setLocale})
* @param message
* The message on mismatch
* @param arguments
* The arguments of the message, use {@link String#format}
* @return The operator
* @category localized_message
*/
default StepMap containsAny(final Map map, final Locale locale, final CharSequence message, final Object... arguments) {
return () -> AssertorMap.containsAny(this.getStep(), map, MessageAssertor.of(locale, message, arguments));
}
/**
* Asserts that the given {@link Map} contains ANY specified {@code values}.
*
*
* precondition: neither {@link Map} and {@code values} can be {@code null}
* or empty
*
*
*
* Assertor.that(map).containsAnyValues(values).orElseThrow();
*
*
* @param values
* The {@link Iterable} values
* @return The operator
* @category no_message
*/
default StepMap containsAnyValues(final Iterable values) {
return this.containsAnyValues(values, null);
}
/**
* Asserts that the given {@link Map} contains ANY specified {@code values}.
*
*
* precondition: neither {@link Map} and {@code values} can be {@code null}
* or empty
*
*
*
* Assertor.that(map).containsAnyValues(values, "not all values can be found in the map").orElseThrow();
*
*
* @param values
* The {@link Iterable} values
* @param message
* The message on mismatch
* @param arguments
* The arguments of the message, use {@link String#format}
* @return The operator
* @category message
*/
default StepMap containsAnyValues(final Iterable values, final CharSequence message, final Object... arguments) {
return this.containsAnyValues(values, null, message, arguments);
}
/**
* Asserts that the given {@link Map} contains ANY specified {@code values}.
*
*
* precondition: neither {@link Map} and {@code values} can be {@code null}
* or empty
*
*
*
* Assertor.that(map).containsAnyValues(values, Locale.US, "not all values can be found in the map").orElseThrow();
*
*
* @param values
* The {@link Iterable} values
* @param locale
* The locale of the message (only used to format this message,
* otherwise use {@link Assertor#setLocale})
* @param message
* The message on mismatch
* @param arguments
* The arguments of the message, use {@link String#format}
* @return The operator
* @category localized_message
*/
default StepMap containsAnyValues(final Iterable values, final Locale locale, final CharSequence message,
final Object... arguments) {
return () -> AssertorMap.containsAnyValues(this.getStep(), values, MessageAssertor.of(locale, message, arguments));
}
/**
* Asserts that the given {@link Map} contains all entries from the
* specified {@code map} in the same order. Each maps must be sorted or
* linked otherwise result is unpredictable.
*
*
* precondition: neither {@link Map} can be {@code null} or empty
*
*
*
* Assertor.that(map).containsInOrder(entries).orElseThrow();
*
*
* @param map
* The {@link Map}
* @return The operator
* @category no_message
*/
default StepMap containsInOrder(final Map map) {
return this.containsInOrder(map, null);
}
/**
* Asserts that the given {@link Map} contains all entries from the
* specified {@code map} in the same order. Each maps must be sorted or
* linked otherwise result is unpredictable.
*
*
* precondition: neither {@link Map} can be {@code null} or empty
*
*
*
* Assertor.that(map).containsInOrder(entries, "the maps are not in the same order").orElseThrow();
*
*
* @param map
* The {@link Map}
* @param message
* The message on mismatch
* @param arguments
* The arguments of the message, use {@link String#format}
* @return The operator
* @category message
*/
default StepMap containsInOrder(final Map map, final CharSequence message, final Object... arguments) {
return this.containsInOrder(map, null, message, arguments);
}
/**
* Asserts that the given {@link Map} contains all entries from the
* specified {@code map} in the same order. Each maps must be sorted or
* linked otherwise result is unpredictable.
*
*
* precondition: neither {@link Map} can be {@code null} or empty
*
*
*
* Assertor.that(map).containsInOrder(entries, Locale.US, "the maps are not in the same order").orElseThrow();
*
*
* @param map
* The {@link Map}
* @param locale
* The locale of the message (only used to format this message,
* otherwise use {@link Assertor#setLocale})
* @param message
* The message on mismatch
* @param arguments
* The arguments of the message, use {@link String#format}
* @return The operator
* @category localized_message
*/
default StepMap containsInOrder(final Map map, final Locale locale, final CharSequence message, final Object... arguments) {
return () -> AssertorMap.containsInOrder(this.getStep(), map, MessageAssertor.of(locale, message, arguments));
}
/**
* Asserts that the given {@link Map} contains all keys in the same order.
* The map and the keys' iterable must be sorted or linked otherwise result
* is unpredictable.
*
*
* precondition: neither {@link Map} nor iterable can be {@code null} or
* empty
*
*
*
* Assertor.that(map).containsInOrder(keys).orElseThrow();
*
*
* @param keys
* The {@link Map} keys
* @return The operator
* @category no_message
*/
default StepMap containsInOrder(final Iterable keys) {
return this.containsInOrder(keys, null);
}
/**
* Asserts that the given {@link Map} contains all keys in the same order.
* The map and the keys' iterable must be sorted or linked otherwise result
* is unpredictable.
*
*
* precondition: neither {@link Map} nor iterable can be {@code null} or
* empty
*
*
*
* Assertor.that(map).containsInOrder(keys, Locale.US, "the keys are not in the same order").orElseThrow();
*
*
* @param keys
* The {@link Map} keys
* @param message
* The message on mismatch
* @param arguments
* The arguments of the message, use {@link String#format}
* @return The operator
* @category localized_message
*/
default StepMap containsInOrder(final Iterable keys, final CharSequence message, final Object... arguments) {
return this.containsInOrder(keys, null, message, arguments);
}
/**
* Asserts that the given {@link Map} contains all keys in the same order.
* The map and the keys' iterable must be sorted or linked otherwise result
* is unpredictable.
*
*
* precondition: neither {@link Map} nor iterable can be {@code null} or
* empty
*
*
*
* Assertor.that(map).containsInOrder(keys, Locale.US, "the keys are not in the same order").orElseThrow();
*
*
* @param keys
* The {@link Map} keys
* @param locale
* The locale of the message (only used to format this message,
* otherwise use {@link Assertor#setLocale})
* @param message
* The message on mismatch
* @param arguments
* The arguments of the message, use {@link String#format}
* @return The operator
* @category localized_message
*/
default StepMap containsInOrder(final Iterable keys, final Locale locale, final CharSequence message,
final Object... arguments) {
return () -> AssertorMap.containsKeysInOrder(this.getStep(), keys, MessageAssertor.of(locale, message, arguments));
}
/**
* Asserts that the given {@link Map} contains all values in the same order.
* The map and the values' iterable must be sorted or linked otherwise
* result is unpredictable.
*
*
* precondition: neither {@link Map} nor iterable can be {@code null} or
* empty
*
*
*
* Assertor.that(map).containsInOrder(values).orElseThrow();
*
*
* @param values
* The {@link Map} values
* @return The operator
* @category no_message
*/
default StepMap containsValuesInOrder(final Iterable values) {
return this.containsValuesInOrder(values, null);
}
/**
* Asserts that the given {@link Map} contains all values in the same order.
* The map and the values' iterable must be sorted or linked otherwise
* result is unpredictable.
*
*
* precondition: neither {@link Map} nor iterable can be {@code null} or
* empty
*
*
*
* Assertor.that(map).containsInOrder(values, "the values are not in the same order").orElseThrow();
*
*
* @param values
* The {@link Map} values
* @param message
* The message on mismatch
* @param arguments
* The arguments of the message, use {@link String#format}
* @return The operator
* @category message
*/
default StepMap containsValuesInOrder(final Iterable values, final CharSequence message, final Object... arguments) {
return this.containsValuesInOrder(values, null, message, arguments);
}
/**
* Asserts that the given {@link Map} contains all values in the same order.
* The map and the values' iterable must be sorted or linked otherwise
* result is unpredictable.
*
*
* precondition: neither {@link Map} nor iterable can be {@code null} or
* empty
*
*
*
* Assertor.that(map).containsInOrder(values, Locale.US, "the values are not in the same order").orElseThrow();
*
*
* @param values
* The {@link Map} values
* @param locale
* The locale of the message (only used to format this message,
* otherwise use {@link Assertor#setLocale})
* @param message
* The message on mismatch
* @param arguments
* The arguments of the message, use {@link String#format}
* @return The operator
* @category localized_message
*/
default StepMap containsValuesInOrder(final Iterable values, final Locale locale, final CharSequence message,
final Object... arguments) {
return () -> AssertorMap.containsValuesInOrder(this.getStep(), values, MessageAssertor.of(locale, message, arguments));
}
}