类org.apache.commons.lang3.EnumUtils源码实例Demo

下面列出了怎么用org.apache.commons.lang3.EnumUtils的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: vividus   文件: DiffDateExpressionProcessor.java
@Override
public Optional<String> execute(String expression)
{
    Matcher expressionMatcher = DIFF_DATE_PATTERN.matcher(expression);
    if (expressionMatcher.find())
    {
        ZonedDateTime firstZonedDateTime = getZonedDateTime(expressionMatcher, FIRST_INPUT_DATE_GROUP,
                FIRST_INPUT_FORMAT_GROUP);
        ZonedDateTime secondZonedDateTime = getZonedDateTime(expressionMatcher, SECOND_INPUT_DATE_GROUP,
                SECOND_INPUT_FORMAT_GROUP);
        Duration duration = Duration.between(firstZonedDateTime, secondZonedDateTime);
        String durationAsString = duration.toString();
        return Optional.ofNullable(expressionMatcher.group(FORMAT_GROUP))
                       .map(String::trim)
                       .map(String::toUpperCase)
                       .map(t -> EnumUtils.getEnum(ChronoUnit.class, t))
                       .map(u -> u.between(firstZonedDateTime, secondZonedDateTime))
                       .map(Object::toString)
                       .or(() -> processNegative(duration, durationAsString));
    }
    return Optional.empty();
}
 
源代码2 项目: easyexcel-utils   文件: EnumExcelConverter.java
@Override
public Enum convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
    String cellDataStr = cellData.getStringValue();

    EnumFormat annotation = contentProperty.getField().getAnnotation(EnumFormat.class);
    Class enumClazz = annotation.value();
    String[] fromExcel = annotation.fromExcel();
    String[] toJavaEnum = annotation.toJavaEnum();

    Enum anEnum = null;
    if (ArrayUtils.isNotEmpty(fromExcel) && ArrayUtils.isNotEmpty(toJavaEnum)) {
        Assert.isTrue(fromExcel.length == toJavaEnum.length, "fromExcel 与 toJavaEnum 的长度必须相同");
        for (int i = 0; i < fromExcel.length; i++) {
            if (Objects.equals(fromExcel[i], cellDataStr)) {
                anEnum = EnumUtils.getEnum(enumClazz, toJavaEnum[i]);
            }
        }
    } else {
        anEnum = EnumUtils.getEnum(enumClazz, cellDataStr);
    }

    Assert.notNull(anEnum, "枚举值不合法");
    return anEnum;
}
 
源代码3 项目: bbs   文件: UserRoleManage.java
/**
 * 处理标签资源
 * @param resourceGroupCode 资源组编号
 * @return
 */
private List<UserResource> processingTagResource(Integer resourceGroupCode){
	List<UserResource> userResourceList = new ArrayList<UserResource>();
	
	List<ResourceEnum> resourceEnumList = EnumUtils.getEnumList(ResourceEnum.class);
	if(resourceEnumList != null && resourceEnumList.size() >0){
		for(ResourceEnum resourceEnum:  resourceEnumList){
			
			if(resourceEnum.getResourceGroupCode().equals(resourceGroupCode)){
				UserResource userResource = new UserResource();
				userResource.setCode(resourceEnum.getCode());
				userResource.setName(resourceEnum.getName());
				userResource.setResourceGroupCode(resourceEnum.getResourceGroupCode());
				userResourceList.add(userResource);
			}
			
			
		}
	}
	return userResourceList;
}
 
源代码4 项目: spring-cloud-shop   文件: SMSServiceImpl.java
@Override
public Response<String> sendSms(String phone, String event) {

    SMSCodeEnums smsCodeEnums = EnumUtils.getEnum(SMSCodeEnums.class, event);

    if (Objects.isNull(smsCodeEnums)) {
        return new Response<>(ResponseStatus.Code.FAIL_CODE, "未找到短信发送渠道");
    }

    Response<SMSTemplateResponse> templateResponse = smsTemplateService.sms(smsCodeEnums.getCode());

    // 模板查询未成功
    if (ResponseStatus.Code.SUCCESS != templateResponse.getCode()) {
        return new Response<>(templateResponse.getCode(), templateResponse.getMsg());
    }

    String content = templateResponse.getData().getTemplateContent();

    return new Response<>(getContent(smsCodeEnums, content, phone));
}
 
源代码5 项目: spring-cloud-shop   文件: JobTrigger.java
/**
 * 获取所有job任务
 */
public static List<JobInfo> getJobs(Scheduler scheduler) throws SchedulerException {
    GroupMatcher<JobKey> matcher = GroupMatcher.anyJobGroup();

    List<JobInfo> jobs = Lists.newArrayList();
    Set<JobKey> jobKeys = scheduler.getJobKeys(matcher);

    for (JobKey jobKey : jobKeys) {
        List<? extends Trigger> triggers = scheduler.getTriggersOfJob(jobKey);
        for (Trigger trigger : triggers) {

            JobInfo event = new JobInfo();
            event.setJobName(jobKey.getName());
            event.setJobGroup(jobKey.getGroup());
            event.setDescription(String.format("触发器 ======== %s", trigger.getKey()));
            Trigger.TriggerState state = scheduler.getTriggerState(trigger.getKey());
            event.setJobStatus(EnumUtils.getEnum(JobStatusEnums.class, state.name()).getCode());
            if (trigger instanceof CronTrigger) {
                CronTrigger cronTrigger = (CronTrigger) trigger;
                event.setCron(cronTrigger.getCronExpression());
                jobs.add(event);
            }
        }
    }
    return jobs;
}
 
源代码6 项目: spring-cloud-shop   文件: JobTrigger.java
/**
 * 获取正在运行的job任务
 *
 * @param scheduler scheduler
 */
public static List<JobInfo> getRunningJobs(Scheduler scheduler) throws SchedulerException {
    return Optional.ofNullable(scheduler.getCurrentlyExecutingJobs()).orElse(Collections.emptyList()).stream().map(context -> {
        JobDetail jobDetail = context.getJobDetail();
        Trigger trigger = context.getTrigger();
        JobKey jobKey = jobDetail.getKey();
        JobInfo job = new JobInfo();
        job.setJobName(jobKey.getName());
        job.setJobGroup(jobKey.getGroup());
        job.setDescription(String.format("触发器 ======== %s", trigger.getKey()));
        try {
            Trigger.TriggerState state = scheduler.getTriggerState(trigger.getKey());
            job.setJobStatus(EnumUtils.getEnum(JobStatusEnums.class, state.name()).getCode());
            if (trigger instanceof CronTrigger) {
                CronTrigger cronTrigger = (CronTrigger) trigger;
                job.setCron(cronTrigger.getCronExpression());
                return job;
            }
        } catch (SchedulerException e) {
            e.printStackTrace();
        }
        return null;
    }).filter(Objects::nonNull).collect(Collectors.toList());
}
 
源代码7 项目: azure-cosmosdb-java   文件: RequestHelper.java
public static ConsistencyLevel GetConsistencyLevelToUse(GatewayServiceConfigurationReader serviceConfigReader,
                                                        RxDocumentServiceRequest request) throws DocumentClientException {
    ConsistencyLevel consistencyLevelToUse = serviceConfigReader.getDefaultConsistencyLevel();

    String requestConsistencyLevelHeaderValue = request.getHeaders().get(HttpConstants.HttpHeaders.CONSISTENCY_LEVEL);

    if (!Strings.isNullOrEmpty(requestConsistencyLevelHeaderValue)) {
        ConsistencyLevel requestConsistencyLevel = EnumUtils.getEnum(ConsistencyLevel.class, requestConsistencyLevelHeaderValue);
        if (requestConsistencyLevel == null) {
            throw new BadRequestException(
                    String.format(
                            RMResources.InvalidHeaderValue,
                            requestConsistencyLevelHeaderValue,
                            HttpConstants.HttpHeaders.CONSISTENCY_LEVEL));
        }

        consistencyLevelToUse = requestConsistencyLevel;
    }

    return consistencyLevelToUse;
}
 
源代码8 项目: azure-cosmosdb-java   文件: ServerStoreModel.java
public Observable<RxDocumentServiceResponse> processMessage(RxDocumentServiceRequest request) {
    String requestConsistencyLevelHeaderValue = request.getHeaders().get(HttpConstants.HttpHeaders.CONSISTENCY_LEVEL);

    request.requestContext.originalRequestConsistencyLevel = null;

    if (!Strings.isNullOrEmpty(requestConsistencyLevelHeaderValue)) {
        ConsistencyLevel requestConsistencyLevel;

        if ((requestConsistencyLevel = EnumUtils.getEnum(ConsistencyLevel.class, requestConsistencyLevelHeaderValue)) == null) {
            return Observable.error(new BadRequestException(
                String.format(
                    RMResources.InvalidHeaderValue,
                    requestConsistencyLevelHeaderValue,
                    HttpConstants.HttpHeaders.CONSISTENCY_LEVEL)));
        }

        request.requestContext.originalRequestConsistencyLevel = requestConsistencyLevel;
    }

    if (ReplicatedResourceClient.isMasterResource(request.getResourceType())) {
        request.getHeaders().put(HttpConstants.HttpHeaders.CONSISTENCY_LEVEL, ConsistencyLevel.Strong.toString());
    }

    Single<RxDocumentServiceResponse> response = this.storeClient.processMessageAsync(request);
    return response.toObservable();
}
 
源代码9 项目: powsybl-core   文件: CgmesModelTripleStore.java
@Override
public void add(String context, String type, PropertyBags objects) {
    String contextName = EnumUtils.isValidEnum(CgmesSubset.class, context)
        ? contextNameFor(CgmesSubset.valueOf(context))
        : context;
    try {
        if (type.equals(CgmesNames.FULL_MODEL)) {
            tripleStore.add(contextName, mdNamespace(), type, objects);
        } else {
            tripleStore.add(contextName, cimNamespace, type, objects);
        }
    } catch (TripleStoreException x) {
        String msg = String.format("Adding objects of type %s to context %s", type, context);
        throw new CgmesModelException(msg, x);
    }
}
 
ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, String referenceTypeString, String reference)
		throws Exception {
	try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
		ActionResult<List<Wo>> result = new ActionResult<>();
		Business business = new Business(emc);
		ReferenceType referenceType = EnumUtils.getEnum(ReferenceType.class, referenceTypeString);
		if (null == referenceType) {
			throw new ExceptionInvalidReferenceType(referenceTypeString);
		}
		if (StringUtils.isEmpty(reference)) {
			throw new ExceptionEmptyReference(reference);
		}
		List<String> ids = business.file().listWithReferenceTypeWithReference(referenceType, reference);
		List<Wo> wos = Wo.copier.copy(emc.list(File.class, ids));
		wos = wos.stream().sorted(Comparator.comparing(File::getName, Comparator.nullsLast(String::compareTo)))
				.collect(Collectors.toList());
		result.setData(wos);
		return result;
	}
}
 
源代码11 项目: o2oa   文件: FileRemoveQueue.java
@Override
protected void execute(Map<String, String> map) throws Exception {
	String reference = map.get(REFERENCE);
	String referenceTypeString = map.get(REFERENCETYPE);
	ReferenceType referenceType = EnumUtils.getEnum(ReferenceType.class, referenceTypeString);
	if (StringUtils.isEmpty(reference) || (null == referenceType)) {
		logger.warn("接收到无效的删除文件请求, referenceType: {}, reference: {}.", referenceTypeString, reference);
	} else {
		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
			Business business = new Business(emc);
			List<String> ids = business.file().listWithReferenceTypeWithReference(referenceType, reference);
			for (File o : emc.list(File.class, ids)) {
				StorageMapping mapping = ThisApplication.context().storageMappings().get(File.class,
						o.getStorage());
				if (null == mapping) {
					throw new ExceptionStorageMappingNotExisted(o.getStorage());
				} else {
					o.deleteContent(mapping);
					emc.beginTransaction(File.class);
					emc.remove(o);
					emc.commit();
				}
			}
		}
	}
}
 
源代码12 项目: o2oa   文件: ActionCopy.java
ActionResult<Wo> execute(EffectivePerson effectivePerson, String attachmentId, String referenceTypeString,
		String reference, Integer scale) throws Exception {
	ActionResult<Wo> result = new ActionResult<>();
	try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
		Business business = new Business(emc);
		ReferenceType referenceType = EnumUtils.getEnum(ReferenceType.class, referenceTypeString);
		if (null == referenceType) {
			throw new ExceptionInvalidReferenceType(referenceTypeString);
		}
		if (StringUtils.isEmpty(reference)) {
			throw new ExceptionEmptyReference(reference);
		}
		Attachment attachment = emc.find(attachmentId, Attachment.class);
		if (null == attachment) {
			throw new ExceptionAttachmentNotExisted(attachmentId);
		}
		if (effectivePerson.isNotManager() && effectivePerson.isNotPerson(attachment.getPerson())) {
			throw new ExceptionAttachmentAccessDenied(effectivePerson.getDistinguishedName(), attachment.getName(),
					attachment.getId());
		}
		String id = this.copy(effectivePerson, business, referenceType, reference, attachment, scale);
		Wo wo = new Wo();
		wo.setId(id);
		return result;
	}
}
 
ActionResult<List<Wo>> execute(EffectivePerson effectivePerson, String referenceTypeString, String reference)
		throws Exception {
	try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
		ActionResult<List<Wo>> result = new ActionResult<>();
		Business business = new Business(emc);
		ReferenceType referenceType = EnumUtils.getEnum(ReferenceType.class, referenceTypeString);
		if (null == referenceType) {
			throw new ExceptionInvalidReferenceType(referenceTypeString);
		}
		if (StringUtils.isEmpty(reference)) {
			throw new ExceptionEmptyReference(reference);
		}
		List<String> ids = business.file().listWithReferenceTypeWithReference(referenceType, reference);
		List<Wo> wos = Wo.copier.copy(emc.list(File.class, ids));
		wos = wos.stream().sorted(Comparator.comparing(File::getName, Comparator.nullsLast(String::compareTo)))
				.collect(Collectors.toList());
		result.setData(wos);
		return result;
	}
}
 
源代码14 项目: o2oa   文件: FileRemoveQueue.java
@Override
protected void execute(Map<String, String> map) throws Exception {
	String reference = map.get(REFERENCE);
	String referenceTypeString = map.get(REFERENCETYPE);
	ReferenceType referenceType = EnumUtils.getEnum(ReferenceType.class, referenceTypeString);
	if (StringUtils.isEmpty(reference) || (null == referenceType)) {
		logger.warn("接收到无效的删除文件请求, referenceType: {}, reference: {}.", referenceTypeString, reference);
	} else {
		try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
			Business business = new Business(emc);
			List<String> ids = business.file().listWithReferenceTypeWithReference(referenceType, reference);
			for (File o : emc.list(File.class, ids)) {
				StorageMapping mapping = ThisApplication.context().storageMappings().get(File.class,
						o.getStorage());
				if (null == mapping) {
					throw new ExceptionStorageMappingNotExisted(o.getStorage());
				} else {
					o.deleteContent(mapping);
					emc.beginTransaction(File.class);
					emc.remove(o);
					emc.commit();
				}
			}
		}
	}
}
 
源代码15 项目: o2oa   文件: ActionCopy.java
ActionResult<Wo> execute(EffectivePerson effectivePerson, String attachmentId, String referenceTypeString,
		String reference, Integer scale) throws Exception {
	ActionResult<Wo> result = new ActionResult<>();
	try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
		Business business = new Business(emc);
		ReferenceType referenceType = EnumUtils.getEnum(ReferenceType.class, referenceTypeString);
		if (null == referenceType) {
			throw new ExceptionInvalidReferenceType(referenceTypeString);
		}
		if (StringUtils.isEmpty(reference)) {
			throw new ExceptionEmptyReference(reference);
		}
		Attachment attachment = emc.find(attachmentId, Attachment.class);
		if (null == attachment) {
			throw new ExceptionAttachmentNotExisted(attachmentId);
		}
		if (effectivePerson.isNotManager() && effectivePerson.isNotPerson(attachment.getPerson())) {
			throw new ExceptionAttachmentAccessDenied(effectivePerson.getDistinguishedName(), attachment.getName(),
					attachment.getId());
		}
		String id = this.copy(effectivePerson, business, referenceType, reference, attachment, scale);
		Wo wo = new Wo();
		wo.setId(id);
		return result;
	}
}
 
private Set<DescriptorMetadata> getDescriptors(@Nullable String name, @Nullable String type, @Nullable String context,
    BiFunction<Set<Descriptor>, ConfigContextEnum, Set<DescriptorMetadata>> generatorFunction) {
    Predicate<Descriptor> filter = Descriptor::hasUIConfigs;
    if (name != null) {
        filter = filter.and(descriptor -> name.equalsIgnoreCase(descriptor.getDescriptorKey().getUniversalKey()));
    }

    DescriptorType typeEnum = EnumUtils.getEnumIgnoreCase(DescriptorType.class, type);
    if (typeEnum != null) {
        filter = filter.and(descriptor -> typeEnum.equals(descriptor.getType()));
    } else if (type != null) {
        return Set.of();
    }

    ConfigContextEnum contextEnum = EnumUtils.getEnumIgnoreCase(ConfigContextEnum.class, context);
    if (contextEnum != null) {
        filter = filter.and(descriptor -> descriptor.hasUIConfigForType(contextEnum));
    } else if (context != null) {
        return Set.of();
    }

    Set<Descriptor> filteredDescriptors = filter(descriptors, filter);
    return generatorFunction.apply(filteredDescriptors, contextEnum);
}
 
源代码17 项目: jvm-sandbox   文件: GaEnumUtils.java
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;
}
 
源代码18 项目: wechat-mp-sdk   文件: EventPushParser.java
@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;
}
 
源代码19 项目: wechat-mp-sdk   文件: ReplyUtil.java
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;
}
 
源代码20 项目: wechat-mp-sdk   文件: PushTest.java
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");
    }
}
 
源代码21 项目: vividus   文件: RoundExpressionProcessor.java
public RoundingMode getRoundingMode()
{
    if (roundingMode == null)
    {
        return value.charAt(0) == '-' ? RoundingMode.HALF_DOWN : RoundingMode.HALF_UP;
    }
    return EnumUtils.getEnum(RoundingMode.class, roundingMode.toUpperCase());
}
 
源代码22 项目: vividus   文件: ExtendedTableTransformer.java
default <E extends Enum<E>> E getMandatoryEnumProperty(TableProperties properties, String propertyName,
        Class<E> enumClass)
{
    String propertyValueStr = properties.getProperties().getProperty(propertyName);
    E propertyValue = EnumUtils.getEnumIgnoreCase(enumClass, propertyValueStr);
    isTrue(propertyValue != null, "Value of ExamplesTable property '%s' must be from range %s", propertyName,
            Arrays.toString(enumClass.getEnumConstants()));
    return propertyValue;
}
 
源代码23 项目: synopsys-detect   文件: FilterableEnumUtils.java
public static <T extends Enum<T>> List<T> populatedValues(@NotNull List<FilterableEnumValue<T>> filterableList, Class<T> enumClass) {
    if (FilterableEnumUtils.containsNone(filterableList)) {
        return new ArrayList<>();
    } else if (FilterableEnumUtils.containsAll(filterableList)) {
        return EnumUtils.getEnumList(enumClass);
    } else {
        return FilterableEnumUtils.toPresentValues(filterableList);
    }
}
 
源代码24 项目: AnyMock   文件: HttpInterfaceDaoImpl.java
private HttpInterfaceBO convertToBO(HttpInterfaceDO httpInterfaceDO) {
    HttpInterfaceBO httpInterfaceBO = new HttpInterfaceBO();
    BeanUtils.copyProperties(httpInterfaceDO, httpInterfaceBO);
    httpInterfaceBO.setConfigMode(EnumUtils.getEnum(ConfigMode.class, httpInterfaceDO.getConfigMode()));
    httpInterfaceBO.setAccessAuthority(EnumUtils.getEnum(AccessAuthority.class, httpInterfaceDO.getAccessAuthority()));

    Long id = httpInterfaceDO.getId();
    httpInterfaceBO.setResponseHeaderList(httpInterfaceHeaderDao.batchQuery(id, HttpHeaderType.RESPONSE));
    httpInterfaceBO.setCallbackRequestHeaderList(httpInterfaceHeaderDao.batchQuery(id, HttpHeaderType.CALLBACK_REQUEST));
    httpInterfaceBO.setBranchScriptList(httpInterfaceBranchDao.batchQuery(id));
    return httpInterfaceBO;
}
 
源代码25 项目: Java-Library   文件: Utils.java
private static ApiError checkQueryParams(String query) {
    if (!EnumUtils.isValidEnum(QueryParams.class, query)) {
        return Utils.convertToApiError(setError("Please provide a proper query, refer to the documentation for more information", 14));
    }

    return null;
}
 
源代码26 项目: blackduck-alert   文件: ConfigActions.java
public FieldModel saveConfig(FieldModel fieldModel, DescriptorKey descriptorKey) throws AlertException {
    validateConfig(fieldModel, new HashMap<>());
    FieldModel modifiedFieldModel = fieldModelProcessor.performBeforeSaveAction(fieldModel);
    String context = modifiedFieldModel.getContext();
    Map<String, ConfigurationFieldModel> configurationFieldModelMap = modelConverter.convertToConfigurationFieldModelMap(modifiedFieldModel);
    ConfigurationModel configuration = configurationAccessor.createConfiguration(descriptorKey, EnumUtils.getEnum(ConfigContextEnum.class, context), configurationFieldModelMap.values());
    FieldModel dbSavedModel = modelConverter.convertToFieldModel(configuration);
    FieldModel afterSaveAction = fieldModelProcessor.performAfterSaveAction(dbSavedModel);
    return dbSavedModel.fill(afterSaveAction);
}
 
public final Map<String, ConfigurationFieldModel> convertToConfigurationFieldModelMap(FieldModel fieldModel) throws AlertDatabaseConstraintException {
    ConfigContextEnum context = EnumUtils.getEnum(ConfigContextEnum.class, fieldModel.getContext());
    String descriptorName = fieldModel.getDescriptorName();
    DescriptorKey descriptorKey = descriptorMap.getDescriptorKey(descriptorName).orElseThrow(() -> new AlertDatabaseConstraintException("Could not find a Descriptor with the name: " + descriptorName));

    List<DefinedFieldModel> fieldsForContext = descriptorAccessor.getFieldsForDescriptor(descriptorKey, context);
    Map<String, ConfigurationFieldModel> configurationModels = new HashMap<>();
    for (DefinedFieldModel definedField : fieldsForContext) {
        fieldModel.getFieldValueModel(definedField.getKey())
            .flatMap(fieldValueModel -> convertFromDefinedFieldModel(definedField, fieldValueModel.getValues(), fieldValueModel.isSet()))
            .ifPresent(configurationFieldModel -> configurationModels.put(configurationFieldModel.getFieldKey(), configurationFieldModel));
    }

    return configurationModels;
}
 
/**
 * 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;
}
 
源代码29 项目: J-Kinopoisk2IMDB   文件: ConfigValidator.java
/**
 * 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!");
    }
}
 
源代码30 项目: gatk   文件: SvType.java
public static SortedSet<String> getKnownTypes() {
    final SortedSet<String> knownTypes = new TreeSet<>( EnumUtils.getEnumMap(SimpleSVType.SupportedType.class).keySet() );

    knownTypes.add(GATKSVVCFConstants.CPX_SV_SYB_ALT_ALLELE_STR);
    knownTypes.add(GATKSVVCFConstants.BREAKEND_STR);

    return Collections.unmodifiableSortedSet(knownTypes);
}
 
 类所在包
 同包方法