Skip to content

Commit

Permalink
Fix generics usage (for compilation in Eclipse)
Browse files Browse the repository at this point in the history
  • Loading branch information
aledsage committed May 22, 2017
1 parent 1cfc0ed commit 15a203c
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static <T extends Enricher> EnricherSpec<T> create(Class<? extends T> typ
* @param config The spec's configuration (see {@link EnricherSpec#configure(Map)}).
* @param type An {@link Enricher} class
*/
public static <T extends Enricher> EnricherSpec<T> create(Map<?,?> config, Class<? extends T> type) {
public static <T extends Enricher> EnricherSpec<T> create(Map<?,?> config, Class<T> type) {
return EnricherSpec.create(type).configure(config);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class PlanInterpretationContext {

public PlanInterpretationContext(Map<String,?> originalDeploymentPlan, List<PlanInterpreter> interpreters) {
super();
this.originalDeploymentPlan = MutableMap.copyOf(originalDeploymentPlan).asUnmodifiable();
this.originalDeploymentPlan = MutableMap.<String, Object>copyOf(originalDeploymentPlan).asUnmodifiable();
this.interpreters = ImmutableList.copyOf(interpreters);
this.allInterpreter = new PlanInterpreter() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,17 +362,15 @@ public <T> void testDoesNotDoRegexMatchingWhenSensorsSpecified() throws Exceptio
}

@Test
@SuppressWarnings({ "unchecked", "rawtypes" })
public <T> void testCoercesSensorName() throws Exception {
AttributeSensor<String> sensor = Sensors.newStringSensor("mysensor");

entity.sensors().set(sensor, "127.0.0.1:1234");
portForwardManager.associate("myPublicIp", HostAndPort.fromParts("mypublichost", 5678), machine, 1234);
entity.addLocations(ImmutableList.of(machine));

// Ugly casting in java, but easy to get passed this when constructed from YAML
entity.enrichers().add(EnricherSpec.create(OnPublicNetworkEnricher.class)
.configure(OnPublicNetworkEnricher.SENSORS, ((List)ImmutableList.of("mysensor"))));
.configure(OnPublicNetworkEnricher.SENSORS.getName(), ImmutableList.of("mysensor")));

assertAttributeEqualsEventually("mysensor.mapped.public", "mypublichost:5678");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,8 @@ public CatalogEntitySummary getEntity(String symbolicName, String version) {
//TODO These casts are not pretty, we could just provide separate get methods for the different types?
//Or we could provide asEntity/asPolicy cast methods on the CataloItem doing a safety check internally
@SuppressWarnings("unchecked")
CatalogItem<Entity, EntitySpec<?>> result =
(CatalogItem<Entity, EntitySpec<?>>) brooklyn().getCatalog().getCatalogItem(symbolicName, version);
CatalogItem<Entity, EntitySpec<? extends Entity>> result =
(CatalogItem<Entity, EntitySpec<? extends Entity>>) brooklyn().getCatalog().getCatalogItem(symbolicName, version);

if (result==null) {
throw WebResourceUtils.notFound("Entity with id '%s:%s' not found", symbolicName, version);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,15 +242,15 @@ public static <T> Optional<T> invokeConstructorWithArgs(ClassLoader classLoader,
}
/** @deprecated since 0.10.0 use {@link #invokeConstructorFromArgs(Class, Object...)} or one of the variants */ @Deprecated
public static <T> Optional<T> invokeConstructorWithArgs(Class<? extends T> clazz, Object...argsArray) {
return invokeConstructorFromArgs(clazz, argsArray).toOptional();
return Reflections.<T>invokeConstructorFromArgs(clazz, argsArray).toOptional();
}
/** @deprecated since 0.10.0 use {@link #invokeConstructorFromArgs(Class, Object...)} or one of the variants */ @Deprecated
public static <T> Optional<T> invokeConstructorWithArgs(Class<? extends T> clazz, Object[] argsArray, boolean setAccessible) {
return invokeConstructorFromArgs(clazz, argsArray, setAccessible).toOptional();
return Reflections.<T>invokeConstructorFromArgs(clazz, argsArray, setAccessible).toOptional();
}
/** @deprecated since 0.10.0 use {@link #invokeConstructorFromArgs(Class, Object...)} or one of the variants */ @Deprecated
public static <T> Optional<T> invokeConstructorWithArgs(Reflections reflections, Class<? extends T> clazz, Object[] argsArray, boolean setAccessible) {
return invokeConstructorFromArgs(reflections, clazz, argsArray, setAccessible).toOptional();
return Reflections.<T>invokeConstructorFromArgs(reflections, clazz, argsArray, setAccessible).toOptional();
}

/** Finds and invokes a suitable constructor, supporting varargs and primitives, boxing and looking at compatible supertypes in the constructor's signature */
Expand Down

0 comments on commit 15a203c

Please sign in to comment.