-
-
Notifications
You must be signed in to change notification settings - Fork 352
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
review: feat: Spoon CtRole based attributes access #1582
Changes from 1 commit
dc3d82e
7912506
504be24
ac8ded6
47db6a7
f28040f
7eed056
6c64be7
e4134f4
f7f577f
f1ede5d
f263563
1498392
8f2e84f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,45 +24,64 @@ | |
import spoon.reflect.path.CtRole; | ||
|
||
/** | ||
* Enables the user to get and set a field based on a rol for a CtElement | ||
* Enables client code to get and set a field based on a role for a CtElement. | ||
* | ||
* One obtains instances of {@link RoleHandler} using the methods of {@link spoon.reflect.meta.impl.RoleHandlerHelper}. | ||
* | ||
* There is one role handler per role of {@link CtRole}, they are set by {@link spoon.reflect.meta.impl.RoleHandlerHelper}. | ||
*/ | ||
public interface RoleHandler { | ||
// the main methods, responsible to get and set the field corresponding to this role | ||
/** | ||
* @param element a element whose value will be get | ||
* @param element a element from which the value will be get for this role | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here too
|
||
* @return a value of the element on the role defined by {@link #getRole()} | ||
*/ | ||
<T, U> U getValue(T element); | ||
/** | ||
* @param element a element whose value will be set | ||
* @param element a element whose value will be set for this role | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here too
|
||
* @param value new value, which will be assigned to the element's attribute defined by role defined by {@link #getRole()} | ||
*/ | ||
<T, U> void setValue(T element, U value); | ||
|
||
// introspection methods | ||
/** | ||
* @return a role of this handler | ||
* @return the role handled by this handler | ||
*/ | ||
CtRole getRole(); | ||
|
||
/** | ||
* @return a type of the class, which this handler can be applied to | ||
* @return the type of the class, which this handler can be applied to (eg CtMethod) | ||
*/ | ||
Class<?> getTargetType(); | ||
|
||
/** | ||
* @return a Class of value of the attribute of {@link #getTargetType()} defined by {@link #getRole()} | ||
* @return the type of returned value defined by {@link #getRole()} | ||
*/ | ||
Class<?> getValueClass(); | ||
|
||
/** | ||
* @return true if value can contain only one element. It is not a collection or map | ||
* @return the container kind, to know whether an element, a list, a map, etc is returned. | ||
*/ | ||
ContainerKind getContainerKind(); | ||
|
||
// utility methods | ||
/** | ||
* @return a value for this role adapted as a modifiable Collection | ||
*/ | ||
<T, U> Collection<U> asCollection(T element); | ||
|
||
/** | ||
* @return a value for this role adapted as a modifiable Set | ||
*/ | ||
<T, U> Set<U> asSet(T element); | ||
|
||
/** | ||
* @return a value for this role adapted as a modifiable List | ||
*/ | ||
<T, U> List<U> asList(T element); | ||
|
||
/** | ||
* @return a value for this role adapted as a modifiable Map | ||
*/ | ||
<T, U> Map<String, U> asMap(T element); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be we should mention this here too: