Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix generics usage (for compilation in Eclipse) #691

Merged
merged 1 commit into from
May 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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