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


Java EnumUtils.isValidEnum方法代碼示例

本文整理匯總了Java中org.apache.commons.lang3.EnumUtils.isValidEnum方法的典型用法代碼示例。如果您正苦於以下問題:Java EnumUtils.isValidEnum方法的具體用法?Java EnumUtils.isValidEnum怎麽用?Java EnumUtils.isValidEnum使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.lang3.EnumUtils的用法示例。


在下文中一共展示了EnumUtils.isValidEnum方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: SummonerQueryForwardPage

import org.apache.commons.lang3.EnumUtils; //導入方法依賴的package包/類
public SummonerQueryForwardPage(PageParameters parameters) {
    super(parameters, "Summoner Search", null);
    // get summoner name and region sent by the form
    String summonerName = parameters.get("summonerName").toString("");
    String regionName = parameters.get("region").toString("").toUpperCase();

    // insert data to error page
    add(new Label("summoner_name", summonerName));
    add(new Label("region", regionName));

    // check if summoner name and region are valid, if not return to show error page
    if (summonerName == null || summonerName.length() == 0) return;
    if (!EnumUtils.isValidEnum(RiotEndpoint.class, regionName)) return;

    // convert region name to RiotEndpoint object
    RiotEndpoint region = RiotEndpoint.valueOf(regionName);

    // generate the summoners statistic
    Pair<String, SummonerStatisticItem> summonerStatistic = PageDataProvider.generateSummonerStatistic(summonerName, region);
    // if statistic generation failed, return to show error page
    if (summonerStatistic == null) return;

    // forward to single summoner page with region and summoner key name
    throw new RestartResponseAtInterceptPageException(SingleSummonerPage.class, new PageParameters()
            .set(0, regionName).set(1, summonerStatistic.getKey()));
}
 
開發者ID:LogicalOverflow,項目名稱:MasterStats,代碼行數:27,代碼來源:SummonerQueryForwardPage.java

示例2: disableModule

import org.apache.commons.lang3.EnumUtils; //導入方法依賴的package包/類
@Authenticated(value = {LoggedIn.class, HasRole.class})
@Authorized(value = {"moderator", "admin"})
@Transactional
public Result disableModule(long forumId, String forumModule) throws ForumNotFoundException {
    Forum forum = forumService.findForumById(forumId);

    if (!EnumUtils.isValidEnum(ForumModules.class, forumModule)) {
        return redirect(routes.ForumController.editForumModuleConfig(forum.getId()));
    }

    ForumModules forumModuleType = ForumModules.valueOf(forumModule);
    if (forum.getModulesSet().containsAll(ForumModuleUtils.getDependedModules(forumModuleType)) && !ForumModuleUtils.getDependedModules(forumModuleType).isEmpty()) {
        flashError(Messages.get("forum.module.disable.error.dependencies", ForumModuleUtils.getDependedModules(forumModuleType).toString()));
        return redirect(routes.ForumController.editForumModuleConfig(forum.getId()));
    }

    forumModuleService.disableModule(forum.getJid(), ForumModules.valueOf(forumModule));

    return redirect(routes.ForumController.editForumModuleConfig(forum.getId()));
}
 
開發者ID:judgels,項目名稱:raguel,代碼行數:21,代碼來源:ForumController.java

示例3: enableModule

import org.apache.commons.lang3.EnumUtils; //導入方法依賴的package包/類
@Authenticated(value = {LoggedIn.class, HasRole.class})
@Transactional
public Result enableModule(long contestId, String contestModule) throws ContestNotFoundException {
    Contest contest = contestService.findContestById(contestId);
    if (contest.isLocked() || !EnumUtils.isValidEnum(ContestModules.class, contestModule) || !ContestControllerUtils.getInstance().isAllowedToManageContest(contest, IdentityUtils.getUserJid())) {
        return redirect(org.iatoki.judgels.uriel.contest.routes.ContestController.editContestModuleConfig(contest.getId()));
    }

    ContestModules contestModuleType = ContestModules.valueOf(contestModule);
    if (!ContestModuleUtils.getModuleContradiction(contestModuleType).isEmpty() && contest.getModulesSet().containsAll(ContestModuleUtils.getModuleContradiction(contestModuleType))) {
        flashError(Messages.get("contest.module.enable.error.contradiction", ContestModuleUtils.getModuleContradiction(contestModuleType).toString()));
        return redirect(org.iatoki.judgels.uriel.contest.routes.ContestController.editContestModuleConfig(contest.getId()));
    }

    if (!contest.getModulesSet().containsAll(ContestModuleUtils.getModuleDependencies(contestModuleType))) {
        flashError(Messages.get("contest.module.enable.error.dependencies", ContestModuleUtils.getModuleDependencies(contestModuleType).toString()));
        return redirect(org.iatoki.judgels.uriel.contest.routes.ContestController.editContestModuleConfig(contest.getId()));
    }

    contestModuleService.enableModule(contest.getJid(), contestModuleType, IdentityUtils.getUserJid(), IdentityUtils.getIpAddress());

    return redirect(org.iatoki.judgels.uriel.contest.routes.ContestController.editContestModuleConfig(contest.getId()));
}
 
開發者ID:judgels,項目名稱:uriel,代碼行數:24,代碼來源:ContestController.java

示例4: disableModule

import org.apache.commons.lang3.EnumUtils; //導入方法依賴的package包/類
@Authenticated(value = {LoggedIn.class, HasRole.class})
@Transactional
public Result disableModule(long contestId, String contestModule) throws ContestNotFoundException {
    Contest contest = contestService.findContestById(contestId);
    if (contest.isLocked() || !EnumUtils.isValidEnum(ContestModules.class, contestModule) || !ContestControllerUtils.getInstance().isAllowedToManageContest(contest, IdentityUtils.getUserJid())) {
        return redirect(org.iatoki.judgels.uriel.contest.routes.ContestController.editContestModuleConfig(contest.getId()));
    }

    ContestModules contestModuleType = ContestModules.valueOf(contestModule);
    if (contest.getModulesSet().containsAll(ContestModuleUtils.getDependedModules(contestModuleType)) && !ContestModuleUtils.getDependedModules(contestModuleType).isEmpty()) {
        flashError(Messages.get("contest.module.disable.error.dependencies", ContestModuleUtils.getDependedModules(contestModuleType).toString()));
        return redirect(org.iatoki.judgels.uriel.contest.routes.ContestController.editContestModuleConfig(contest.getId()));
    }

    contestModuleService.disableModule(contest.getJid(), contestModuleType, IdentityUtils.getUserJid(), IdentityUtils.getIpAddress());

    return redirect(org.iatoki.judgels.uriel.contest.routes.ContestController.editContestModuleConfig(contest.getId()));
}
 
開發者ID:judgels,項目名稱:uriel,代碼行數:19,代碼來源:ContestController.java

示例5: converterDtoParaLancamento

import org.apache.commons.lang3.EnumUtils; //導入方法依賴的package包/類
/**
 * Converte um LancamentoDto para uma entidade Lancamento.
 * 
 * @param lancamentoDto
 * @param result
 * @return Lancamento
 * @throws ParseException 
 */
private Lancamento converterDtoParaLancamento(LancamentoDto lancamentoDto, BindingResult result) throws ParseException {
	Lancamento lancamento = new Lancamento();

	if (lancamentoDto.getId().isPresent()) {
		Optional<Lancamento> lanc = this.lancamentoService.buscarPorId(lancamentoDto.getId().get());
		if (lanc.isPresent()) {
			lancamento = lanc.get();
		} else {
			result.addError(new ObjectError("lancamento", "Lançamento não encontrado."));
		}
	} else {
		lancamento.setFuncionario(new Funcionario());
		lancamento.getFuncionario().setId(lancamentoDto.getFuncionarioId());
	}

	lancamento.setDescricao(lancamentoDto.getDescricao());
	lancamento.setLocalizacao(lancamentoDto.getLocalizacao());
	lancamento.setData(this.dateFormat.parse(lancamentoDto.getData()));

	if (EnumUtils.isValidEnum(TipoEnum.class, lancamentoDto.getTipo())) {
		lancamento.setTipo(TipoEnum.valueOf(lancamentoDto.getTipo()));
	} else {
		result.addError(new ObjectError("tipo", "Tipo inválido."));
	}

	return lancamento;
}
 
開發者ID:m4rciosouza,項目名稱:ponto-inteligente-api,代碼行數:36,代碼來源:LancamentoController.java

示例6: validateSiteToSiteProtocol

import org.apache.commons.lang3.EnumUtils; //導入方法依賴的package包/類
/**
 * Validates Protocol with Enum value.
 * 
 * @param inputProtocol
 * @return HTTP by default
 */
private SiteToSiteTransportProtocol validateSiteToSiteProtocol(String inputProtocol) {
	if (EnumUtils.isValidEnum(SiteToSiteTransportProtocol.class, inputProtocol)) {
		return SiteToSiteTransportProtocol.valueOf(inputProtocol);
	} else {
		// Protocol not validaed. Using HTTP by default
		return SiteToSiteTransportProtocol.HTTP;
	}
}
 
開發者ID:pradeepmvn,項目名稱:logback-nifi-appender,代碼行數:15,代碼來源:NifiAppenderConfigurations.java

示例7: setBossBarStyle

import org.apache.commons.lang3.EnumUtils; //導入方法依賴的package包/類
@Override
public boolean setBossBarStyle(BarStyle style, BarColor colour) {
	try {
		Field fieldBossBattleServer = EnderDragonBattle.class.getDeclaredField("c");
		fieldBossBattleServer.setAccessible(true);
		
		BossBattleServer battleServer = (BossBattleServer) fieldBossBattleServer.get(battle);
		if (battleServer == null) return false;
		
		if (style != null) {
			String nmsStyle = style.name().contains("SEGMENTED") ? style.name().replace("SEGMENTED", "NOTCHED") : "PROGRESS";
			if (EnumUtils.isValidEnum(BossBattle.BarStyle.class, nmsStyle)) {
				battleServer.style = BossBattle.BarStyle.valueOf(nmsStyle);
			}
		}
		if (colour != null) {
			battleServer.color = BossBattle.BarColor.valueOf(colour.name());
		}
		
		battleServer.sendUpdate(PacketPlayOutBoss.Action.UPDATE_STYLE);
		fieldBossBattleServer.setAccessible(false);
	} catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
		e.printStackTrace();
		return false;
	}
	
	return true;
}
 
開發者ID:2008Choco,項目名稱:DragonEggDrop,代碼行數:29,代碼來源:DragonBattle1_10_R1.java

示例8: checkMode

import org.apache.commons.lang3.EnumUtils; //導入方法依賴的package包/類
/**
 * Checks the mode string
 *
 * @throws IllegalArgumentException If not valid
 */
private void checkMode() {
    val mode = config.getString("mode");

    if (!EnumUtils.isValidEnum(MovieHandler.Type.class, mode)) {
        throw new IllegalArgumentException("mode is not valid!");
    }
}
 
開發者ID:REDNBLACK,項目名稱:J-Kinopoisk2IMDB,代碼行數:13,代碼來源:ConfigValidator.java

示例9: enableModule

import org.apache.commons.lang3.EnumUtils; //導入方法依賴的package包/類
@Authenticated(value = {LoggedIn.class, HasRole.class})
@Authorized(value = {"moderator", "admin"})
@Transactional
public Result enableModule(long forumId, String forumModule) throws ForumNotFoundException {
    Forum forum = forumService.findForumById(forumId);

    if (!EnumUtils.isValidEnum(ForumModules.class, forumModule)) {
        return redirect(routes.ForumController.editForumModuleConfig(forum.getId()));
    }

    ForumModules forumModuleType = ForumModules.valueOf(forumModule);
    if (!ForumModuleUtils.getModuleContradiction(forumModuleType).isEmpty() && forum.getModulesSet().containsAll(ForumModuleUtils.getModuleContradiction(forumModuleType))) {
        flashError(Messages.get("forum.module.enable.error.contradiction", ForumModuleUtils.getModuleContradiction(forumModuleType).toString()));
        return redirect(routes.ForumController.editForumModuleConfig(forum.getId()));
    }

    if (!forum.getModulesSet().containsAll(ForumModuleUtils.getModuleDependencies(forumModuleType))) {
        flashError(Messages.get("forum.module.enable.error.dependencies", ForumModuleUtils.getModuleDependencies(forumModuleType).toString()));
        return redirect(routes.ForumController.editForumModuleConfig(forum.getId()));
    }

    // error if inherited
    if (EnumUtils.isValidEnum(InheritedForumModules.class, forumModule) && (forum.inheritModule(forumModuleType))) {
        flashError(Messages.get("forum.module.enable.error.inherited", ForumModuleUtils.getModuleDependencies(forumModuleType).toString()));
        return redirect(routes.ForumController.editForumModuleConfig(forum.getId()));
    }

    forumModuleService.enableModule(forum.getJid(), ForumModules.valueOf(forumModule));

    return redirect(routes.ForumController.editForumModuleConfig(forum.getId()));
}
 
開發者ID:judgels,項目名稱:raguel,代碼行數:32,代碼來源:ForumController.java

示例10: postEditContestant

import org.apache.commons.lang3.EnumUtils; //導入方法依賴的package包/類
@Transactional
@RequireCSRFCheck
public Result postEditContestant(long contestId, long contestContestantId) throws ContestNotFoundException, ContestContestantNotFoundException {
    Contest contest = contestService.findContestById(contestId);
    ContestContestant contestContestant = contestContestantService.findContestantInContestById(contestContestantId);
    if (contest.isLocked() || !isAllowedToSuperviseContestants(contest) || !contestContestant.getContestJid().equals(contest.getJid())) {
        return ContestControllerUtils.getInstance().tryEnteringContest(contest, IdentityUtils.getUserJid());
    }

    Form<ContestContestantEditForm> contestContestantEditForm = Form.form(ContestContestantEditForm.class).bindFromRequest();

    if (formHasErrors(contestContestantEditForm)) {
        return showEditContestant(contestContestantEditForm, contest, contestContestant);
    }

    ContestContestantEditForm contestContestantEditData = contestContestantEditForm.get();

    if (!EnumUtils.isValidEnum(ContestContestantStatus.class, contestContestantEditData.status)) {
        return showEditContestant(contestContestantEditForm, contest, contestContestant);
    }

    contestContestantService.updateContestContestant(contestContestant.getId(), ContestContestantStatus.valueOf(contestContestantEditData.status), IdentityUtils.getUserJid(), IdentityUtils.getIpAddress());

    UrielControllerUtils.getInstance().addActivityLog(BasicActivityKeys.EDIT_IN.construct(CONTEST, contest.getJid(), contest.getName(), CONTESTANT, contestContestant.getUserJid(), JidCacheServiceImpl.getInstance().getDisplayName(contestContestant.getUserJid())));

    return redirect(routes.ContestContestantController.viewContestants(contest.getId()));
}
 
開發者ID:judgels,項目名稱:uriel,代碼行數:28,代碼來源:ContestContestantController.java

示例11: composeCardSection

import org.apache.commons.lang3.EnumUtils; //導入方法依賴的package包/類
private List<String> composeCardSection(List<Event> events, EventsContext context) {
    //

    List<String> res = new ArrayList<>();
    for (Event e : events) {
        if (EnumUtils.isValidEnum(SupportedEventType.class, e.getEvent().toString())) {
            ImmutablePair<String, String[]> message = SupportedEventType.valueOf(e.getEvent().toString())
                .toKeyAndParam(e, context, cardDataRepository);
            res.add(messageSource.getMessage(message.getKey(), message.getValue(), Locale.ENGLISH));
        }
    }
    return res;
}
 
開發者ID:digitalfondue,項目名稱:lavagna,代碼行數:14,代碼來源:NotificationService.java

示例12: DateTimeFormatUnitSpec

import org.apache.commons.lang3.EnumUtils; //導入方法依賴的package包/類
public DateTimeFormatUnitSpec(String unit) {
  if (!isValidUnitSpec(unit)) {
    throw new IllegalArgumentException("Unit must belong to enum TimeUnit or DateTimeTransformUnit");
  }
  if (EnumUtils.isValidEnum(TimeUnit.class, unit)) {
    _timeUnit = TimeUnit.valueOf(unit);
  }
  if (EnumUtils.isValidEnum(DateTimeTransformUnit.class, unit)) {
    _dateTimeTransformUnit = DateTimeTransformUnit.valueOf(unit);
  }
}
 
開發者ID:linkedin,項目名稱:pinot,代碼行數:12,代碼來源:DateTimeFormatUnitSpec.java

示例13: getTimeConverter

import org.apache.commons.lang3.EnumUtils; //導入方法依賴的package包/類
public static TimeUnitConverter getTimeConverter(String timeUnitName) {
  String name = timeUnitName.toUpperCase();
  if (EnumUtils.isValidEnum(TimeUnit.class, name)) {
    return new JavaTimeUnitConverter(name);
  } else {
    return new CustomTimeUnitConverter(name);
  }
}
 
開發者ID:linkedin,項目名稱:pinot,代碼行數:9,代碼來源:TimeConverterFactory.java

示例14: exists

import org.apache.commons.lang3.EnumUtils; //導入方法依賴的package包/類
public static boolean exists(String val) {
	return EnumUtils.isValidEnum(FeatureCode.class, val);
}
 
開發者ID:chrismattmann,項目名稱:lucene-geo-gazetteer,代碼行數:4,代碼來源:CustomLuceneGeoGazetteerComparator.java

示例15: postAddContestant

import org.apache.commons.lang3.EnumUtils; //導入方法依賴的package包/類
@Transactional
@RequireCSRFCheck
public Result postAddContestant(long contestId, long pageIndex, String orderBy, String orderDir, String filterString) throws ContestNotFoundException {
    Contest contest = contestService.findContestById(contestId);
    if (contest.isLocked() || !isAllowedToSuperviseContestants(contest)) {
        return ContestControllerUtils.getInstance().tryEnteringContest(contest, IdentityUtils.getUserJid());
    }

    Form<ContestContestantAddForm> contestContestantCreateForm = Form.form(ContestContestantAddForm.class).bindFromRequest();
    boolean canDelete = ContestControllerUtils.getInstance().isManagerOrAbove(contest, IdentityUtils.getUserJid());

    if (formHasErrors(contestContestantCreateForm)) {
        return showlistAddContestantWithContestantAddForm(pageIndex, orderBy, orderDir, filterString, true, canDelete, contestContestantCreateForm, contest);
    }

    ContestContestantAddForm contestContestantCreateData = contestContestantCreateForm.get();

    if (!EnumUtils.isValidEnum(ContestContestantStatus.class, contestContestantCreateData.status)) {
        return showlistAddContestantWithContestantAddForm(pageIndex, orderBy, orderDir, filterString, true, canDelete, contestContestantCreateForm, contest);
    }

    JophielUser jophielUser;
    try {
        jophielUser = jophielPublicAPI.findUserByUsername(contestContestantCreateData.username);
    } catch (JudgelsAPIClientException e) {
        contestContestantCreateForm.reject("error.contestant.create.userNotExist");

        return showlistAddContestantWithContestantAddForm(pageIndex, orderBy, orderDir, filterString, true, canDelete, contestContestantCreateForm, contest);
    }

    if (jophielUser == null) {
        contestContestantCreateForm.reject("error.contestant.create.userNotExist");

        return showlistAddContestantWithContestantAddForm(pageIndex, orderBy, orderDir, filterString, true, canDelete, contestContestantCreateForm, contest);
    }

    if (contestContestantService.isContestantInContest(contest.getJid(), jophielUser.getJid())) {
        contestContestantCreateForm.reject("error.contestant.create.userIsAlreadyContestant");

        return showlistAddContestantWithContestantAddForm(pageIndex, orderBy, orderDir, filterString, true, canDelete, contestContestantCreateForm, contest);
    }

    userService.upsertUserFromJophielUser(jophielUser, IdentityUtils.getUserJid(), IdentityUtils.getIpAddress());
    contestContestantService.createContestContestant(contest.getJid(), jophielUser.getJid(), ContestContestantStatus.valueOf(contestContestantCreateData.status), IdentityUtils.getUserJid(), IdentityUtils.getIpAddress());

    UrielControllerUtils.getInstance().addActivityLog(BasicActivityKeys.ADD_IN.construct(CONTEST, contest.getJid(), contest.getName(), CONTESTANT, jophielUser.getJid(), jophielUser.getUsername()));

    return redirect(routes.ContestContestantController.viewContestants(contest.getId()));
}
 
開發者ID:judgels,項目名稱:uriel,代碼行數:50,代碼來源:ContestContestantController.java


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