本文整理汇总了Java中com.ivkos.wallhaven4j.models.misc.enums.Category类的典型用法代码示例。如果您正苦于以下问题:Java Category类的具体用法?Java Category怎么用?Java Category使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Category类属于com.ivkos.wallhaven4j.models.misc.enums包,在下文中一共展示了Category类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Wallpaper
import com.ivkos.wallhaven4j.models.misc.enums.Category; //导入依赖的package包/类
@AssistedInject
Wallpaper(WallhavenSession session,
JsonSerializer jsonSerializer,
ResourceFactoryFactory resourceFactoryFactory,
WallpaperTransformers wallpaperTransformers,
@Assisted boolean preloadDom,
@Assisted("id") long id,
@Assisted Category category,
@Assisted Purity purity,
@Assisted Resolution resolution,
@Assisted("favoritesCount") long favoritesCount)
{
super(session, preloadDom, id);
this.jsonSerializer = jsonSerializer;
this.rff = resourceFactoryFactory;
this.transformers = wallpaperTransformers;
this.category = category;
this.purity = purity;
this.resolution = resolution;
this.favoritesCount = favoritesCount;
if (preloadDom) populateFields();
}
示例2: getCategory
import com.ivkos.wallhaven4j.models.misc.enums.Category; //导入依赖的package包/类
/**
* Returns the category of the wallpaper
*
* @return the category of the wallpaper
*/
@ResourceFieldGetter
public Category getCategory()
{
if (category != null) return category;
String categoryText = of(getElementNextToLabel("Category"), "dd")
.get()
.getText();
switch (categoryText) {
case "General":
category = GENERAL;
break;
case "Anime":
category = ANIME;
break;
case "People":
category = PEOPLE;
break;
default:
throw new ParseException("Could not parse wallpaper category");
}
return category;
}
示例3: isValid
import com.ivkos.wallhaven4j.models.misc.enums.Category; //导入依赖的package包/类
public static boolean isValid(Wallpaper wallpaper) {
if(Utils.toList(Storage.getHistory()).contains(wallpaper.getId())) {
Config.LOGGER.info("Retrying... [Wallpaper already posted]");
return false;
}
if(!WallpaperManager.isAppropriateSize(wallpaper)) {
Config.LOGGER.info("Retrying... [Resolution : " + wallpaper.getResolution() + "]");
return false;
}
if(wallpaper.getViewsCount() < Config.MIN_VIEWS) {
Config.LOGGER.info("Retrying... [Views : " + wallpaper.getViewsCount() + "/" + Config.MIN_VIEWS + "]");
return false;
}
if(WallpaperManager.containsTag(wallpaper, "women") && wallpaper.getCategory().equals(Category.PEOPLE)) {
Config.LOGGER.info("Retrying... [Category : 'People', containing #women]");
return false;
}
if(WallpaperManager.containsTag(wallpaper, "car") && wallpaper.getCategory().equals(Category.GENERAL)) {
Config.LOGGER.info("Retrying... [Category : 'General', containing #car]");
return false;
}
return true;
}
示例4: getHelp
import com.ivkos.wallhaven4j.models.misc.enums.Category; //导入依赖的package包/类
@Override
public EmbedObject getHelp(String prefix) {
return new HelpBuilder(this, prefix)
.setDescription("Search for a wallpaper.")
.setUsage(String.format("[-p %s] [-c %s] [-rat %s] [-res %s] [-k %s]", PURITY, CATEGORY, RATIO, RESOLUTION, KEYWORD))
.addArg(PURITY, FormatUtils.format(Purity.values(), purity -> purity.toString().toLowerCase(), ", "), true)
.addArg(CATEGORY, FormatUtils.format(Category.values(), cat -> cat.toString().toLowerCase(), ", "), true)
.addArg(RATIO, "image ratio (e.g. 16x9)", true)
.addArg(RESOLUTION, "image resolution (e.g. 1920x1080)", true)
.addArg(KEYWORD, "keywords (e.g. doom,game)", true)
.setExample(String.format("Search a *SFW* wallpaper in category *Anime*, with a *16x9* ratio :"
+ "%n`%s%s -p sfw -c anime -rat 16x9`", prefix, this.getName()))
.setSource("https://alpha.wallhaven.cc")
.build();
}
示例5: searchPageWithQuery
import com.ivkos.wallhaven4j.models.misc.enums.Category; //导入依赖的package包/类
@Test
public void searchPageWithQuery() throws Exception
{
SearchQuery query = new SearchQueryBuilder()
.keywords("minimal")
.categories(Category.GENERAL)
.ratios(new Ratio(9, 16))
.build();
List<Wallpaper> page2 = getWallhaven().search(query, 2);
assertFalse(page2.isEmpty());
}
示例6: getCategory
import com.ivkos.wallhaven4j.models.misc.enums.Category; //导入依赖的package包/类
@Test
public void getCategory() throws Exception
{
assertEquals(Category.GENERAL, wSfw.getCategory());
assertEquals(Category.PEOPLE, wSketchy.getCategory());
assertEquals(Category.PEOPLE, wNsfw.getCategory());
}
示例7: create
import com.ivkos.wallhaven4j.models.misc.enums.Category; //导入依赖的package包/类
Wallpaper create(boolean preloadDom,
@Assisted("id") Long id,
Category category,
Purity purity,
Resolution resolution,
@Assisted("favoritesCount") long favoritesCount);
示例8: transform
import com.ivkos.wallhaven4j.models.misc.enums.Category; //导入依赖的package包/类
public Wallpaper transform(HtmlElement figureElement)
{
String idText = figureElement.getDataAttributes().get("wallpaper-id");
//region id
long id;
try {
id = parseLong(idText);
} catch (NumberFormatException e) {
throw new ParseException("Could not parse wallpaper id of wallpaper thumbnail");
}
//endregion
//region category
Category category = figureElement.hasClass("thumb-general") ? GENERAL
: figureElement.hasClass("thumb-anime") ? ANIME
: figureElement.hasClass("thumb-people") ? PEOPLE
: null;
if (category == null) throw new ParseException("Could not parse category of wallpaper thumbnail");
//endregion
//region purity
Purity purity = figureElement.hasClass("thumb-sfw") ? SFW
: figureElement.hasClass("thumb-sketchy") ? SKETCHY
: figureElement.hasClass("thumb-nsfw") ? NSFW
: null;
if (purity == null) throw new ParseException("Could not parse purity of wallpaper thumbnail");
//endregion
//region resolution
HtmlElement resolutionElement = OptionalSelector.of(figureElement, "span.wall-res")
.orElseThrow(forResource(Wallpaper.class, "resolution in thumbnail"));
String resolutionText = resolutionElement.getText().replace(" ", "");
Resolution resolution = Resolution.parse(resolutionText);
//endregion
//region favorites count
String favoritesCountText = OptionalSelector.of(figureElement, "a.wall-favs, span.wall-favs")
.orElseThrow(forResource(Wallpaper.class, "favorites count in thumbnail"))
.getText()
.trim()
.replace(",", "");
long favoritesCount = parseLong(favoritesCountText);
//endregion
WallpaperFactory wallpaperFactory = rff.getFactoryFor(Wallpaper.class);
wallpaperFactory.create(false, id, category, purity, resolution, favoritesCount);
return wallpaperFactory.create(false, id);
}
示例9: categoriesWontAcceptNull
import com.ivkos.wallhaven4j.models.misc.enums.Category; //导入依赖的package包/类
@Test(expected = NullPointerException.class)
public void categoriesWontAcceptNull() throws Exception
{
sqb.categories(((Collection<Category>) null));
}