Search in sources :

Example 1 with HttpMethodType

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));
    }
}
Also used : HttpMethodType(com.robotoworks.mechanoid.net.netModel.HttpMethodType) BodyBlock(com.robotoworks.mechanoid.net.netModel.BodyBlock) Check(org.eclipse.xtext.validation.Check)

Example 2 with HttpMethodType

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));
}
Also used : HttpMethodType(com.robotoworks.mechanoid.net.netModel.HttpMethodType) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 3 with HttpMethodType

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;
}
Also used : HttpMethodType(com.robotoworks.mechanoid.net.netModel.HttpMethodType)

Aggregations

HttpMethodType (com.robotoworks.mechanoid.net.netModel.HttpMethodType)3 BodyBlock (com.robotoworks.mechanoid.net.netModel.BodyBlock)1 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)1 Check (org.eclipse.xtext.validation.Check)1