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.ref;
018
019 import org.jetbrains.annotations.NotNull;
020 import org.jetbrains.jet.lang.resolve.name.FqName;
021
022 import java.util.Collections;
023 import java.util.List;
024
025 public class JetTypeName {
026 // generic types one day
027 private final FqName className;
028 private final List<JetTypeName> arguments;
029
030 public JetTypeName(@NotNull FqName className, @NotNull List<JetTypeName> arguments) {
031 this.className = className;
032 this.arguments = arguments;
033 }
034
035 @NotNull
036 public FqName getClassName() {
037 return className;
038 }
039
040 @NotNull
041 public List<JetTypeName> getArguments() {
042 return arguments;
043 }
044
045 @NotNull
046 public static JetTypeName fromJavaClass(@NotNull Class<?> clazz) {
047 if (clazz.getTypeParameters().length != 0) {
048 throw new IllegalArgumentException("cannot create type reference: actual type parameters unknown: " + clazz);
049 }
050 FqName fqName = new FqName(clazz.getName());
051 return withoutParameters(fqName);
052 }
053
054 @NotNull
055 public static JetTypeName withoutParameters(@NotNull FqName fqName) {
056 return new JetTypeName(fqName, Collections.<JetTypeName>emptyList());
057 }
058
059 @NotNull
060 public static JetTypeName parse(@NotNull String value) {
061 return JetTypeNameParser.parse(value);
062 }
063 }