Skip to content

Commit

Permalink
Add type to generics to remove warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
spelletier authored and darkv committed Jan 27, 2016
1 parent 77b49cf commit 8d6353c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 21 deletions.
20 changes: 11 additions & 9 deletions Frameworks/Ajax/Ajax/Sources/er/ajax/AjaxDraggable.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,12 @@ public boolean isStateless() {
return true;
}

@SuppressWarnings("unchecked")
public static Object draggableObjectForPage(WOComponent page, String draggableID) {
Object droppedObject = null;
Map componentDraggablesMap = (Map)page.context().session().objectForKey(AjaxDraggable.COMPONENT_DRAGGABLES_MAP_KEY);
Map<WOComponent, Map<String, Object>> componentDraggablesMap = (Map<WOComponent, Map<String, Object>>)page.context().session().objectForKey(AjaxDraggable.COMPONENT_DRAGGABLES_MAP_KEY);
if (componentDraggablesMap != null) {
Map draggablesMap = (Map) componentDraggablesMap.get(page);
Map<String, Object> draggablesMap = componentDraggablesMap.get(page);
if (draggablesMap != null) {
droppedObject = draggablesMap.get(draggableID);
}
Expand All @@ -115,18 +116,19 @@ public static Object draggableObjectForPage(WOComponent page, String draggableID
}

@Override
@SuppressWarnings("unchecked")
public void appendToResponse(WOResponse res, WOContext ctx) {
if (canGetValueForBinding("draggableObject")) {
Object draggableObject = valueForBinding("draggableObject");
WOComponent page = context().page();
Map componentDraggablesMap = (Map)ctx.session().objectForKey(AjaxDraggable.COMPONENT_DRAGGABLES_MAP_KEY);
Map<WOComponent, Map<String, Object>> componentDraggablesMap = (Map<WOComponent, Map<String, Object>>) ctx.session().objectForKey(AjaxDraggable.COMPONENT_DRAGGABLES_MAP_KEY);
if (componentDraggablesMap == null) {
componentDraggablesMap = new WeakHashMap();
componentDraggablesMap = new WeakHashMap<WOComponent, Map<String, Object>>();
ctx.session().setObjectForKey(componentDraggablesMap, AjaxDraggable.COMPONENT_DRAGGABLES_MAP_KEY);
}
Map draggablesMap = (Map) componentDraggablesMap.get(page);
Map<String, Object> draggablesMap = componentDraggablesMap.get(page);
if (draggablesMap == null) {
draggablesMap = new HashMap();
draggablesMap = new HashMap<String, Object>();
componentDraggablesMap.put(page, draggablesMap);
}
String id = draggableID();
Expand All @@ -140,8 +142,8 @@ public void appendToResponse(WOResponse res, WOContext ctx) {
super.appendToResponse(res, ctx);
}

public NSDictionary createAjaxOptions() {
NSMutableArray ajaxOptionsArray = new NSMutableArray();
public NSDictionary<String, String> createAjaxOptions() {
NSMutableArray<AjaxOption> ajaxOptionsArray = new NSMutableArray<AjaxOption>();
// PROTOTYPE OPTIONS
ajaxOptionsArray.addObject(new AjaxOption("starteffect", AjaxOption.SCRIPT));
ajaxOptionsArray.addObject(new AjaxOption("reverteffect", AjaxOption.SCRIPT));
Expand All @@ -154,7 +156,7 @@ public NSDictionary createAjaxOptions() {
ajaxOptionsArray.addObject(new AjaxOption("change", AjaxOption.SCRIPT));
ajaxOptionsArray.addObject(new AjaxOption("keyPress", AjaxOption.SCRIPT));
ajaxOptionsArray.addObject(new AjaxOption("scroll", AjaxOption.SCRIPT));
NSMutableDictionary options = AjaxOption.createAjaxOptionsDictionary(ajaxOptionsArray, this);
NSMutableDictionary<String, String> options = AjaxOption.createAjaxOptionsDictionary(ajaxOptionsArray, this);
return options;
}

Expand Down
25 changes: 13 additions & 12 deletions Frameworks/Ajax/Ajax/Sources/er/ajax/AjaxSortableList.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ protected void addRequiredWebResources(WOResponse res) {
addScriptResourceInHead(res, "dragdrop.js");
}

public NSDictionary createAjaxOptions() {
NSMutableArray ajaxOptionsArray = new NSMutableArray();
public NSDictionary<String, String> createAjaxOptions() {
NSMutableArray<AjaxOption> ajaxOptionsArray = new NSMutableArray<AjaxOption>();
ajaxOptionsArray.addObject(new AjaxOption("tag", AjaxOption.STRING));
ajaxOptionsArray.addObject(new AjaxOption("treeTag", AjaxOption.STRING));
ajaxOptionsArray.addObject(new AjaxOption("only", AjaxOption.STRING_ARRAY));
Expand All @@ -147,7 +147,7 @@ public NSDictionary createAjaxOptions() {
ajaxOptionsArray.addObject(new AjaxOption("dropOnEmpty", AjaxOption.BOOLEAN));
ajaxOptionsArray.addObject(new AjaxOption("scroll", AjaxOption.BOOLEAN));
ajaxOptionsArray.addObject(new AjaxOption("onChange", AjaxOption.SCRIPT));
NSMutableDictionary options = AjaxOption.createAjaxOptionsDictionary(ajaxOptionsArray, this);
NSMutableDictionary<String, String> options = AjaxOption.createAjaxOptionsDictionary(ajaxOptionsArray, this);
return options;
}

Expand Down Expand Up @@ -183,6 +183,7 @@ public String onUpdate() {
return onUpdateBuffer.toString();
}

@SuppressWarnings("unchecked")
@Override
public WOActionResults handleRequest(WORequest request, WOContext context) {
if (!canGetValueForBinding("list")) {
Expand All @@ -193,26 +194,26 @@ public WOActionResults handleRequest(WORequest request, WOContext context) {
}
String listItemIDKeyPath = (String) valueForBinding("listItemIDKeyPath");
Object listItemIDArrayObj = request.formValues().objectForKey(_sortOrderKeyName + "[]");
NSArray listItemIDArray;
NSArray<String> listItemIDArray;
if (listItemIDArrayObj instanceof NSArray) {
listItemIDArray = (NSArray) listItemIDArrayObj;
listItemIDArray = (NSArray<String>) listItemIDArrayObj;
}
else if (listItemIDArrayObj instanceof String) {
String listItemIDStr = (String) listItemIDArrayObj;
listItemIDArray = new NSArray(listItemIDStr);
listItemIDArray = new NSArray<String>(listItemIDStr);
}
else {
throw new IllegalArgumentException("Unknown list item ID array " + listItemIDArrayObj);
}

NSArray list = (NSArray) valueForBinding("list");
NSArray<Object> list = (NSArray<Object>) valueForBinding("list");
boolean mutableList = (list instanceof NSMutableArray);
NSMutableArray reorderedList;
NSMutableArray<Object> reorderedList;
if (mutableList) {
reorderedList = (NSMutableArray) list;
reorderedList = (NSMutableArray<Object>) list;
}
else {
reorderedList = new NSMutableArray();
reorderedList = new NSMutableArray<Object>();
}

int startIndex = 0;
Expand All @@ -238,9 +239,9 @@ else if (listItemIDArrayObj instanceof String) {
else {
itemPageRange = new NSRange(startIndex, listItemIDCount);
}
NSArray itemPageArray = list.subarrayWithRange(itemPageRange);
NSArray<Object> itemPageArray = list.subarrayWithRange(itemPageRange);
EOQualifier itemIDQualifier = new EOKeyValueQualifier(listItemIDKeyPath, EOQualifier.QualifierOperatorEqual, itemID);
NSArray matchingItems = EOQualifier.filteredArrayWithQualifier(itemPageArray, itemIDQualifier);
NSArray<Object> matchingItems = EOQualifier.filteredArrayWithQualifier(itemPageArray, itemIDQualifier);
if (matchingItems.count() == 0) {
throw new NoSuchElementException("There was no item that matched the ID '" + itemID + "' in " + list + ".");
}
Expand Down

0 comments on commit 8d6353c

Please sign in to comment.