Skip to content

Commit

Permalink
👕 fix check style
Browse files Browse the repository at this point in the history
  • Loading branch information
germanattanasio committed Mar 31, 2017
1 parent c6497ed commit d5ccc68
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 36 deletions.
70 changes: 34 additions & 36 deletions core/src/test/java/com/ibm/watson/developer_cloud/util/WaitFor.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/

package com.ibm.watson.developer_cloud.util;

import java.util.concurrent.TimeUnit;
Expand All @@ -21,43 +20,42 @@
*/

public class WaitFor {
/**
* Static method used to wait for a specific condition to be satisfied.
*
* @param condition
* The condition to check
* @param time
* The maximum time to wait for the condition to become true
* @param unit
* The time unit of the {@code time} argument
* @param sleepMs
* The time to wait between checks
*
* @return true if the condition was true before the timeout, false if it wasn't.
*/
public static boolean waitFor(Condition condition, long time, TimeUnit unit, long sleepMs) {
long waitMs = unit.toMillis(time);
long startMs = System.currentTimeMillis();
while (System.currentTimeMillis() - startMs < waitMs) {
if (condition.isSatisfied()) {
return true;
}
try {
Thread.sleep(sleepMs);
} catch (InterruptedException e) {
throw new RuntimeException("WaitFor aborted", e);
}
}
return false;

private WaitFor() {}

/**
* Static method used to wait for a specific condition to be satisfied.
*
* @param condition The condition to check
* @param time The maximum time to wait for the condition to become true
* @param unit The time unit of the {@code time} argument
* @param sleepMs The time to wait between checks
*
* @return true if the condition was true before the timeout, false if it wasn't.
*/
public static boolean waitFor(Condition condition, long time, TimeUnit unit, long sleepMs) {
long waitMs = unit.toMillis(time);
long startMs = System.currentTimeMillis();
while (System.currentTimeMillis() - startMs < waitMs) {
if (condition.isSatisfied()) {
return true;
}
try {
Thread.sleep(sleepMs);
} catch (InterruptedException e) {
throw new RuntimeException("WaitFor aborted", e);
}
}
return false;
}

/**
* The Interface Condition.
*/
public interface Condition {
/**
* The Interface Condition.
* @return true/false indicating whether or not the condition has been met.
*/
public interface Condition {
/**
* @return true/false indicating whether or not the condition has been met.
*/
boolean isSatisfied();
}
boolean isSatisfied();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
* Override default enum handling for poorly formed JSON field types schema.
*/
public class FieldAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
if (!Field.class.isAssignableFrom(typeToken.getRawType())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
* Override the default {@link LazilyParsedNumber} for parsing {@link Number}s.
*/
public class EagerNumberAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
if (!Number.class.isAssignableFrom(typeToken.getRawType())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* Adapts the abstract {@link Aggregation} to its concrete implementations.
*/
public class AggregationAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
if (typeToken.getRawType() != Aggregation.class) {
Expand Down

0 comments on commit d5ccc68

Please sign in to comment.