Author: tchemit Date: 2011-10-20 06:25:09 +0200 (Thu, 20 Oct 2011) New Revision: 2364 Url: http://nuiton.org/repositories/revision/topia/2364 Log: Evolution #1782: Permits not to generate getXXX() methods for boolean properties on Entities Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityTransformer.java Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityTransformer.java =================================================================== --- trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityTransformer.java 2011-10-20 03:00:38 UTC (rev 2363) +++ trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/EntityTransformer.java 2011-10-20 04:25:09 UTC (rev 2364) @@ -101,6 +101,8 @@ protected boolean generateImpl; + protected boolean generateBooleanGetMethods; + protected void clean() { outputInterface = null; outputAbstract = null; @@ -139,6 +141,12 @@ generateAbstract = isGenerateAbstract(input); generateImpl = isGenerateImpl(input); + String noGenerateBooleanGetMethods = + JavaGeneratorUtil.getDoNotGenerateBooleanGetMethods(model, input); + boolean generateBooleanGetMethods = + StringUtils.isEmpty(noGenerateBooleanGetMethods) || + !"true".equals(noGenerateBooleanGetMethods.trim()); + if (generateInterface) { // Create Entity Interface and its header @@ -574,7 +582,7 @@ * method (association class, reverse, entity reference, ...). * * @param attribute Input attribute to treate - * @see #addSingleGetOperation(ObjectModelAttribute, String) + * @see #addSingleGetOperation(ObjectModelAttribute, String, String) * @see #addSingleSetOperation(ObjectModelAttribute) * @see #addMultipleAddOperation(ObjectModelAttribute, String) * @see #addMultipleAddAllOperation(ObjectModelAttribute, String) @@ -594,9 +602,27 @@ // setXXX addSingleSetOperation(attribute); - // getXXX - addSingleGetOperation(attribute, null); + String attrType = getPropertyType(attribute); + boolean booleanProperty = attrType.toLowerCase().contains("boolean"); + if (booleanProperty) { + + // isXXX + addSingleGetOperation( + attribute, + attrType, + TopiaGeneratorUtil.OPERATION_GETTER_BOOLEAN_PREFIX); + } + + if (!booleanProperty || generateBooleanGetMethods) { + + // getXXX + addSingleGetOperation( + attribute, + attrType, + TopiaGeneratorUtil.OPERATION_GETTER_DEFAULT_PREFIX); + } + } else { // List, Set or Collection ? @@ -688,19 +714,16 @@ * outputAbstract} and {@code outputInterface}. * * @param attribute ObjectModelAttribute for getter operation + * @param attrType type of the attribute * @param operationPrefix Operation prefix : 'get' by default, if prefix * is null */ protected void addSingleGetOperation(ObjectModelAttribute attribute, - String operationPrefix) { + String attrType, + String operationPrefix) { String attrName = getPropertyName(attribute); - String attrType = getPropertyType(attribute); - if (operationPrefix == null) { - operationPrefix = TopiaGeneratorUtil.OPERATION_GETTER_DEFAULT_PREFIX; - } - if (log.isDebugEnabled()) { log.debug("Generate single '" + operationPrefix + "' operation for property : " + attrName + " [" + attrType + "]"); @@ -725,13 +748,6 @@ return result; }*/ ); - - // Generate 'is' getter for boolean attributes - if (attrType.toLowerCase().contains("boolean") && - !operationPrefix.equals(TopiaGeneratorUtil.OPERATION_GETTER_BOOLEAN_PREFIX)) { - addSingleGetOperation(attribute, - TopiaGeneratorUtil.OPERATION_GETTER_BOOLEAN_PREFIX); - } } protected void addMultipleAddOperation(ObjectModelAttribute attribute,
participants (1)
-
tchemit@users.nuiton.org