mirror of https://github.com/apache/jclouds.git
don't consider field equivalence when using ofApi
This commit is contained in:
parent
af3a226b3d
commit
d1fdc504c0
|
@ -206,22 +206,22 @@ public class ProviderPredicates {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all providers with the given api.
|
* Returns all providers with an instance of the given api.
|
||||||
*
|
*
|
||||||
* @param type
|
* @param apiClass
|
||||||
* the type of the provider to return
|
* the api of the provider to return
|
||||||
*
|
*
|
||||||
* @return the providers with the given api
|
* @return the providers with the given api
|
||||||
*/
|
*/
|
||||||
public static Predicate<ProviderMetadata> api(final ApiMetadata api) {
|
public static Predicate<ProviderMetadata> apiInstanceOf(final Class<? extends ApiMetadata> apiClass) {
|
||||||
Preconditions.checkNotNull(api, "api must be defined");
|
Preconditions.checkNotNull(apiClass, "api must be defined");
|
||||||
return new Predicate<ProviderMetadata>() {
|
return new Predicate<ProviderMetadata>() {
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(ProviderMetadata providerMetadata) {
|
public boolean apply(ProviderMetadata providerMetadata) {
|
||||||
return providerMetadata.getApi().equals(api);
|
return Predicates.instanceOf(apiClass).apply(providerMetadata.getApi());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -229,7 +229,7 @@ public class ProviderPredicates {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "api(" + api + ")";
|
return "apiInstanceOf(" + apiClass + ")";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ import java.util.ServiceLoader;
|
||||||
import org.jclouds.apis.ApiMetadata;
|
import org.jclouds.apis.ApiMetadata;
|
||||||
import org.jclouds.apis.ApiType;
|
import org.jclouds.apis.ApiType;
|
||||||
|
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
import com.google.common.base.Predicates;
|
import com.google.common.base.Predicates;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -141,7 +142,8 @@ public class Providers {
|
||||||
* @return the providers of the provided api
|
* @return the providers of the provided api
|
||||||
*/
|
*/
|
||||||
public static Iterable<ProviderMetadata> ofApi(ApiMetadata api) {
|
public static Iterable<ProviderMetadata> ofApi(ApiMetadata api) {
|
||||||
return filter(all(), ProviderPredicates.api(api));
|
Preconditions.checkNotNull(api, "api must be defined");
|
||||||
|
return filter(all(), ProviderPredicates.apiInstanceOf(api.getClass()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue