|
| 1 | +/* |
| 2 | + * Copyright 2017-present the original author or authors. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
| 13 | + * or implied. See the License for the specific language governing |
| 14 | + * permissions and limitations under the License. |
| 15 | + */ |
| 16 | +package org.springframework.data.gemfire.tests.util; |
| 17 | + |
| 18 | +import java.io.FileFilter; |
| 19 | + |
| 20 | +import org.springframework.lang.NonNull; |
| 21 | +import org.springframework.lang.Nullable; |
| 22 | + |
| 23 | +/** |
| 24 | + * Java {@link FileFilter} implementation capable of being composed |
| 25 | + * |
| 26 | + * @author John Blum |
| 27 | + * @see java.lang.FunctionalInterface |
| 28 | + * @see java.io.FileFilter |
| 29 | + * @since 0.3.5-RAJ |
| 30 | + */ |
| 31 | +@FunctionalInterface |
| 32 | +@SuppressWarnings("unused") |
| 33 | +public interface ComposableFileFilter extends FileFilter { |
| 34 | + |
| 35 | + default @NonNull ComposableFileFilter andThen(@Nullable ComposableFileFilter fileFilter) { |
| 36 | + return fileFilter == null ? this |
| 37 | + : file -> this.accept(file) && fileFilter.accept(file); |
| 38 | + } |
| 39 | + |
| 40 | + default @NonNull ComposableFileFilter orThen(@Nullable ComposableFileFilter fileFilter) { |
| 41 | + return fileFilter == null ? this |
| 42 | + : file -> this.accept(file) || fileFilter.accept(file); |
| 43 | + } |
| 44 | +} |
0 commit comments