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.predicate.PredicateAssertorStepMap 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.predicate;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.function.Predicate;
import fr.landel.utils.assertor.Assertor;
import fr.landel.utils.assertor.StepAssertor;
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 PredicateStepMap}. The chain looks like:
*
*
* {@link PredicateAssertorStepMap} > {@link PredicateStepMap} > {@link PredicateAssertorStepMap} > {@link PredicateStepMap}...
*
*
* This chain always starts with a {@link PredicateAssertorStepMap} and ends
* with {@link PredicateStepMap}.
*
* @since Aug 3, 2016
* @author Gilles
*
*/
@FunctionalInterface
public interface PredicateAssertorStepMap extends PredicateAssertorStep, Map> {
/**
* {@inheritDoc}
*/
@Override
default PredicateStepMap get(final StepAssertor> result) {
return () -> result;
}
/**
* {@inheritDoc}
*/
@Override
default PredicateAssertorStepMap 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
*
*
*
* PredicateStepMap<String, Integer> checkMapSize = Assertor.<String, Integer> ofMap().hasSize(size);
* checkMapSize.that(map).orElseThrow();
*
*
* @param size
* The wanted size
* @return The operator
* @category no_message
*/
default PredicateStepMap 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
*
*
*
* PredicateStepMap<String, Integer> checkMapSize = Assertor.<String, Integer> ofMap().hasSize(size, "bad size");
* checkMapSize.that(map).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 PredicateStepMap 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
*
*
*
* PredicateStepMap<String, Integer> checkMapSize = Assertor.<String, Integer> ofMap().hasSize(size, Locale.US, "bad size");
* checkMapSize.that(map).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 PredicateStepMap 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 localized_message
*/
default PredicateStepMap 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 localized_message
*/
default PredicateStepMap 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 PredicateStepMap 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 PredicateStepMap 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 PredicateStepMap 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 PredicateStepMap 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 PredicateStepMap 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 PredicateStepMap 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 PredicateStepMap 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 PredicateStepMap 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 PredicateStepMap 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 PredicateStepMap 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
*
*
*
* PredicateStepMap<String, Integer> checkMapIsEmpty = Assertor.<String, Integer> ofMap().isEmpty();
* checkMapIsEmpty.that(map).orElseThrow();
*
*
* @return The operator
* @category no_message
*/
default PredicateStepMap isEmpty() {
return this.isEmpty(null);
}
/**
* Asserts that the given {@link Map} is {@code null} or empty.
*
*
* precondition: none
*
*
*
* PredicateStepMap<String, Integer> checkMapIsEmpty = Assertor.<String, Integer> ofMap().isEmpty("the map must be null or empty");
* checkMapIsEmpty.that(map).orElseThrow();
*
*
* @param message
* The message on mismatch
* @param arguments
* The arguments of the message, use {@link String#format}
* @return The operator
* @category message
*/
default PredicateStepMap 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
*
*
*
* PredicateStepMap<String, Integer> checkMapIsEmpty = Assertor.<String, Integer> ofMap().isEmpty(Locale.US,
* "the map must be null or empty");
* checkMapIsEmpty.that(map).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 PredicateStepMap 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
*
*
*
* PredicateStepMap<String, Integer> checkMapIsNotEmpty = Assertor.<String, Integer> ofMap().isNotEmpty();
* checkMapIsNotEmpty.that(map).orElseThrow();
*
*
* @return The operator
* @category no_message
*/
default PredicateStepMap isNotEmpty() {
return this.isNotEmpty(null);
}
/**
* Asserts that the given {@link Map} is not {@code null} and not empty.
*
*
* precondition: none
*
*
*
* PredicateStepMap<String, Integer> checkMapIsNotEmpty = Assertor.<String, Integer> ofMap().isNotEmpty("the map cannot be null or empty");
* checkMapIsNotEmpty.that(map).orElseThrow();
*
*
* @param message
* The message on mismatch
* @param arguments
* The arguments of the message, use {@link String#format}
* @return The operator
* @category message
*/
default PredicateStepMap isNotEmpty(final CharSequence message, final Object... arguments) {
return this.isNotEmpty(null, message, arguments);
}
/**
* Asserts that the given {@link Map} is not {@code null} and not empty.
*
*
* precondition: none
*
*
*
* PredicateStepMap<String, Integer> checkMapIsNotEmpty = Assertor.<String, Integer> ofMap().isNotEmpty(Locale.US,
* "the map cannot be null or empty");
* checkMapIsNotEmpty.that(map).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 PredicateStepMap 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 PredicateStepMap 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 PredicateStepMap 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 PredicateStepMap 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 PredicateStepMap 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 PredicateStepMap 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 PredicateStepMap 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
*
*
*
* PredicateStepMap<String, Integer> checkMapContains = Assertor.<String, Integer> ofMap().contains(key);
* checkMapContains.that(map).orElseThrow();
*
*
* @param key
* The {@link Map} key
* @return The operator
* @category no_message
*/
default PredicateStepMap 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
*
*
*
* PredicateStepMap<String, Integer> checkMapContains = Assertor.<String, Integer> ofMap().contains(key,
* "the key was not found in the map");
* checkMapContains.that(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 PredicateStepMap contains(final K key, final CharSequence message, final Object... arguments) {
return this.contains(key, (Locale) null, message, arguments);
}
/**
* Asserts that the given {@link Map} contains the specified {@code key}.
*
*
* precondition: the {@link Map} cannot be {@code null} or empty
*
*
*
* PredicateStepMap<String, Integer> checkMapContains = Assertor.<String, Integer> ofMap().contains(key, Locale.US,
* "the key was not found in the map");
* checkMapContains.that(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 PredicateStepMap 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
*
*
*
* PredicateStepMap<String, Integer> checkMapContains = Assertor.<String, Integer> ofMap().contains(key, value);
* checkMapContains.that(map).orElseThrow();
*
*
* @param key
* The {@link Map} key
* @param value
* The {@link Map} value
* @return The operator
* @category no_message
*/
default PredicateStepMap 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
*
*
*
* PredicateStepMap<String, Integer> checkMapContains = Assertor.<String, Integer> ofMap().contains(key, value,
* "the pair key/value was not found in the map");
* checkMapContains.that(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 PredicateStepMap 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
*
*
*
* PredicateStepMap<String, Integer> checkMapContains = Assertor.<String, Integer> ofMap().contains(key, value, Locale.US,
* "the pair key/value was not found in the map");
* checkMapContains.that(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 PredicateStepMap 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
*
*
*
* PredicateStepMap<String, Integer> checkMapContains = Assertor.<String, Integer> ofMap().contains(value);
* checkMapContains.that(map).orElseThrow();
*
*
* @param value
* The {@link Map} value
* @return The operator
* @category no_message
*/
default PredicateStepMap 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
*
*
*
* PredicateStepMap<String, Integer> checkMapContains = Assertor.<String, Integer> ofMap().contains(value,
* "the value was not found in the map");
* checkMapContains.that(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 PredicateStepMap 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
*
*
*
* PredicateStepMap<String, Integer> checkMapContains = Assertor.<String, Integer> ofMap().contains(value, Locale.US,
* "the value was not found in the map");
* checkMapContains.that(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 PredicateStepMap 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
*
*
*
* PredicateStepMap<String, Integer> checkMapContainsAllKeys = Assertor.<String, Integer> ofMap().containsAll(keys);
* checkMapContainsAllKeys.that(map).orElseThrow();
*
*
* @param keys
* The {@link Iterable} keys
* @return The operator
* @category no_message
*/
default PredicateStepMap 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
*
*
*
* PredicateStepMap<String, Integer> checkMapContainsAllKeys = Assertor.<String, Integer> ofMap().containsAll(keys,
* "not all keys can be found in the map");
* checkMapContainsAllKeys.that(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 PredicateStepMap 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
*
*
*
* PredicateStepMap<String, Integer> checkMapContainsAllKeys = Assertor.<String, Integer> ofMap().containsAll(keys, Locale.US,
* "not all keys can be found in the map");
* checkMapContainsAllKeys.that(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 PredicateStepMap 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
*
*
*
* PredicateStepMap<String, Integer> checkMapContainsAll = Assertor.<String, Integer> ofMap().containsAll(entries);
* checkMapContainsAll.that(map).orElseThrow();
*
*
* @param map
* The {@link Map}
* @return The operator
* @category no_message
*/
default PredicateStepMap 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
*
*
*
* PredicateStepMap<String, Integer> checkMapContainsAll = Assertor.<String, Integer> ofMap().containsAll(entries,
* "not all pairs key/value can be found in the map");
* checkMapContainsAll.that(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 PredicateStepMap 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
*
*
*
* PredicateStepMap<String, Integer> checkMapContainsAll = Assertor.<String, Integer> ofMap().containsAll(entries, Locale.US,
* "not all pairs key/value can be found in the map");
* checkMapContainsAll.that(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 PredicateStepMap 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
*
*
*
* PredicateStepMap<String, Integer> checkMapContainsValues = Assertor.<String, Integer> ofMap().containsAllValues(values);
* checkMapContainsValues.that(map).orElseThrow();
*
*
* @param values
* The {@link Iterable} values
* @return The operator
* @category no_message
*/
default PredicateStepMap 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
*
*
*
* PredicateStepMap<String, Integer> checkMapContainsValues = Assertor.<String, Integer> ofMap().containsAllValues(values,
* "not all values can be found in the map");
* checkMapContainsValues.that(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 PredicateStepMap 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
*
*
*
* PredicateStepMap<String, Integer> checkMapContainsValues = Assertor.<String, Integer> ofMap().containsAllValues(values, Locale.US,
* "not all values can be found in the map");
* checkMapContainsValues.that(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 PredicateStepMap 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
*
*
*
* PredicateStepMap<String, Integer> checkMapContainsAnyKeys = Assertor.<String, Integer> ofMap().containsAny(keys);
* checkMapContainsAnyKeys.that(map).orElseThrow();
*
*
* @param keys
* The {@link Iterable} of keys
* @return The operator
* @category no_message
*/
default PredicateStepMap 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
*
*
*
* PredicateStepMap<String, Integer> checkMapContainsAnyKeys = Assertor.<String, Integer> ofMap().containsAny(keys,
* "no pair key can be found in the map");
* checkMapContainsAnyKeys.that(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 PredicateStepMap 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
*
*
*
* PredicateStepMap<String, Integer> checkMapContainsAnyKeys = Assertor.<String, Integer> ofMap().containsAny(keys, Locale.US,
* "no pair key can be found in the map");
* checkMapContainsAnyKeys.that(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 PredicateStepMap 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
*
*
*
* PredicateStepMap<String, Integer> checkMapContainsAny = Assertor.<String, Integer> ofMap().containsAny(entries);
* checkMapContainsAny.that(map).orElseThrow();
*
*
* @param map
* The {@link Map}
* @return The operator
* @category no_message
*/
default PredicateStepMap 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
*
*
*
* PredicateStepMap<String, Integer> checkMapContainsAny = Assertor.<String, Integer> ofMap().containsAny(entries,
* "no pair key/value can be found in the map");
* checkMapContainsAny.that(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 PredicateStepMap 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
*
*
*
* PredicateStepMap<String, Integer> checkMapContainsAny = Assertor.<String, Integer> ofMap().containsAny(entries, Locale.US,
* "no pair key/value can be found in the map");
* checkMapContainsAny.that(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 PredicateStepMap 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 PredicateStepMap 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 PredicateStepMap 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 PredicateStepMap 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
*
*
*
* PredicateStepMap<String, Integer> checkMapOrder = Assertor.<String, Integer> ofMap().containsInOrder(entries);
* checkMapOrder.that(map).orElseThrow();
*
*
* @param map
* The {@link Map}
* @return The operator
* @category message
*/
default PredicateStepMap 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
*
*
*
* PredicateStepMap<String, Integer> checkMapOrder = Assertor.<String, Integer> ofMap().containsInOrder(entries,
* "the maps are not in the same order");
* checkMapOrder.that(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 PredicateStepMap 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
*
*
*
* PredicateStepMap<String, Integer> checkMapOrder = Assertor.<String, Integer> ofMap().containsInOrder(entries, Locale.US,
* "the maps are not in the same order");
* checkMapOrder.that(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 PredicateStepMap 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
*
*
*
* PredicateStepMap<String, Integer> checkMapOrder = Assertor.<String, Integer> ofMap().containsInOrder(keys);
* checkMapOrder.that(map).orElseThrow();
*
*
* @param keys
* The keys' {@link Iterable}
* @return The operator
* @category no_message
*/
default PredicateStepMap 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
*
*
*
* PredicateStepMap<String, Integer> checkMapOrder = Assertor.<String, Integer> ofMap().containsInOrder(keys,
* "the keys are not in the same order");
* checkMapOrder.that(map).orElseThrow();
*
*
* @param keys
* The keys' {@link Iterable}
* @param message
* The message on mismatch
* @param arguments
* The arguments of the message, use {@link String#format}
* @return The operator
* @category message
*/
default PredicateStepMap 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
*
*
*
* PredicateStepMap<String, Integer> checkMapOrder = Assertor.<String, Integer> ofMap().containsInOrder(keys, Locale.US,
* "the keys are not in the same order");
* checkMapOrder.that(map).orElseThrow();
*
*
* @param keys
* The keys' {@link Iterable}
* @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 PredicateStepMap 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
*
*
*
* PredicateStepMap<String, Integer> checkMapOrder = Assertor.<String, Integer> ofMap().containsInOrder(values);
* checkMapOrder.that(map).orElseThrow();
*
*
* @param values
* The values' {@link Iterable}
* @return The operator
* @category no_message
*/
default PredicateStepMap 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
*
*
*
* PredicateStepMap<String, Integer> checkMapOrder = Assertor.<String, Integer> ofMap().containsInOrder(values,
* "the values are not in the same order");
* checkMapOrder.that(map).orElseThrow();
*
*
* @param values
* The values' {@link Iterable}
* @param message
* The message on mismatch
* @param arguments
* The arguments of the message, use {@link String#format}
* @return The operator
* @category message
*/
default PredicateStepMap 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
*
*
*
* PredicateStepMap<String, Integer> checkMapOrder = Assertor.<String, Integer> ofMap().containsInOrder(values, Locale.US,
* "the values are not in the same order");
* checkMapOrder.that(map).orElseThrow();
*
*
* @param values
* The values' {@link Iterable}
* @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 PredicateStepMap containsValuesInOrder(final Iterable values, final Locale locale, final CharSequence message,
final Object... arguments) {
return () -> AssertorMap.containsValuesInOrder(this.getStep(), values, MessageAssertor.of(locale, message, arguments));
}
}