Search in sources :

Example 1 with Type

use of org.applause.lang.applauseDsl.Type in project applause by applause.

the class EntitiesValidationTestHelper method isValidEntityWithAttributes.

public void isValidEntityWithAttributes(final CharSequence sequence) {
    try {
        final Model model = this._parseHelper.parse(sequence);
        EList<NamedElement> _elements = model.getElements();
        Iterable<Entity> _filter = Iterables.<Entity>filter(_elements, Entity.class);
        final Entity entity = IterableExtensions.<Entity>head(_filter);
        final EList<Attribute> attributes = entity.getAttributes();
        int _size = attributes.size();
        Matcher<Integer> _is = CoreMatchers.<Integer>is(Integer.valueOf(2));
        Assert.<Integer>assertThat(Integer.valueOf(_size), _is);
        EList<NamedElement> _elements_1 = model.getElements();
        final Function1<NamedElement, Boolean> _function = new Function1<NamedElement, Boolean>() {

            public Boolean apply(final NamedElement it) {
                String _name = it.getName();
                boolean _equals = Objects.equal(_name, "Date");
                return Boolean.valueOf(_equals);
            }
        };
        final NamedElement dateType = IterableExtensions.<NamedElement>findFirst(_elements_1, _function);
        EList<NamedElement> _elements_2 = model.getElements();
        final Function1<NamedElement, Boolean> _function_1 = new Function1<NamedElement, Boolean>() {

            public Boolean apply(final NamedElement it) {
                String _name = it.getName();
                boolean _equals = Objects.equal(_name, "String");
                return Boolean.valueOf(_equals);
            }
        };
        final NamedElement stringType = IterableExtensions.<NamedElement>findFirst(_elements_2, _function_1);
        final Attribute firstAttribute = IterableExtensions.<Attribute>head(attributes);
        String _name = firstAttribute.getName();
        Matcher<String> _is_1 = CoreMatchers.<String>is("name");
        Assert.<String>assertThat(_name, _is_1);
        Type _type = firstAttribute.getType();
        Matcher<NamedElement> _is_2 = CoreMatchers.<NamedElement>is(stringType);
        Assert.<Type>assertThat(_type, _is_2);
        final Attribute secondAttribute = IterableExtensions.<Attribute>last(attributes);
        String _name_1 = secondAttribute.getName();
        Matcher<String> _is_3 = CoreMatchers.<String>is("birthdate");
        Assert.<String>assertThat(_name_1, _is_3);
        Type _type_1 = secondAttribute.getType();
        Matcher<NamedElement> _is_4 = CoreMatchers.<NamedElement>is(dateType);
        Assert.<Type>assertThat(_type_1, _is_4);
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : Entity(org.applause.lang.applauseDsl.Entity) Attribute(org.applause.lang.applauseDsl.Attribute) Function1(org.eclipse.xtext.xbase.lib.Functions.Function1) Type(org.applause.lang.applauseDsl.Type) Model(org.applause.lang.applauseDsl.Model) NamedElement(org.applause.lang.applauseDsl.NamedElement)

Example 2 with Type

use of org.applause.lang.applauseDsl.Type in project applause by applause.

the class TypeExtensions method typeName.

public String typeName(final Attribute it) {
    String _switchResult = null;
    Type _type = it.getType();
    String _name = _type.getName();
    final String _switchValue = _name;
    boolean _matched = false;
    if (!_matched) {
        if (Objects.equal(_switchValue, "String")) {
            _matched = true;
            _switchResult = "NSString";
        }
    }
    if (!_matched) {
        if (Objects.equal(_switchValue, "Bool")) {
            _matched = true;
            _switchResult = "BOOL";
        }
    }
    if (!_matched) {
        if (Objects.equal(_switchValue, "Date")) {
            _matched = true;
            _switchResult = "NSDate";
        }
    }
    if (!_matched) {
        if (Objects.equal(_switchValue, "Integer")) {
            _matched = true;
            _switchResult = "NSNumber";
        }
    }
    if (!_matched) {
        Type _type_1 = it.getType();
        String _name_1 = _type_1.getName();
        _switchResult = _name_1;
    }
    return _switchResult;
}
Also used : Type(org.applause.lang.applauseDsl.Type)

Example 3 with Type

use of org.applause.lang.applauseDsl.Type in project applause by applause.

the class TypeExtensions method isScalar.

public boolean isScalar(final Attribute it) {
    boolean _switchResult = false;
    Type _type = it.getType();
    String _name = _type.getName();
    final String _switchValue = _name;
    boolean _matched = false;
    if (!_matched) {
        if (Objects.equal(_switchValue, "Bool")) {
            _matched = true;
            _switchResult = true;
        }
    }
    if (!_matched) {
        _switchResult = false;
    }
    return _switchResult;
}
Also used : Type(org.applause.lang.applauseDsl.Type)

Example 4 with Type

use of org.applause.lang.applauseDsl.Type in project applause by applause.

the class AttributeImpl method setType.

/**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
public void setType(Type newType) {
    Type oldType = type;
    type = newType;
    if (eNotificationRequired())
        eNotify(new ENotificationImpl(this, Notification.SET, ApplauseDslPackage.ATTRIBUTE__TYPE, oldType, type));
}
Also used : Type(org.applause.lang.applauseDsl.Type) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 5 with Type

use of org.applause.lang.applauseDsl.Type in project applause by applause.

the class EntityDataAccessExtensions method parameterList.

public String parameterList(final DataSourceAccessMethod it) {
    EList<Parameter> _declaredParameters = it.getDeclaredParameters();
    final Function1<Parameter, String> _function = new Function1<Parameter, String>() {

        public String apply(final Parameter param) {
            Type _type = param.getType();
            String _typeName = EntityDataAccessExtensions.this._typeExtensions.typeName(_type);
            String _plus = (_typeName + " *");
            Type _type_1 = param.getType();
            String _parameterName = EntityDataAccessExtensions.this.parameterName(_type_1);
            String _plus_1 = (_plus + _parameterName);
            return _plus_1;
        }
    };
    List<String> _map = ListExtensions.<Parameter, String>map(_declaredParameters, _function);
    String _join = IterableExtensions.join(_map, ", ");
    return _join;
}
Also used : Type(org.applause.lang.applauseDsl.Type) Function1(org.eclipse.xtext.xbase.lib.Functions.Function1) Parameter(org.applause.lang.applauseDsl.Parameter)

Aggregations

Type (org.applause.lang.applauseDsl.Type)7 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)2 Function1 (org.eclipse.xtext.xbase.lib.Functions.Function1)2 Attribute (org.applause.lang.applauseDsl.Attribute)1 Entity (org.applause.lang.applauseDsl.Entity)1 Model (org.applause.lang.applauseDsl.Model)1 NamedElement (org.applause.lang.applauseDsl.NamedElement)1 Parameter (org.applause.lang.applauseDsl.Parameter)1