Skip to content

Commit e8aa552

Browse files
DavideDSanne
authored andcommitted
HSEARCH-1326 Fix NeedBraces checkstyle violations
1 parent a7edfbe commit e8aa552

34 files changed

+276
-112
lines changed

infinispan/src/test/java/org/hibernate/search/infinispan/sharedIndex/Device.java

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,32 +69,47 @@ public int hashCode() {
6969

7070
@Override
7171
public boolean equals(Object obj) {
72-
if ( this == obj )
72+
if ( this == obj ) {
7373
return true;
74-
if ( obj == null )
74+
}
75+
if ( obj == null ) {
7576
return false;
76-
if ( !( obj instanceof Device ) )
77+
}
78+
if ( !( obj instanceof Device ) ) {
7779
return false;
80+
}
7881
Device other = (Device) obj;
7982

8083
if ( manufacturer == null ) {
81-
if ( other.manufacturer != null )
84+
if ( other.manufacturer != null ) {
8285
return false;
86+
}
87+
}
88+
else {
89+
if ( !manufacturer.equals( other.manufacturer ) ) {
90+
return false;
91+
}
8392
}
84-
else if ( !manufacturer.equals( other.manufacturer ) )
85-
return false;
8693
if ( model == null ) {
87-
if ( other.model != null )
94+
if ( other.model != null ) {
8895
return false;
96+
}
97+
}
98+
else {
99+
if ( !model.equals( other.model ) ) {
100+
return false;
101+
}
89102
}
90-
else if ( !model.equals( other.model ) )
91-
return false;
92103
if ( serialNumber == null ) {
93-
if ( other.serialNumber != null )
104+
if ( other.serialNumber != null ) {
94105
return false;
106+
}
107+
}
108+
else {
109+
if ( !serialNumber.equals( other.serialNumber ) ) {
110+
return false;
111+
}
95112
}
96-
else if ( !serialNumber.equals( other.serialNumber ) )
97-
return false;
98113
return true;
99114
}
100115
}

orm/src/main/java/org/hibernate/search/batchindexing/impl/IdentifierProducer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,9 @@ private void loadAllIdentifiers(final StatelessSession session) throws Interrupt
136136
if ( objectsLimit != 0 && objectsLimit < totalCount ) {
137137
totalCount = objectsLimit;
138138
}
139-
if ( log.isDebugEnabled() )
139+
if ( log.isDebugEnabled() ) {
140140
log.debugf( "going to fetch %d primary keys", totalCount);
141+
}
141142
monitor.addToTotalCount( totalCount );
142143

143144
Criteria criteria = session

orm/src/main/java/org/hibernate/search/cfg/impl/SearchConfigurationFromHibernateCore.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ public class SearchConfigurationFromHibernateCore extends SearchConfigurationBas
5050
private ReflectionManager reflectionManager;
5151

5252
public SearchConfigurationFromHibernateCore(org.hibernate.cfg.Configuration cfg) {
53-
if ( cfg == null ) throw new NullPointerException( "Configuration is null" );
53+
if ( cfg == null ) {
54+
throw new NullPointerException( "Configuration is null" );
55+
}
5456
this.cfg = cfg;
5557
}
5658

@@ -105,7 +107,9 @@ private ClassIterator(Iterator hibernatePersistentClassIterator) {
105107

106108
public boolean hasNext() {
107109
//we need to read the next non null one. getMappedClass() can return null and should be ignored
108-
if ( future != null) return true;
110+
if ( future != null) {
111+
return true;
112+
}
109113
do {
110114
if ( ! hibernatePersistentClassIterator.hasNext() ) {
111115
future = null;
@@ -120,7 +124,9 @@ public boolean hasNext() {
120124

121125
public Class<?> next() {
122126
//run hasNext to init the next element
123-
if ( ! hasNext() ) throw new NoSuchElementException();
127+
if ( ! hasNext() ) {
128+
throw new NoSuchElementException();
129+
}
124130
Class<?> result = future;
125131
future = null;
126132
return result;

orm/src/main/java/org/hibernate/search/query/hibernate/impl/IteratorImpl.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ public IteratorImpl(List<EntityInfo> entityInfos, Loader loader) {
5050

5151
//side effect is to set up next
5252
public boolean hasNext() {
53-
if ( nextObjectIndex == index ) return next != null;
53+
if ( nextObjectIndex == index ) {
54+
return next != null;
55+
}
5456
next = null;
5557
nextObjectIndex = -1;
5658
do {
@@ -73,7 +75,9 @@ public boolean hasNext() {
7375

7476
public Object next() {
7577
//hasNext() has side effect
76-
if ( !hasNext() ) throw new NoSuchElementException( "Out of boundaries" );
78+
if (!hasNext()) {
79+
throw new NoSuchElementException( "Out of boundaries" );
80+
}
7781
index++;
7882
return next;
7983
}

orm/src/main/java/org/hibernate/search/query/hibernate/impl/LookupObjectsInitializer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ public void initializeObjects(EntityInfo[] entityInfos,
6767
for ( EntityInfo entityInfo : entityInfos ) {
6868
ObjectLoaderHelper.load( entityInfo, session );
6969
}
70-
if ( traceEnabled )
70+
if ( traceEnabled ) {
7171
log.tracef( "Initialized %d objects by lookup method.", maxResults );
72+
}
7273
}
7374
}

orm/src/main/java/org/hibernate/search/query/hibernate/impl/MultiClassesQueryLoader.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ public Object executeLoad(EntityInfo entityInfo) {
9595
}
9696

9797
public List executeLoad(EntityInfo... entityInfos) {
98-
if ( entityInfos.length == 0 ) return Collections.EMPTY_LIST;
98+
if ( entityInfos.length == 0 ) {
99+
return Collections.EMPTY_LIST;
100+
}
99101
if ( entityInfos.length == 1 ) {
100102
final Object entity = load( entityInfos[0] );
101103
if ( entity == null ) {
@@ -125,7 +127,9 @@ public List executeLoad(EntityInfo... entityInfos) {
125127
break; //we stop looping for the right bucket
126128
}
127129
}
128-
if (!found) throw new AssertionFailure( "Could not find root entity for " + clazz );
130+
if (!found) {
131+
throw new AssertionFailure( "Could not find root entity for " + clazz );
132+
}
129133
}
130134

131135
//initialize objects by bucket
@@ -155,7 +159,9 @@ private static class RootEntityMetadata {
155159
RootEntityMetadata(Class<?> rootEntity, SearchFactoryImplementor searchFactoryImplementor) {
156160
this.rootEntity = rootEntity;
157161
EntityIndexBinding provider = searchFactoryImplementor.getIndexBinding( rootEntity );
158-
if ( provider == null) throw new AssertionFailure("Provider not found for class: " + rootEntity);
162+
if ( provider == null) {
163+
throw new AssertionFailure("Provider not found for class: " + rootEntity);
164+
}
159165
this.mappedSubclasses = provider.getDocumentBuilder().getMappedSubclasses();
160166
this.criteria = null; //default
161167
}

orm/src/main/java/org/hibernate/search/query/hibernate/impl/ScrollableResultsImpl.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,9 @@ private LoadedObject ensureCurrentLoaded() {
124124
entityInfosToLoad.add( lo.getEntityInfo( x ) );
125125
resultsContext[arrayIdx] = lo;
126126
sizeToLoad++;
127-
if ( sizeToLoad >= fetchSize )
127+
if ( sizeToLoad >= fetchSize ) {
128128
break;
129+
}
129130
}
130131
}
131132
//preload efficiently by batches:
@@ -230,7 +231,9 @@ public Object[] get() throws HibernateException {
230231
// (or 0 I can't remember) but we can't
231232
// do that since we have to make up for
232233
// an Object[]. J.G
233-
if ( current < first || current > max ) return null;
234+
if ( current < first || current > max ) {
235+
return null;
236+
}
234237
LoadedObject cacheEntry = ensureCurrentLoaded();
235238
return cacheEntry.getManagedResult( current );
236239
}
@@ -404,7 +407,9 @@ public TimeZone getTimeZone(int col) {
404407
}
405408

406409
public int getRowNumber() {
407-
if ( max < first ) return -1;
410+
if ( max < first ) {
411+
return -1;
412+
}
408413
return current - first;
409414
}
410415

@@ -437,7 +442,9 @@ private Object[] getManagedResult(int x) {
437442
}
438443
else {
439444
Object loaded = loader.load( entityInfo );
440-
if ( ! loaded.getClass().isArray() ) loaded = new Object[] { loaded };
445+
if ( ! loaded.getClass().isArray() ) {
446+
loaded = new Object[] { loaded };
447+
}
441448
objects = (Object[]) loaded;
442449
this.entity = new SoftReference<Object[]>( objects );
443450
return objects;
@@ -473,8 +480,9 @@ private boolean areAllEntitiesManaged(Object[] objects, EntityInfo entityInfo) {
473480
for ( int idx : entityInfo.getIndexesOfThis() ) {
474481
Object o = objects[idx];
475482
//TODO improve: is it useful to check for proxies and have them reassociated to persistence context?
476-
if ( ! hibSession.contains( o ) )
483+
if ( ! hibSession.contains( o ) ) {
477484
return false;
485+
}
478486
}
479487
return true;
480488
}

orm/src/main/java/org/hibernate/search/query/hibernate/impl/SecondLevelCacheObjectsInitializer.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ public void initializeObjects(EntityInfo[] entityInfos,
5656
//Do not call isTimeOut here as the caller might be the last biggie on the list.
5757
final int maxResults = entityInfos.length;
5858
if ( maxResults == 0 ) {
59-
if ( traceEnabled ) log.tracef( "No object to initialize", maxResults );
59+
if ( traceEnabled ) {
60+
log.tracef( "No object to initialize", maxResults );
61+
}
6062
return;
6163
}
6264

@@ -88,7 +90,9 @@ public void initializeObjects(EntityInfo[] entityInfos,
8890
//update entityInfos to only contains the remaining ones
8991
final int remainingSize = remainingEntityInfos.size();
9092

91-
if ( traceEnabled ) log.tracef( "Initialized %d objects out of %d in the second level cache", maxResults - remainingSize, maxResults );
93+
if ( traceEnabled ) {
94+
log.tracef( "Initialized %d objects out of %d in the second level cache", maxResults - remainingSize, maxResults );
95+
}
9296
if ( remainingSize > 0 ) {
9397
delegate.initializeObjects(
9498
remainingEntityInfos.toArray( new EntityInfo[remainingSize] ),

orm/src/test/java/org/hibernate/search/test/PurgeTest.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ public void testPurge() throws Exception {
7878
assertEquals( "incorrect test record count", 1, results.size() );
7979
assertEquals( "incorrect test record", 2, ( (Clock) results.get( 0 ) ).getId().intValue() );
8080

81-
for ( Object element : s.createQuery( "from java.lang.Object" ).list() )
81+
for ( Object element : s.createQuery( "from java.lang.Object" ).list() ) {
8282
s.delete( element );
83+
}
8384
tx.commit();
8485
s.close();
8586
}
@@ -119,7 +120,9 @@ public void testPurgeAll() throws Exception {
119120
results = hibQuery.list();
120121
assertEquals( "incorrect class purged", 2, results.size() );
121122

122-
for (Object element : s.createQuery( "from java.lang.Object" ).list()) s.delete( element );
123+
for (Object element : s.createQuery( "from java.lang.Object" ).list()) {
124+
s.delete( element );
125+
}
123126
tx.commit();
124127
s.close();
125128
}

orm/src/test/java/org/hibernate/search/test/SerializationTestHelper.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,19 @@ public int hashCode() {
106106

107107
@Override
108108
public boolean equals(Object obj) {
109-
if (this == obj)
109+
if (this == obj) {
110110
return true;
111-
if (obj == null)
111+
}
112+
if (obj == null) {
112113
return false;
113-
if (getClass() != obj.getClass())
114+
}
115+
if (getClass() != obj.getClass()) {
114116
return false;
117+
}
115118
final TestInnerClass other = (TestInnerClass) obj;
116-
if (v != other.v)
119+
if (v != other.v) {
117120
return false;
121+
}
118122
return true;
119123
}
120124
}

0 commit comments

Comments
 (0)