當前位置: 首頁>>代碼示例>>Java>>正文


Java Category類代碼示例

本文整理匯總了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();
}
 
開發者ID:ivkos,項目名稱:wallhaven4j,代碼行數:26,代碼來源:Wallpaper.java

示例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;
}
 
開發者ID:ivkos,項目名稱:wallhaven4j,代碼行數:31,代碼來源:Wallpaper.java

示例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;
}
 
開發者ID:Shadorc,項目名稱:1Day1Wallpaper,代碼行數:29,代碼來源:WallpaperManager.java

示例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();
}
 
開發者ID:Shadorc,項目名稱:Shadbot,代碼行數:16,代碼來源:WallpaperCmd.java

示例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());
}
 
開發者ID:ivkos,項目名稱:wallhaven4j,代碼行數:14,代碼來源:WallhavenTest.java

示例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());
}
 
開發者ID:ivkos,項目名稱:wallhaven4j,代碼行數:8,代碼來源:WallpaperTest.java

示例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);
 
開發者ID:ivkos,項目名稱:wallhaven4j,代碼行數:7,代碼來源:WallpaperFactory.java

示例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);
}
 
開發者ID:ivkos,項目名稱:wallhaven4j,代碼行數:55,代碼來源:ThumbnailTransformer.java

示例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));
}
 
開發者ID:ivkos,項目名稱:wallhaven4j,代碼行數:6,代碼來源:SearchQueryBuilderTest.java


注:本文中的com.ivkos.wallhaven4j.models.misc.enums.Category類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。