001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.apache.hadoop.hbase.types; 019 020import org.apache.hadoop.hbase.util.Order; 021import org.apache.hadoop.hbase.util.PositionedByteRange; 022import org.apache.yetus.audience.InterfaceAudience; 023 024/** 025 * The {@code Union} family of {@link DataType}s encode one of a fixed collection of Objects. They 026 * provide convenience methods which handle type casting on your behalf. 027 */ 028@SuppressWarnings("unchecked") 029@InterfaceAudience.Public 030public abstract class Union4<A, B, C, D> extends Union3<A, B, C> { 031 032 protected final DataType<D> typeD; 033 034 /** 035 * Create an instance of {@code Union4} over the set of specified types. 036 */ 037 public Union4(DataType<A> typeA, DataType<B> typeB, DataType<C> typeC, DataType<D> typeD) { 038 super(typeA, typeB, typeC); 039 this.typeD = typeD; 040 } 041 042 @Override 043 public boolean isOrderPreserving() { 044 return super.isOrderPreserving() && typeD.isOrderPreserving(); 045 } 046 047 @Override 048 public Order getOrder() { 049 return null; 050 } 051 052 @Override 053 public boolean isNullable() { 054 return super.isNullable() && typeD.isNullable(); 055 } 056 057 @Override 058 public boolean isSkippable() { 059 return super.isSkippable() && typeD.isSkippable(); 060 } 061 062 /** 063 * Read an instance of the fourth type parameter from buffer {@code src}. 064 */ 065 public D decodeD(PositionedByteRange src) { 066 return (D) decode(src); 067 } 068}