List of usage examples for java.lang Enum equals
public final boolean equals(Object other)
From source file:org.kuali.kra.s2s.generator.impl.RRSF424V1_1Generator.java
/** * /*from ww w. j a v a 2 s . c o m*/ * This method is used to get ApplicationType for the form RRSF424 * * @return ApplicationType corresponding to the proposal type code. */ private ApplicationType getApplicationType() { ApplicationType applicationType = ApplicationType.Factory.newInstance(); Map<String, String> submissionInfo = s2sUtilService.getSubmissionType(pdDoc); if (pdDoc.getDevelopmentProposal().getProposalTypeCode() != null && Integer.parseInt(pdDoc.getDevelopmentProposal().getProposalTypeCode()) < PROPOSAL_TYPE_CODE_6) { // Check <6 to ensure that if proposalType='TASk ORDER", it must not // set. THis is because enum ApplicationType has no // entry for TASK ORDER ApplicationTypeCodeDataType.Enum applicationTypeCodeDataType = ApplicationTypeCodeDataType.Enum .forInt(Integer.parseInt(pdDoc.getDevelopmentProposal().getProposalTypeCode())); applicationType.setApplicationTypeCode(applicationTypeCodeDataType); if (Integer.parseInt(pdDoc.getDevelopmentProposal() .getProposalTypeCode()) == ApplicationTypeCodeDataType.INT_REVISION) { String revisionCode = null; if (submissionInfo.get(S2SConstants.KEY_REVISION_CODE) != null) { revisionCode = submissionInfo.get(S2SConstants.KEY_REVISION_CODE); RevisionTypeCodeDataType.Enum revisionCodeApplication = RevisionTypeCodeDataType.Enum .forString(revisionCode); applicationType.setRevisionCode(revisionCodeApplication); } String revisionCodeOtherDesc = null; if (submissionInfo.get(S2SConstants.KEY_REVISION_OTHER_DESCRIPTION) != null) { revisionCodeOtherDesc = submissionInfo.get(S2SConstants.KEY_REVISION_OTHER_DESCRIPTION); applicationType.setRevisionCodeOtherExplanation(revisionCodeOtherDesc); } } } ProposalYnq proposalYnq = getAnswer(PROPOSAL_YNQ_OTHER_AGENCY_SUBMISSION, pdDoc); Enum answer = YesNoDataType.N_NO; if (proposalYnq != null && proposalYnq.getAnswer() != null) { answer = (proposalYnq.getAnswer().equals(S2SConstants.PROPOSAL_YNQ_ANSWER_Y) ? YesNoDataType.Y_YES : YesNoDataType.N_NO); } applicationType.setIsOtherAgencySubmission(answer); if (answer.equals(YesNoDataType.Y_YES)) { String answerExplanation = proposalYnq.getExplanation(); if (answerExplanation != null) { if (answerExplanation.length() > ANSWER_EXPLANATION_MAX_LENGTH) { applicationType.setOtherAgencySubmissionExplanation( answerExplanation.substring(0, ANSWER_EXPLANATION_MAX_LENGTH)); } else { applicationType.setOtherAgencySubmissionExplanation(answerExplanation); } } } return applicationType; }
From source file:org.structr.common.ValidationHelper.java
/** * Checks whether the value for the given property key of the given node * is a valid enum value of the given type. In case of an error, the * type identifiery in typeString is used for the error message. * * @param typeString/*from w ww .ja v a 2 s . c o m*/ * @param node the node * @param key the property key * @param enumType the enum type to check against * @param errorBuffer the error buffer * * @return true if there is an error checking the given node */ public static boolean checkStringInEnum(final String typeString, final GraphObject node, final PropertyKey<? extends Enum> key, Class<? extends Enum> enumType, final ErrorBuffer errorBuffer) { Enum value = node.getProperty(key); Enum[] values = enumType.getEnumConstants(); for (Enum v : values) { if (v.equals(value)) { return false; } } errorBuffer.add(new ValueToken(typeString, key, values)); return true; }