001 /*
002 * Copyright 2010-2015 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.kotlin.types;
018
019 import org.jetbrains.annotations.NotNull;
020 import org.jetbrains.annotations.Nullable;
021 import org.jetbrains.kotlin.descriptors.annotations.Annotations;
022 import org.jetbrains.kotlin.resolve.scopes.JetScope;
023 import org.jetbrains.kotlin.types.checker.JetTypeChecker;
024
025 import java.util.List;
026
027 public abstract class DelegatingType implements JetType {
028 protected abstract JetType getDelegate();
029
030 @NotNull
031 @Override
032 public TypeConstructor getConstructor() {
033 return getDelegate().getConstructor();
034 }
035
036 @NotNull
037 @Override
038 public List<TypeProjection> getArguments() {
039 return getDelegate().getArguments();
040 }
041
042 @NotNull
043 @Override
044 public TypeSubstitution getSubstitution() {
045 return getDelegate().getSubstitution();
046 }
047
048 @Override
049 public boolean isMarkedNullable() {
050 return getDelegate().isMarkedNullable();
051 }
052
053 @NotNull
054 @Override
055 public JetScope getMemberScope() {
056 return getDelegate().getMemberScope();
057 }
058
059 @Override
060 public boolean isError() {
061 return getDelegate().isError();
062 }
063
064 @NotNull
065 @Override
066 public Annotations getAnnotations() {
067 return getDelegate().getAnnotations();
068 }
069
070 @Override
071 @Nullable
072 public <T extends TypeCapability> T getCapability(@NotNull Class<T> capabilityClass) {
073 return getDelegate().getCapability(capabilityClass);
074 }
075
076 @NotNull
077 @Override
078 public TypeCapabilities getCapabilities() {
079 return getDelegate().getCapabilities();
080 }
081
082 @Override
083 public int hashCode() {
084 return getDelegate().hashCode();
085 }
086
087 @Override
088 public boolean equals(Object obj) {
089 if (this == obj) return true;
090 if (!(obj instanceof JetType)) return false;
091
092 JetType type = (JetType) obj;
093 return JetTypeChecker.FLEXIBLE_UNEQUAL_TO_INFLEXIBLE.equalTypes(this, type);
094 }
095
096 @Override
097 public String toString() {
098 return getDelegate().toString();
099 }
100 }