Skip to content

Commit

Permalink
Remove some raw usage of generic types
Browse files Browse the repository at this point in the history
We can add more type information and make Sonar and IntelliJ happier.
  • Loading branch information
rhowe committed Feb 2, 2022
1 parent e39201e commit 4e03652
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ public HealthCheckManager(final List<HealthCheckConfiguration> configs,

this.aggregateHealthyName = MetricRegistry.name("health", "aggregate", "healthy");
this.aggregateUnhealthyName = MetricRegistry.name("health", "aggregate", "unhealthy");
metrics.register(aggregateHealthyName, (Gauge) this::calculateNumberOfHealthyChecks);
metrics.register(aggregateUnhealthyName, (Gauge) this::calculateNumberOfUnhealthyChecks);
metrics.register(aggregateHealthyName, (Gauge<Long>) this::calculateNumberOfHealthyChecks);
metrics.register(aggregateUnhealthyName, (Gauge<Long>) this::calculateNumberOfUnhealthyChecks);
}

// visible for testing
Expand Down
17 changes: 8 additions & 9 deletions dropwizard-util/src/test/java/io/dropwizard/util/MapsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class MapsTest {

@Test
void of2KeyValuePairs() {
final Map map = Maps.of(1, 60, 2, 61);
final HashMap hashMap = new HashMap();
final Map<Integer,Integer> map = Maps.of(1, 60, 2, 61);
final HashMap<Integer,Integer> hashMap = new HashMap<>();
hashMap.put(1, 60);
hashMap.put(2, 61);

Expand All @@ -21,8 +21,8 @@ void of2KeyValuePairs() {

@Test
void of3KeyValuePairs() {
final Map map = Maps.of(1, 60, 2, 61, 3, 62);
final HashMap hashMap = new HashMap();
final Map<Integer,Integer> map = Maps.of(1, 60, 2, 61, 3, 62);
final HashMap<Integer,Integer> hashMap = new HashMap<>();
hashMap.put(1, 60);
hashMap.put(2, 61);
hashMap.put(3, 62);
Expand All @@ -32,8 +32,8 @@ void of3KeyValuePairs() {

@Test
void of4KeyValuePairs() {
final Map map = Maps.of(1, 60, 2, 61, 3, 62, 4, 63);
final HashMap hashMap = new HashMap();
final Map<Integer,Integer> map = Maps.of(1, 60, 2, 61, 3, 62, 4, 63);
final HashMap<Integer,Integer> hashMap = new HashMap<>();
hashMap.put(1, 60);
hashMap.put(2, 61);
hashMap.put(3, 62);
Expand All @@ -44,8 +44,8 @@ void of4KeyValuePairs() {

@Test
void of5KeyValuePairs() {
final Map map = Maps.of(1, 60, 2, 61, 3, 62, 4, 63, 5, 64);
final HashMap hashMap = new HashMap();
final Map<Integer,Integer> map = Maps.of(1, 60, 2, 61, 3, 62, 4, 63, 5, 64);
final HashMap<Integer,Integer> hashMap = new HashMap<>();
hashMap.put(1, 60);
hashMap.put(2, 61);
hashMap.put(3, 62);
Expand All @@ -54,5 +54,4 @@ void of5KeyValuePairs() {

assertThat(map).isEqualTo(hashMap);
}

}
16 changes: 8 additions & 8 deletions dropwizard-util/src/test/java/io/dropwizard/util/SetsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,30 @@ class SetsTest {

@Test
void of2Elements() {
final Set set = Sets.of(1, 2);
final Set<Integer> set = Sets.of(1, 2);

assertThat(set).isEqualTo(new HashSet(Arrays.asList(1, 2)));
assertThat(set).isEqualTo(new HashSet<>(Arrays.asList(1, 2)));
}

@Test
void of3Elements() {
final Set set = Sets.of(1, 2, 1);
final Set<Integer> set = Sets.of(1, 2, 1);

assertThat(set).isEqualTo(new HashSet(Arrays.asList(1, 2)));
assertThat(set).isEqualTo(new HashSet<>(Arrays.asList(1, 2)));
}

@Test
void of4Elements() {
final Set set = Sets.of(1, 2, 1, 1);
final Set<Integer> set = Sets.of(1, 2, 1, 1);

assertThat(set).isEqualTo(new HashSet(Arrays.asList(1, 2)));
assertThat(set).isEqualTo(new HashSet<>(Arrays.asList(1, 2)));
}

@Test
void of5Elements() {
final Set set = Sets.of(1, 1, 2, 3, 3);
final Set<Integer> set = Sets.of(1, 1, 2, 3, 3);

assertThat(set).isEqualTo(new HashSet(Arrays.asList(1, 2, 3)));
assertThat(set).isEqualTo(new HashSet<>(Arrays.asList(1, 2, 3)));
}

}

0 comments on commit 4e03652

Please sign in to comment.