001    /*
002     * Copyright 2010-2013 JetBrains s.r.o.
003     *
004     * Licensed under the Apache License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.apache.org/licenses/LICENSE-2.0
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    
017    package org.jetbrains.jet.lang.types;
018    
019    import org.jetbrains.annotations.NotNull;
020    import org.jetbrains.annotations.Nullable;
021    import org.jetbrains.jet.lang.descriptors.ClassifierDescriptor;
022    import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor;
023    import org.jetbrains.jet.lang.descriptors.annotations.AnnotatedImpl;
024    import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
025    
026    import java.util.ArrayList;
027    import java.util.Collection;
028    import java.util.Collections;
029    import java.util.List;
030    
031    public class TypeConstructorImpl extends AnnotatedImpl implements TypeConstructor {
032        private final List<TypeParameterDescriptor> parameters;
033        private Collection<JetType> supertypes;
034        private final String debugName;
035        private final boolean sealed;
036    
037        @Nullable
038        private final ClassifierDescriptor classifierDescriptor;
039    
040        public TypeConstructorImpl(
041                @Nullable ClassifierDescriptor classifierDescriptor,
042                @NotNull List<AnnotationDescriptor> annotations,
043                boolean sealed,
044                @NotNull String debugName,
045                @NotNull List<? extends TypeParameterDescriptor> parameters,
046                @NotNull Collection<JetType> supertypes) {
047            super(annotations);
048            this.classifierDescriptor = classifierDescriptor;
049            this.sealed = sealed;
050            this.debugName = debugName;
051            this.parameters = Collections.unmodifiableList(new ArrayList<TypeParameterDescriptor>(parameters));
052            this.supertypes = Collections.unmodifiableCollection(supertypes);
053        }
054    
055        @Override
056        @NotNull
057        public List<TypeParameterDescriptor> getParameters() {
058            return parameters;
059        }
060    
061        @Override
062        @NotNull
063        public Collection<JetType> getSupertypes() {
064            return supertypes;
065        }
066    
067        @Override
068        public String toString() {
069            return debugName;
070        }
071    
072        @Override
073        public boolean isSealed() {
074            return sealed;
075        }
076    
077        @Override
078        @Nullable
079        public ClassifierDescriptor getDeclarationDescriptor() {
080            return classifierDescriptor;
081        }
082    }