本文整理匯總了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()));
}
示例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()));
}
示例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()));
}
示例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()));
}
示例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;
}
示例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;
}
}
示例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;
}
示例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!");
}
}
示例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()));
}
示例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()));
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例14: exists
import org.apache.commons.lang3.EnumUtils; //導入方法依賴的package包/類
public static boolean exists(String val) {
return EnumUtils.isValidEnum(FeatureCode.class, val);
}
示例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()));
}