brooklyn.catalog.CatalogPredicates Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of brooklyn-core Show documentation
Show all versions of brooklyn-core Show documentation
Entity implementation classes, events, and other core elements
package brooklyn.catalog;
import javax.annotation.Nullable;
import brooklyn.catalog.CatalogItem.CatalogItemType;
import brooklyn.entity.Application;
import brooklyn.entity.Entity;
import brooklyn.policy.Policy;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
public class CatalogPredicates {
public static Predicate> isCatalogItemType(final CatalogItemType ciType) {
return new Predicate>() {
@Override
public boolean apply(@Nullable CatalogItem item) {
return item!=null && item.getCatalogItemType()==ciType;
}
};
}
public static final Predicate> IS_TEMPLATE =
CatalogPredicates.isCatalogItemType(CatalogItemType.TEMPLATE);
public static final Predicate> IS_ENTITY =
CatalogPredicates.isCatalogItemType(CatalogItemType.ENTITY);
public static final Predicate> IS_POLICY =
CatalogPredicates.isCatalogItemType(CatalogItemType.POLICY);
public static final Function,String> ID_OF_ITEM_TRANSFORMER = new Function, String>() {
@Override @Nullable
public String apply(@Nullable CatalogItem> input) {
if (input==null) return null;
return input.getId();
}
};
public static Predicate> name(final Predicate super String> filter) {
return new Predicate>() {
@Override
public boolean apply(@Nullable CatalogItem item) {
return item!=null && filter.apply(item.getName());
}
};
}
public static Predicate> javaType(final Predicate super String> filter) {
return new Predicate>() {
@Override
public boolean apply(@Nullable CatalogItem item) {
return item!=null && filter.apply(item.getJavaType());
}
};
}
public static Predicate> xml(final Predicate super String> filter) {
return new Predicate>() {
@Override
public boolean apply(@Nullable CatalogItem item) {
return item!=null && filter.apply(item.toXmlString());
}
};
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy