/* __ __ __ __ __ ___ * \ \ / / \ \ / / __/ * \ \/ / /\ \ \/ / / * \____/__/ \__\____/__/ * * Copyright 2014-2017 Vavr, http://vavr.io * * 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 ch.usi.inf.sdm.sdm04; import ch.usi.si.codelounge.jsicko.Contract; import java.util.stream.StreamSupport; @SuppressWarnings("unused") // methods used by jSicko public interface CharRangeContracts extends Contract { @Pure char getStart(); @Pure char getEnd(); @Pure boolean isNegated(); @Pure boolean contains(final char ch); @Pure default boolean char_range_is_not_null(final CharRange range) { return range != null; } @Pure default boolean contains_uses_start_end_range(final boolean returns, final char ch) { return returns == (this.isNegated() != (this.getStart() <= ch && this.getEnd() >= ch)); } @Pure default boolean characters_in_param_are_in_this(final boolean returns, final CharRange range) { return returns == StreamSupport.stream(range.spliterator(), false).allMatch(this::contains); } }