use of com.robotoworks.mechanoid.net.netModel.HttpMethodType in project mechanoid by robotoworks.
the class NetModelJavaValidator method checkBodyIsValid.
@Check
public void checkBodyIsValid(HttpMethod method) {
Iterable<BodyBlock> bodyBlocks = IterableExtensions.filter(method.getBlocks(), BodyBlock.class);
int numBodyBlocks = IterableExtensions.size(bodyBlocks);
HttpMethodType methodType = method.getType();
if (methodType == HttpMethodType.POST || methodType == HttpMethodType.PUT) {
if (numBodyBlocks > 1) {
BodyBlock lastBlock = IterableExtensions.last(bodyBlocks);
error("Body block already defined", method, NetModelPackage.Literals.HTTP_METHOD__BLOCKS, method.getBlocks().indexOf(lastBlock));
}
return;
}
if (numBodyBlocks > 0) {
BodyBlock lastBlock = IterableExtensions.last(bodyBlocks);
error("body not valid for " + methodType.getLiteral() + " methods", method, NetModelPackage.Literals.HTTP_METHOD__BLOCKS, method.getBlocks().indexOf(lastBlock));
}
}
use of com.robotoworks.mechanoid.net.netModel.HttpMethodType in project mechanoid by robotoworks.
the class HttpMethodImpl method setType.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setType(HttpMethodType newType) {
HttpMethodType oldType = type;
type = newType == null ? TYPE_EDEFAULT : newType;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, NetModelPackage.HTTP_METHOD__TYPE, oldType, type));
}
use of com.robotoworks.mechanoid.net.netModel.HttpMethodType in project mechanoid by robotoworks.
the class ClientGenerator method generateServiceMethod.
public CharSequence generateServiceMethod(final HttpMethod method) {
CharSequence _switchResult = null;
HttpMethodType _type = method.getType();
if (_type != null) {
switch(_type) {
case GET:
_switchResult = this.generateServiceGetMethod(method);
break;
case PUT:
_switchResult = this.generateServicePutMethod(method);
break;
case POST:
_switchResult = this.generateServicePostMethod(method);
break;
case DELETE:
_switchResult = this.generateServiceDeleteMethod(method);
break;
case PATCH:
_switchResult = this.generateServicePatchMethod(method);
break;
default:
break;
}
}
return _switchResult;
}
Aggregations