You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by nt...@apache.org on 2019/04/11 08:40:14 UTC

[cayenne] 03/03: Additional checks

This is an automated email from the ASF dual-hosted git repository.

ntimofeev pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cayenne.git

commit 9e3b9fdfadfd410ad737ee842e23f7bcf4e8c22a
Author: Nikita Timofeev <st...@gmail.com>
AuthorDate: Thu Apr 11 11:39:55 2019 +0300

    Additional checks
---
 .../org/apache/cayenne/reflect/BeanAccessor.java    | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/cayenne-server/src/main/java/org/apache/cayenne/reflect/BeanAccessor.java b/cayenne-server/src/main/java/org/apache/cayenne/reflect/BeanAccessor.java
index 354699e..9fa8f8d 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/reflect/BeanAccessor.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/reflect/BeanAccessor.java
@@ -45,13 +45,7 @@ public class BeanAccessor implements Accessor {
 			throw new IllegalArgumentException("Null objectClass");
 		}
 
-		if (propertyName == null) {
-			throw new IllegalArgumentException("Null propertyName");
-		}
-
-		if (propertyName.length() == 0) {
-			throw new IllegalArgumentException("Empty propertyName");
-		}
+		checkPropertyName(propertyName);
 		
 		if (booleanGetterName == null) {
 			throw new IllegalArgumentException("Null booleanGetterName");
@@ -165,17 +159,30 @@ public class BeanAccessor implements Accessor {
 	}
 	
 	private static String defaultSetterName( String propertyName ) {
+		checkPropertyName(propertyName);
 		final String capitalized = Character.toUpperCase(propertyName.charAt(0)) + propertyName.substring(1);
 		return "set" + capitalized;
 	}
 
 	private static String defaultGetterName( String propertyName ) {
+		checkPropertyName(propertyName);
 		final String capitalized = Character.toUpperCase(propertyName.charAt(0)) + propertyName.substring(1);
 		return "get" + capitalized;
 	}
 
 	private static String defaultBooleanGetterName( String propertyName ) {
+		checkPropertyName(propertyName);
 		final String capitalized = Character.toUpperCase(propertyName.charAt(0)) + propertyName.substring(1);
 		return "is" + capitalized;
 	}
+
+	private static void checkPropertyName(String propertyName) {
+		if (propertyName == null) {
+			throw new IllegalArgumentException("Null propertyName");
+		}
+
+		if (propertyName.length() == 0) {
+			throw new IllegalArgumentException("Empty propertyName");
+		}
+	}
 }