if (currentTypeIsProxy && name.contentEquals("stableId")
&& clientMethodElement.getParameters().isEmpty()) {
return null;
}
ExecutableType clientMethod = viewIn(checkedElement, clientMethodElement, state);
List<TypeMirror> lookFor = new ArrayList<TypeMirror>();
// Convert client method signature to domain types
TypeMirror returnType;
try {
returnType = convertToDomainTypes(clientMethod, lookFor, clientMethodElement, state);
} catch (UnmappedTypeException e) {
/*
* Unusual: this would happen if a RequestContext for which we have a
* resolved domain service method uses unresolved proxy types. For
* example, the RequestContext uses a @Service annotation, while one or
* more proxy types use @ProxyForName("") and specify a domain type not
* available to the compiler.
*/
return null;
}
ExecutableElement domainMethod;
if (currentTypeIsProxy && isSetter(clientMethodElement, state)) {
// Look for void setFoo(...)
domainMethod =
new MethodFinder(name, state.types.getNoType(TypeKind.VOID), lookFor, false, state).scan(
domainElement, state);
if (domainMethod == null) {
// Try a builder style
domainMethod =
new MethodFinder(name, domainElement.asType(), lookFor, false, state).scan(
domainElement, state);
}
} else {
/*
* The usual case for getters and all service methods. Only box return
* types when matching context methods since there's a significant
* semantic difference between a null Integer and 0.
*/
domainMethod =
new MethodFinder(name, returnType, lookFor, !currentTypeIsProxy, state).scan(
domainElement, state);
}
if (domainMethod == null) {
// Did not find a service method
StringBuilder sb = new StringBuilder();
sb.append(returnType).append(" ").append(name).append("(");
boolean first = true;
for (TypeMirror param : lookFor) {
if (!first) {
sb.append(", ");
}
sb.append(param);
first = false;
}
sb.append(")");
state.poison(clientMethodElement, Messages.domainMissingMethod(sb));
return null;
}
// Check if the method is public
if (!domainMethod.getModifiers().contains(Modifier.PUBLIC)) {
state.poison(clientMethodElement, Messages.domainMethodNotPublic(
domainMethod.getSimpleName()));
}
/*
* Check the domain method for any requirements for it to be static.
* InstanceRequests assume instance methods on the domain type.
*/
boolean isInstanceRequest =
state.types.isSubtype(clientMethod.getReturnType(), state.instanceRequestType);
if ((isInstanceRequest || requireInstanceDomainMethods)
&& domainMethod.getModifiers().contains(Modifier.STATIC)) {
state.poison(clientMethodElement, Messages.domainMethodWrongModifier(false, domainMethod
.getSimpleName()));