This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository pollen. See http://git.chorem.org/pollen.git commit 65cd880fe6177531cb580d5b2c28b6628ff87940 Author: Adrien Garandel <a.garandel@dralagen.fr> Date: Thu Jul 17 17:21:41 2014 +0200 add defaut case in choicetype --- .../chorem/pollen/services/bean/ChoiceBean.java | 24 ++++++++++------------ .../pollen/services/service/ChoiceService.java | 18 +++++++--------- 2 files changed, 18 insertions(+), 24 deletions(-) diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/bean/ChoiceBean.java b/pollen-services/src/main/java/org/chorem/pollen/services/bean/ChoiceBean.java index 40e8691..aa0bf6b 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/bean/ChoiceBean.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/bean/ChoiceBean.java @@ -61,20 +61,19 @@ public class ChoiceBean extends PollenBean<Choice> { } + + //TODO agarandel 17/07/14 : review code : is switch case required switch (entity.getChoiceType()) { case TEXT: - setChoiceValue(entity.getChoiceValue()); - break; - case DATE: - setChoiceValue(entity.getChoiceValue()); - break; - case IMAGE: setChoiceValue(entity.getChoiceValue()); break; + + default: + throw new UnsupportedOperationException("Unexpected value : " + entity.getChoiceType()); } setDescription(entity.getDescription()); @@ -92,6 +91,8 @@ public class ChoiceBean extends PollenBean<Choice> { ChoiceType choiceType = getChoiceType(); if (choiceType != null) { + + //TODO agarandel 17/07/14 : review code : is switch case required switch (choiceType) { case TEXT: entity.setChoiceValue(getChoiceValue()); @@ -99,19 +100,16 @@ public class ChoiceBean extends PollenBean<Choice> { break; case DATE: - if ( getChoiceValue() != null ) { - entity.setChoiceValue(getChoiceValue()); - } - - break; - case IMAGE: if ( getChoiceValue() != null ) { - entity.setChoiceValue(getChoiceValue()); + entity.setChoiceValue(getChoiceValue()); } break; + + default: + throw new UnsupportedOperationException("Unexpected value : " + choiceType); } } diff --git a/pollen-services/src/main/java/org/chorem/pollen/services/service/ChoiceService.java b/pollen-services/src/main/java/org/chorem/pollen/services/service/ChoiceService.java index 90a2dd2..268a212 100644 --- a/pollen-services/src/main/java/org/chorem/pollen/services/service/ChoiceService.java +++ b/pollen-services/src/main/java/org/chorem/pollen/services/service/ChoiceService.java @@ -28,10 +28,8 @@ import com.google.common.collect.Sets; import org.apache.commons.collections4.CollectionUtils; import org.chorem.pollen.persistence.entity.*; import org.chorem.pollen.services.bean.ChoiceBean; -import org.chorem.pollen.services.bean.PollenEntityId; import org.chorem.pollen.services.bean.PollenEntityRef; import org.chorem.pollen.services.service.security.PermissionVerb; -import org.nuiton.topia.persistence.TopiaIdFactory; import java.util.ArrayList; import java.util.Date; @@ -238,23 +236,18 @@ public class ChoiceService extends PollenServiceSupport { toSave.setChoiceType(choice.getChoiceType()); + //TODO agarandel 17/07/14 : review code : is switch case required switch (toSave.getChoiceType()) { case TEXT: - - toSave.setChoiceValue(choice.getChoiceValue()); - - break; - case DATE: + case IMAGE: toSave.setChoiceValue(choice.getChoiceValue()); - break; - case IMAGE: - - toSave.setChoiceValue(choice.getChoiceValue()); + default: + throw new UnsupportedOperationException("Unexpected value : " + toSave.getChoiceType()); } @@ -357,6 +350,9 @@ public class ChoiceService extends PollenServiceSupport { break; + default: + throw new UnsupportedOperationException("Unexpected value : " + choice.getChoiceType()); + } } -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.