Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import javax.lang.model.element.Element;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.TypeElement;
import javax.lang.model.element.TypeParameterElement;
import javax.lang.model.element.VariableElement;
import javax.lang.model.type.ArrayType;
import javax.lang.model.type.DeclaredType;
Expand Down Expand Up @@ -109,7 +110,6 @@ public Parameter(String name, JClass jClass) {
public JMethod overrideAnnotatedMethod(ExecutableElement executableElement, GeneratedClassHolder holder) {

String methodName = executableElement.getSimpleName().toString();

JClass returnType = typeMirrorToJClass(executableElement.getReturnType(), holder);

List<Parameter> parameters = new ArrayList<Parameter>();
Expand Down Expand Up @@ -139,6 +139,21 @@ public JMethod overrideAnnotatedMethod(ExecutableElement executableElement, Gene
method._throws(thrownType);
}

for (TypeParameterElement typeParameter : executableElement.getTypeParameters()) {
List<? extends TypeMirror> bounds = typeParameter.getBounds();

JClass jClassBounds;
if (bounds.isEmpty()) {
jClassBounds = holder.classes().OBJECT;
} else {
// Currently Codemodel can't generate generics with multiple
// classes like this <T extends Number & Serializable>.
// So we only take the first class
jClassBounds = typeMirrorToJClass(bounds.get(0), holder);
}
method.generify(typeParameter.toString(), jClassBounds);
}

callSuperMethod(method, holder, method.body());

return method;
Expand Down
1 change: 1 addition & 0 deletions 1 AndroidAnnotations/functional-test-1-5/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
<activity android:name="org.androidannotations.test15.AwaitingResultActivity_" />
<activity android:name=".HierarchyViewerActivity_" />
<activity android:name="org.androidannotations.test15.CustomTitleActivity_" />
<activity android:name=".ActivityWithGenerics_" />

<receiver android:name="org.androidannotations.test15.ereceiver.MyReceiver_" />

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
* Copyright (C) 2010-2013 eBusiness Information, Excilys Group
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed To in writing, software
* distributed under the License is distributed on 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 org.androidannotations.test15;

import java.util.List;

import org.androidannotations.annotations.Background;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.UiThread;

import android.app.Activity;

@EActivity
public class ActivityWithGenerics extends Activity {

// @UiThread
// <T, S extends Number & List<String>> void emptyUiMethod(T param, S param2) {
// // Not possible due to Codemodel's constraints
// }

@UiThread
<T, S extends Number> void emptyUiMethod(T param) {

}

@Background
<T, S extends Number> void emptyBackgroundMethod(T param) {

}

@Background
<T extends Number> void emptyBackgroundMethod(T param, List<T> param2) {

}

}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.