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


Java EnumUtils.getEnum方法代碼示例

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


在下文中一共展示了EnumUtils.getEnum方法的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`コマンドで確認出來ます");
		}
	}
}
 
開發者ID:Team-Fruit,項目名稱:EEWBot,代碼行數:23,代碼來源:DiscordEventListener.java

示例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;
}
 
開發者ID:ligoj,項目名稱:bootstrap,代碼行數:20,代碼來源:AbstractSpecification.java

示例3: 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;
}
 
開發者ID:alibaba,項目名稱:jvm-sandbox,代碼行數:17,代碼來源:GaEnumUtils.java

示例4: 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);
	}
}
 
開發者ID:andreptb,項目名稱:fitnesse-selenium-slim,代碼行數:20,代碼來源:SeleniumLocatorParser.java

示例5: 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);
}
 
開發者ID:DistantEye,項目名稱:EP_Utilities,代碼行數:30,代碼來源:Morph.java

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

示例7: 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()));
    });
}
 
開發者ID:ata4,項目名稱:dragon-mounts,代碼行數:19,代碼來源:DragonBreedHelper.java

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

示例9: parse

import org.apache.commons.lang3.EnumUtils; //導入方法依賴的package包/類
@Override
public Reply parse(Push push) {
    if (!(push instanceof EventPush)) {
        return null;
    }

    EventPush eventPush = (EventPush) push;
    String event = eventPush.getEvent();

    EventPushType eventPushType = EnumUtils.getEnum(EventPushType.class, StringUtils.upperCase(event));
    Validate.notNull(eventPushType, "don't-support-%s-event-push", event);

    // TODO please custom it.
    if (eventPushType == EventPushType.SUBSCRIBE) {
        Reply reply = ReplyUtil.parseReplyDetailWarpper(ReplyUtil.getDummyTextReplyDetailWarpper());
        return ReplyUtil.buildReply(reply, eventPush);
    }

    return null;
}
 
開發者ID:usc,項目名稱:wechat-mp-sdk,代碼行數:21,代碼來源:EventPushParser.java

示例10: parseReplyDetailWarpper

import org.apache.commons.lang3.EnumUtils; //導入方法依賴的package包/類
public static Reply parseReplyDetailWarpper(ReplyDetailWarpper replyDetailWarpper) {
    if (replyDetailWarpper == null) {
        return null;
    }

    String replyType = replyDetailWarpper.getReplyType();
    ReplyEnumFactory replyEnumFactory = EnumUtils.getEnum(ReplyEnumFactory.class, StringUtils.upperCase(replyType));
    if (replyEnumFactory == null) {
        return null;
    }

    Reply buildReply = replyEnumFactory.buildReply(replyDetailWarpper.getReplyDetails());
    if (buildReply != null) {
        buildReply.setFuncFlag(replyDetailWarpper.getFuncFlag());

        return buildReply;
    }

    return null;
}
 
開發者ID:usc,項目名稱:wechat-mp-sdk,代碼行數:21,代碼來源:ReplyUtil.java

示例11: main

import org.apache.commons.lang3.EnumUtils; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
    File parent = new File(PushTest.class.getClassLoader().getResource("push").toURI());
    for (File pushFile : parent.listFiles()) {
        // if (!StringUtils.startsWithIgnoreCase(pushFile.getName(), "event")) {
        // continue;
        // }
        //
        String message = FileUtils.readFileToString(pushFile, "utf-8");

        String messageType = getMsgType(message);
        PushEnumFactory pushEnum = EnumUtils.getEnum(PushEnumFactory.class, StringUtils.upperCase(messageType));

        Push push = pushEnum.convert(message);

        System.out.println(pushFile + "\n" + message + "\n" + push + "\n");
    }
}
 
開發者ID:usc,項目名稱:wechat-mp-sdk,代碼行數:18,代碼來源:PushTest.java

示例12: validate

import org.apache.commons.lang3.EnumUtils; //導入方法依賴的package包/類
public WebDriverProperties validate() {
    // validate CAPABILITY_BROWSER when testing in local
    if(isEmpty(getRemote())) {
        DriverType browserType = EnumUtils.getEnum(DriverType.class, getBrowser().toUpperCase());
        checkArgument(DriverType.local.contains(browserType),
                String.format("Invalid [capabilities.browser, capabilities.browserName, browser] " +
                                "= [%s] not in %s", getBrowser(), DriverType.local.toString()));
    }
    // validate CAPABILITY_BROWSER_SIZE
    if(isNotEmpty(getBrowserSize())) {
        checkArgument(getBrowserSize().matches("\\d+[x]\\d+"),
                String.format("Invalid [capabilities.browserSize] = [%s] " +
                                "not in the format 123x456",
                        getBrowserSize()));
    }
    // validate CAPABILITY_VIEWPORT_SIZE
    if(isNotEmpty(getViewportSize())) {
        checkArgument(getViewportSize().matches("\\d+[x]\\d+"),
                String.format("Invalid [capabilities.viewportSize] = [%s] " +
                                "not in the format 123x456",
                        getViewportSize()));
    }
    // validate CAPABILITY_DEVICE_NAME over CAPABILITY_USER_AGENT
    if(isNotEmpty(getDeviceName()) && isNotEmpty(getUserAgent())) {
        throw new IllegalArgumentException(
                "Invalid capabilities setup:" +
                        " [capabilities.deviceName] and [capabilities.userAgent] cannot coexist.");
    }
    // validate CAPABILITY_REMOTE
    if(isNotEmpty(getRemote())) {
        try {
            new URL(getRemote());
        } catch (MalformedURLException e) {
            throw new IllegalArgumentException(
                    "Invalid 'capabilities.remote' parameter: " + getRemote(), e);
        }
    }
    // all the properties are valid
    return this;
}
 
開發者ID:isgarlo,項目名稱:givemeadriver,代碼行數:41,代碼來源:WebDriverProperties.java

示例13: getCellValueFromFormula

import org.apache.commons.lang3.EnumUtils; //導入方法依賴的package包/類
private static Object getCellValueFromFormula(FormulaEvaluator formulaEvaluator, Cell cell) {
	try {
		CellValue cellValue = formulaEvaluator.evaluate(cell);
		
		if (cellValue.getCellType() == Cell.CELL_TYPE_NUMERIC) {
			if (DateUtil.isCellDateFormatted(cell)) {
				Calendar calendar = GregorianCalendar.getInstance();
				calendar.setTime(DateUtil.getJavaDate(cellValue.getNumberValue()));
				
				return calendar.getTime();
			} else {
				return DECIMAL_FORMAT.format(cellValue.getNumberValue());
			}
		} else if (cellValue.getCellType() == Cell.CELL_TYPE_STRING) {
			if (StringUtils.hasText(cellValue.getStringValue())) {
				return cellValue.getStringValue();
			}
		}
	} catch (NotImplementedException e) {
		// If formula use Excel features not implemented in POI (like proper),
		// we can retrieve the cached value (which may no longer be correct, depending of what you do on your file).
		FormulaFeature feature = EnumUtils.getEnum(FormulaFeature.class, e.getCause().getMessage());
		if (ALLOWED_NOT_IMPLEMENTED_FORMULA_FEATURES.contains(feature)) {
			return getCellPrimitiveValue(cell, cell.getCachedFormulaResultType());
		} else {
			throw e;
		}
	}
	
	return null;
}
 
開發者ID:openwide-java,項目名稱:owsi-core-parent,代碼行數:32,代碼來源:WorkbookUtils.java

示例14: execute

import org.apache.commons.lang3.EnumUtils; //導入方法依賴的package包/類
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    if (args.length < 1) {
        throw new WrongUsageException(getCommandUsage(sender));
    }

    String enumName = args[0].toUpperCase();
    E enumValue = EnumUtils.getEnum(enumClass, enumName);
    if (enumValue == null) {
        // default constructor uses "snytax"...
        throw new SyntaxErrorException("commands.generic.syntax");
    }

    applyModifier(server, sender, dragon -> enumConsumer.accept(dragon, enumValue));
}
 
開發者ID:ata4,項目名稱:dragon-mounts,代碼行數:16,代碼來源:CommandDragonEnumSetter.java

示例15: beforeStep

import org.apache.commons.lang3.EnumUtils; //導入方法依賴的package包/類
@Override
public void beforeStep(StepExecution stepExecution) {
    SourceCode sc = EnumUtils.getEnum(SourceCode.class, sourceCode);
    judgmentRepository.markAsNotIndexedBySourceCode(sc);
    
    String deletingQuery = (sc == null) ? "*:*" : JudgmentIndexField.SOURCE_CODE.getFieldName() + ":" + sc.name();
    
    try {
        solrJudgmentsServer.deleteByQuery(deletingQuery);
    } catch (SolrServerException | IOException e) {
        throw new RuntimeException(e);
    }
}
 
開發者ID:CeON,項目名稱:saos,代碼行數:14,代碼來源:ReindexJobStepExecutionListener.java


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