PageRenderTime 27ms CodeModel.GetById 11ms app.highlight 11ms RepoModel.GetById 1ms app.codeStats 0ms

/tags/release-0.0.0-rc0/hive/external/serde/src/java/org/apache/hadoop/hive/serde2/typeinfo/ListTypeInfo.java

#
Java | 89 lines | 42 code | 14 blank | 33 comment | 3 complexity | 71fff9774147662511f1e616b6fbb18d MD5 | raw file
 1/**
 2 * Licensed to the Apache Software Foundation (ASF) under one
 3 * or more contributor license agreements.  See the NOTICE file
 4 * distributed with this work for additional information
 5 * regarding copyright ownership.  The ASF licenses this file
 6 * to you under the Apache License, Version 2.0 (the
 7 * "License"); you may not use this file except in compliance
 8 * with the License.  You may obtain a copy of the License at
 9 *
10 *     http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19package org.apache.hadoop.hive.serde2.typeinfo;
20
21import java.io.Serializable;
22
23import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector.Category;
24
25/**
26 * A List Type has homogeneous elements. All elements of the List has the same
27 * TypeInfo which is returned by getListElementTypeInfo.
28 * 
29 * Always use the TypeInfoFactory to create new TypeInfo objects, instead of
30 * directly creating an instance of this class.
31 */
32public final class ListTypeInfo extends TypeInfo implements Serializable {
33
34  private static final long serialVersionUID = 1L;
35  private TypeInfo listElementTypeInfo;
36
37  /**
38   * For java serialization use only.
39   */
40  public ListTypeInfo() {
41  }
42
43  @Override
44  public String getTypeName() {
45    return org.apache.hadoop.hive.serde.Constants.LIST_TYPE_NAME + "<"
46        + listElementTypeInfo.getTypeName() + ">";
47  }
48
49  /**
50   * For java serialization use only.
51   */
52  public void setListElementTypeInfo(TypeInfo listElementTypeInfo) {
53    this.listElementTypeInfo = listElementTypeInfo;
54  }
55
56  /**
57   * For TypeInfoFactory use only.
58   */
59  ListTypeInfo(TypeInfo elementTypeInfo) {
60    listElementTypeInfo = elementTypeInfo;
61  }
62
63  @Override
64  public Category getCategory() {
65    return Category.LIST;
66  }
67
68  public TypeInfo getListElementTypeInfo() {
69    return listElementTypeInfo;
70  }
71
72  @Override
73  public boolean equals(Object other) {
74    if (this == other) {
75      return true;
76    }
77    if (!(other instanceof ListTypeInfo)) {
78      return false;
79    }
80    return getListElementTypeInfo().equals(
81        ((ListTypeInfo) other).getListElementTypeInfo());
82  }
83
84  @Override
85  public int hashCode() {
86    return listElementTypeInfo.hashCode();
87  }
88
89}