@@ -29,7 +29,7 @@ public abstract class AbstractStrategy implements RevengStrategy {
2929
3030 static final private Logger log = Logger .getLogger (AbstractStrategy .class );
3131
32- private static Set <String > AUTO_OPTIMISTICLOCK_COLUMNS ;
32+ private static final Set <String > AUTO_OPTIMISTICLOCK_COLUMNS ;
3333
3434 private RevengSettings settings = new RevengSettings (this );
3535
@@ -145,7 +145,7 @@ public String tableToClassName(TableIdentifier tableIdentifier) {
145145 String pkgName = settings .getDefaultPackageName ();
146146 String className = toUpperCamelCase ( tableIdentifier .getName () );
147147
148- if (pkgName .length ()> 0 ) {
148+ if (! pkgName .isEmpty () ) {
149149 return StringHelper .qualify (pkgName , className );
150150 }
151151 else {
@@ -187,7 +187,7 @@ public String getOptimisticLockColumnName(TableIdentifier identifier) {
187187
188188 public boolean useColumnForOptimisticLock (TableIdentifier identifier , String column ) {
189189 if (settings .getDetectOptimsticLock ()) {
190- return AUTO_OPTIMISTICLOCK_COLUMNS .contains (column .toLowerCase ())? true : false ;
190+ return AUTO_OPTIMISTICLOCK_COLUMNS .contains (column .toLowerCase ());
191191 } else {
192192 return false ;
193193 }
@@ -221,11 +221,7 @@ public boolean isForeignKeyCollectionInverse(String name, Table foreignKeyTable,
221221 // if the reference column is the first one then we are inverse.
222222 Column column = foreignKeyTable .getColumn (0 );
223223 Column fkColumn = (Column ) referencedColumns .get (0 );
224- if (fkColumn .equals (column )) {
225- return true ;
226- } else {
227- return false ;
228- }
224+ return fkColumn .equals (column );
229225 }
230226 return true ;
231227 }
@@ -242,26 +238,23 @@ public boolean isOneToOne(ForeignKey foreignKey) {
242238 if (settings .getDetectOneToOne ()) {
243239 // add support for non-PK associations
244240 List <Column > fkColumns = foreignKey .getColumns ();
245- List <Column > pkForeignTableColumns = null ;
246-
241+ List <Column > pkForeignTableColumns = Collections . emptyList () ;
242+
247243 if (foreignKey .getTable ().hasPrimaryKey ())
248244 pkForeignTableColumns = foreignKey .getTable ().getPrimaryKey ().getColumns ();
249245
250- boolean equals =
251- fkColumns != null && pkForeignTableColumns != null
252- && fkColumns .size () == pkForeignTableColumns .size ();
246+ boolean equals = fkColumns .size () == pkForeignTableColumns .size ();
253247
254248 Iterator <Column > columns = foreignKey .getColumns ().iterator ();
255249 while (equals && columns .hasNext ()) {
256- Column fkColumn = ( Column ) columns .next ();
257- equals = equals && pkForeignTableColumns .contains (fkColumn );
250+ Column fkColumn = columns .next ();
251+ equals = pkForeignTableColumns .contains (fkColumn );
258252 }
259-
260253 return equals ;
261254 } else {
262255 return false ;
263256 }
264- }
257+ }
265258
266259 public boolean isManyToManyTable (Table table ) {
267260 if (settings .getDetectManyToMany ()) {
@@ -287,14 +280,11 @@ public boolean isManyToManyTable(Table table) {
287280 }
288281
289282 // tests that all columns are implied in the fks
290- Set <Column > columns = new HashSet <Column >();
291- for (Column column : table .getColumns ()) {
292- columns .add (column );
293- }
283+ Set <Column > columns = new HashSet <>(table .getColumns ());
294284
295285 for (ForeignKey fkey : table .getForeignKeys ().values ()) {
296286 if (columns .isEmpty ()) break ;
297- columns . removeAll ( fkey .getColumns ());
287+ fkey .getColumns (). forEach ( columns :: remove );
298288 }
299289
300290 return columns .isEmpty ();
0 commit comments