本文整理匯總了Java中org.apache.commons.lang3.EnumUtils類的典型用法代碼示例。如果您正苦於以下問題:Java EnumUtils類的具體用法?Java EnumUtils怎麽用?Java EnumUtils使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
EnumUtils類屬於org.apache.commons.lang3包,在下文中一共展示了EnumUtils類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onMessageReceived
import org.apache.commons.lang3.EnumUtils; //導入依賴的package包/類
@EventSubscriber
public void onMessageReceived(final MessageReceivedEvent e) {
final String msg = e.getMessage().getContent();
if (msg.startsWith("!eew")) {
final String[] args = msg.split(" ");
if (args.length<=1)
Command.reply(e, "引數が不足しています");
else {
final Command command = EnumUtils.getEnum(Command.class, args[1]);
if (command!=null)
if (!EEWBot.instance.getConfig().isEnablePermission()||userHasPermission(e.getAuthor().getLongID(), command))
if (args.length-2>=command.getMinArgLength())
command.onCommand(e, ArrayUtils.subarray(args, 2, args.length+1));
else
Command.reply(e, "引數が不足しています");
else
Command.reply(e, "権限がありません!");
else
Command.reply(e, "コマンドが存在しません\nコマンド一覧は`help`コマンドで確認出來ます");
}
}
}
示例2: toEnum
import org.apache.commons.lang3.EnumUtils; //導入依賴的package包/類
/**
* Get {@link Enum} value from the string raw data. Accept lower and upper case for the match.
*/
@SuppressWarnings("unchecked")
private static <Y extends Enum<Y>> Enum<Y> toEnum(final String data, final Expression<Y> expression) {
if (StringUtils.isNumeric(data)) {
// Get Enum value by its ordinal
return expression.getJavaType().getEnumConstants()[Integer.parseInt(data)];
}
// Get Enum value by its exact name
Enum<Y> fromName = EnumUtils.getEnum((Class<Y>) expression.getJavaType(), data);
// Get Enum value by its upper case name
if (fromName == null) {
fromName = Enum.valueOf((Class<Y>) expression.getJavaType(), data.toUpperCase(Locale.ENGLISH));
}
return fromName;
}
示例3: setSimpleRawProperty
import org.apache.commons.lang3.EnumUtils; //導入依賴的package包/類
/**
* Manage simple value.
*
* @param bean
* the target bean.
* @param property
* the bean property to set.
* @param rawValue
* the raw value to set.
* @param <E>
* Enumeration type.
*/
@SuppressWarnings("unchecked")
protected <E extends Enum<E>> void setSimpleRawProperty(final T bean, final String property, final String rawValue)
throws IllegalAccessException, InvocationTargetException {
final Field field = getField(clazz, property);
// Update the property
if (field.getAnnotation(GeneratedValue.class) == null) {
if (field.getType().isEnum()) {
// Ignore case of Enum name
final Class<E> enumClass = (Class<E>) field.getType();
beanUtilsBean.setProperty(bean, property, Enum.valueOf(enumClass,
EnumUtils.getEnumMap(enumClass).keySet().stream().filter(rawValue::equalsIgnoreCase).findFirst().orElse(rawValue)));
} else {
beanUtilsBean.setProperty(bean, property, rawValue);
}
}
}
示例4: valuesOf
import org.apache.commons.lang3.EnumUtils; //導入依賴的package包/類
public static <T extends Enum<T>> Set<T> valuesOf(Class<T> enumClass, String[] enumNameArray, T[] defaultEnumArray) {
final Set<T> enumSet = new LinkedHashSet<T>();
if (ArrayUtils.isNotEmpty(enumNameArray)) {
for (final String enumName : enumNameArray) {
final T enumValue = EnumUtils.getEnum(enumClass, enumName);
if (null != enumValue) {
enumSet.add(enumValue);
}
}
}
if (CollectionUtils.isEmpty(enumSet)
&& ArrayUtils.isNotEmpty(defaultEnumArray)) {
Collections.addAll(enumSet, defaultEnumArray);
}
return enumSet;
}
示例5: 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()));
}
示例6: parseBy
import org.apache.commons.lang3.EnumUtils; //導入依賴的package包/類
private By parseBy(String locator) {
if (StringUtils.isBlank(locator)) {
return new ByFocus();
}
Pair<String, String> prefixAndSelector = this.fitnesseMarkup.cleanAndParseKeyValue(locator, FitnesseMarkup.KEY_VALUE_SEPARATOR);
String prefix = prefixAndSelector.getKey();
String selector = prefixAndSelector.getValue();
LocatorType selectorType = EnumUtils.getEnum(LocatorType.class, prefix);
if (selectorType == null) {
selector = locator;
selectorType = LocatorType.xpath;
}
try {
return selectorType.byClass.getConstructor(String.class).newInstance(selector);
} catch (ReflectiveOperationException e) {
throw new IllegalStateException("Unexpected failure instantiating selector: " + prefix, e);
}
}
示例7: CreateInternalMorph
import org.apache.commons.lang3.EnumUtils; //導入依賴的package包/類
/**
* Creates a new Morph that is stored statically in the class.
*
* isSynth is a true/false field
* @param input String[] {name, morphType, description, implants, aptitudeMaxStr, durability, woundThreshold, CP, creditCost, effects, notes}
*/
public static void CreateInternalMorph(String[] parts)
{
if (parts.length != 11 || !Utils.isInteger(parts[5]) || !Utils.isInteger(parts[6]) || !Utils.isInteger(parts[7]))
{
throw new IllegalArgumentException("Invalidly formatted Morph string[] : " + StringUtils.join(parts,","));
}
int cnt = 0;
String name = parts[cnt++];
MorphType morphType = EnumUtils.getEnum(MorphType.class, parts[cnt++].toUpperCase());
String description = parts[cnt++];
String implants = parts[cnt++];
String aptitudeMaxStr = parts[cnt++];
int durability = Integer.parseInt(parts[cnt++]);
int woundThreshold = Integer.parseInt(parts[cnt++]);
int CP = Integer.parseInt(parts[cnt++]);
String creditCost = parts[cnt++];
String effects = parts[cnt++];
String notes = parts[cnt++];
Morph temp = new Morph(name,morphType,description,implants,aptitudeMaxStr,durability,woundThreshold,CP,creditCost,effects,notes);
Morph.morphList.add(temp);
}
示例8: CreateInternalsleight
import org.apache.commons.lang3.EnumUtils; //導入依賴的package包/類
/**
* Creates a new sleight that is stored statically in the class
* @param input String[] of format SleightType;IsExsurgent;SleightName;ActivePassive;ActionType;Range;Duration;StrainMod;skillUsed;Description
*/
public static void CreateInternalsleight(String[] input)
{
if (input.length != 10 )
{
throw new IllegalArgumentException("Array for Sleight must have 10 parts");
}
int cnt = 0;
SleightType sleightType = EnumUtils.getEnum(SleightType.class,input[cnt++]);
Boolean isExsurgent = Boolean.parseBoolean(input[cnt++]);
String sleightName = input[cnt++];
UsageType activePassive = EnumUtils.getEnum(UsageType.class,input[cnt++].toUpperCase());
ActionType actionType = EnumUtils.getEnum(ActionType.class,input[cnt++].toUpperCase());
Range range = EnumUtils.getEnum(Range.class,input[cnt++].toUpperCase());
Duration duration = EnumUtils.getEnum(Duration.class,input[cnt++].toUpperCase());
String strainMod = input[cnt++];
String skillUsed = input[cnt++];
String description = input[cnt++];
Sleight temp = new Sleight(sleightType, isExsurgent, sleightName,activePassive, actionType, range, duration, strainMod, skillUsed, description);
Sleight.sleightList.put(temp.getName(),temp);
}
示例9: 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()));
}
示例10: initGui
import org.apache.commons.lang3.EnumUtils; //導入依賴的package包/類
@Override
public void initGui() {
buttonList.add(new GuiButton(0, width - 105, height - 25, 100, 20, "Apply and continue"));
super.initGui();
namefield = new GuiTextField(1, fontRendererObj, 55, 110, 100, 10);
surnamefield = new GuiTextField(2, fontRendererObj, 55, 125, 100, 10);
namefield.setCanLoseFocus(true);
surnamefield.setCanLoseFocus(true);
genderGroup = new GuiRadioGroup(surnamefield.xPosition, surnamefield.yPosition + surnamefield.height + 5);
jobMenu = new GuiDropdownMenu(5, genderGroup.yPos + 20, surnamefield.getWidth() + 10, "Job: ");
genderGroup.buttonList.clear();
genderGroup.horizontal = true;
genderGroup.addButton(new GuiRadiobutton(0, 0, 0, 10, 10, "Male"));
genderGroup.addButton(new GuiRadiobutton(1, 0, 0, 10, 10, "Female"));
genderGroup.singleChoice = true;
jobMenu.setMaxHeight(4);
int enumid = 0;
for (EnumJob job : EnumUtils.getEnumList(EnumJob.class)) {
jobMenu.contents.add(new GuiMenuItem(jobMenu, enumid, job.name()));
enumid++;
}
}
示例11: 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()));
}
示例12: 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()));
}
示例13: logNumOfVarByTypes
import org.apache.commons.lang3.EnumUtils; //導入依賴的package包/類
private static void logNumOfVarByTypes(final List<VariantContext> variants, final Logger logger) {
logger.info("Discovered " + variants.size() + " variants.");
final Map<String, Long> variantsCountByType = variants.stream()
.collect(Collectors.groupingBy(vc -> (String) vc.getAttribute(GATKSVVCFConstants.SVTYPE), Collectors.counting()));
variantsCountByType.forEach((key, value) -> logger.info(key + ": " + value));
final Set<String> knownTypes = new HashSet<>( EnumUtils.getEnumMap(SimpleSVType.TYPES.class).keySet() );
knownTypes.add(BreakEndVariantType.InvSuspectBND.INV33_BND);
knownTypes.add(BreakEndVariantType.InvSuspectBND.INV55_BND);
knownTypes.add(BreakEndVariantType.TransLocBND.STRANDSWITCHLESS_BND);
knownTypes.add(GATKSVVCFConstants.CPX_SV_SYB_ALT_ALLELE_STR);
Sets.difference(knownTypes, variantsCountByType.keySet()).forEach(key -> logger.info(key + ": " + 0));
}
示例14: readFromNBT
import org.apache.commons.lang3.EnumUtils; //導入依賴的package包/類
@Override
public void readFromNBT(NBTTagCompound nbt) {
// read breed name and convert it to the corresponding breed object
String breedName = nbt.getString(NBT_BREED);
EnumDragonBreed breed = EnumUtils.getEnum(EnumDragonBreed.class, breedName.toUpperCase());
if (breed == null) {
breed = EnumDragonBreed.DEFAULT;
L.warn("Dragon {} loaded with invalid breed type {}, using {} instead",
dragon.getEntityId(), breedName, breed);
}
setBreedType(breed);
// read breed points
NBTTagCompound breedPointTag = nbt.getCompoundTag(NBT_BREED_POINTS);
breedPoints.forEach((type, points) -> {
points.set(breedPointTag.getInteger(type.getName()));
});
}
示例15: JooqProcessRecord
import org.apache.commons.lang3.EnumUtils; //導入依賴的package包/類
public JooqProcessRecord(ProcessInstanceRecord record) {
this.processInstance = record;
id = record.getId();
accountId = record.getAccountId();
clusterId = record.getClusterId();
data = new HashMap<>(record.getData());
endTime = toTimestamp(record.getEndTime());
executionCount = record.getExecutionCount();
exitReason = EnumUtils.getEnum(ExitReason.class, record.getExitReason());
priority = record.getPriority();
processLog = new ProcessLog();
processName = record.getProcessName();
resourceId = record.getResourceId();
resourceType = record.getResourceType();
result = EnumUtils.getEnum(ProcessResult.class, record.getResult());
runAfter = record.getRunAfter();
runningProcessServerId = record.getRunningProcessServerId();
startProcessServerId = record.getStartProcessServerId();
startTime = toTimestamp(record.getStartTime());
}