Search in sources :

Example 1 with MemberByNameAndAccessMap

use of org.eclipse.n4js.ts.types.internal.MemberByNameAndAccessMap in project n4js by eclipse.

the class ContainerTypeImpl method getOrCreateOwnedMembersByNameAndAccess.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public Map<NameAndAccess, ? extends TMember> getOrCreateOwnedMembersByNameAndAccess() {
    Map<NameAndAccess, ? extends TMember> _ownedMembersByNameAndAccess = this.getOwnedMembersByNameAndAccess();
    boolean _tripleEquals = (_ownedMembersByNameAndAccess == null);
    if (_tripleEquals) {
        Map<NameAndAccess, ? extends TMember> _switchResult = null;
        int _size = this.getOwnedMembers().size();
        switch(_size) {
            case 0:
                _switchResult = Collections.<NameAndAccess, TMember>emptyMap();
                break;
            case 1:
                Map<NameAndAccess, ? extends TMember> _xblockexpression = null;
                {
                    final MT singleMember = this.getOwnedMembers().get(0);
                    final NameAndAccess[] nameAndAccess = NameAndAccess.of(singleMember);
                    Map<NameAndAccess, ? extends TMember> _xifexpression = null;
                    int _length = nameAndAccess.length;
                    boolean _greaterThan = (_length > 1);
                    if (_greaterThan) {
                        Map<NameAndAccess, TMember> _xblockexpression_1 = null;
                        {
                            final HashMap<NameAndAccess, TMember> map = new HashMap<NameAndAccess, TMember>();
                            map.put(nameAndAccess[0], singleMember);
                            map.put(nameAndAccess[1], singleMember);
                            _xblockexpression_1 = Collections.<NameAndAccess, TMember>unmodifiableMap(map);
                        }
                        _xifexpression = _xblockexpression_1;
                    } else {
                        _xifexpression = Collections.<NameAndAccess, MT>singletonMap(nameAndAccess[0], singleMember);
                    }
                    _xblockexpression = _xifexpression;
                }
                _switchResult = _xblockexpression;
                break;
            default:
                EList<MT> _ownedMembers = this.getOwnedMembers();
                MemberByNameAndAccessMap _memberByNameAndAccessMap = new MemberByNameAndAccessMap(_ownedMembers);
                _switchResult = Collections.<NameAndAccess, TMember>unmodifiableMap(_memberByNameAndAccessMap);
                break;
        }
        final Map<NameAndAccess, ? extends TMember> newRegistry = _switchResult;
        final Procedure0 _function = new Procedure0() {

            public void apply() {
                ContainerTypeImpl.this.setOwnedMembersByNameAndAccess(newRegistry);
            }
        };
        EcoreUtilN4.doWithDeliver(false, _function, this);
    }
    return this.getOwnedMembersByNameAndAccess();
}
Also used : MemberByNameAndAccessMap(org.eclipse.n4js.ts.types.internal.MemberByNameAndAccessMap) NameAndAccess(org.eclipse.n4js.ts.types.NameAndAccess) Procedure0(org.eclipse.xtext.xbase.lib.Procedures.Procedure0) HashMap(java.util.HashMap) TMember(org.eclipse.n4js.ts.types.TMember) HashMap(java.util.HashMap) Map(java.util.Map) MemberByNameAndAccessMap(org.eclipse.n4js.ts.types.internal.MemberByNameAndAccessMap)

Aggregations

HashMap (java.util.HashMap)1 Map (java.util.Map)1 NameAndAccess (org.eclipse.n4js.ts.types.NameAndAccess)1 TMember (org.eclipse.n4js.ts.types.TMember)1 MemberByNameAndAccessMap (org.eclipse.n4js.ts.types.internal.MemberByNameAndAccessMap)1 Procedure0 (org.eclipse.xtext.xbase.lib.Procedures.Procedure0)1