com.tngtech.archunit.base.Guava Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of archunit Show documentation
Show all versions of archunit Show documentation
A Java architecture test library, to specify and assert architecture rules in plain Java - Module 'archunit'
/*
* Copyright 2017 TNG Technology Consulting GmbH
*
* 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 com.tngtech.archunit.base;
import java.util.Map;
import com.google.common.base.Predicate;
import com.tngtech.archunit.Internal;
/**
* NOTE: We keep Google Guava out of the public API and use the Gradle Shadow plugin to repackage the internally
* used Guava classes. This ensures they don't clash with other versions of Guava we might encounter while
* scanning classes from the classpath.
*/
@Internal
public final class Guava {
private static Predicate toGuava(final DescribedPredicate predicate) {
return new Predicate() {
@Override
public boolean apply(T input) {
return predicate.apply(input);
}
};
}
@Internal
public static final class Maps {
public static Map filterValues(Map map, DescribedPredicate super V> predicate) {
return com.google.common.collect.Maps.filterValues(map, toGuava(predicate));
}
}
@Internal
public static final class Iterables {
public static Iterable filter(Iterable iterable, DescribedPredicate super T> predicate) {
return com.google.common.collect.Iterables.filter(iterable, toGuava(predicate));
}
}
}