Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (C) 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
package com.facebook.swift.codec.metadata;
import com.facebook.swift.codec.ThriftProtocolType;
import com.google.common.base.Preconditions;
import com.google.common.reflect.TypeParameter;
import com.google.common.reflect.TypeToken;
import javax.annotation.concurrent.Immutable;
import java.lang.reflect.Type;
import java.nio.ByteBuffer;
import java.util.List;
import java.util.Map;
import java.util.Set;
import static com.facebook.swift.codec.ThriftProtocolType.ENUM;
import static com.facebook.swift.codec.ThriftProtocolType.STRUCT;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
/**
* ThriftType contains all metadata necessary for converting the java type to and from Thrift.
*/
@Immutable
public class ThriftType
{
public static final ThriftType BOOL = new ThriftType(ThriftProtocolType.BOOL, boolean.class);
public static final ThriftType BYTE = new ThriftType(ThriftProtocolType.BYTE, byte.class);
public static final ThriftType DOUBLE = new ThriftType(ThriftProtocolType.DOUBLE, double.class);
public static final ThriftType I16 = new ThriftType(ThriftProtocolType.I16, short.class);
public static final ThriftType I32 = new ThriftType(ThriftProtocolType.I32, int.class);
public static final ThriftType I64 = new ThriftType(ThriftProtocolType.I64, long.class);
public static final ThriftType STRING = new ThriftType(ThriftProtocolType.STRING, String.class);
public static final ThriftType BINARY = new ThriftType(ThriftProtocolType.BINARY, ByteBuffer.class);
public static final ThriftType VOID = new ThriftType(ThriftProtocolType.STRUCT, void.class);
public static final ThriftTypeReference BOOL_REF = new DefaultThriftTypeReference(BOOL);
public static final ThriftTypeReference BYTE_REF = new DefaultThriftTypeReference(BYTE);
public static final ThriftTypeReference DOUBLE_REF = new DefaultThriftTypeReference(DOUBLE);
public static final ThriftTypeReference I16_REF = new DefaultThriftTypeReference(I16);
public static final ThriftTypeReference I32_REF = new DefaultThriftTypeReference(I32);
public static final ThriftTypeReference I64_REF = new DefaultThriftTypeReference(I64);
public static final ThriftTypeReference STRING_REF = new DefaultThriftTypeReference(STRING);
public static final ThriftTypeReference BINARY_REF = new DefaultThriftTypeReference(BINARY);
public static final ThriftTypeReference VOID_REF = new DefaultThriftTypeReference(VOID);
public static ThriftType struct(ThriftStructMetadata structMetadata)
{
return new ThriftType(structMetadata);
}
public static ThriftType map(ThriftType keyType, ThriftType valueType)
{
checkNotNull(keyType, "keyType is null");
checkNotNull(valueType, "valueType is null");
return map(new DefaultThriftTypeReference(keyType), new DefaultThriftTypeReference(valueType));
}
public static ThriftType map(ThriftTypeReference keyTypeReference,
ThriftTypeReference valueTypeReference)
{
checkNotNull(keyTypeReference, "keyTypeReference is null");
checkNotNull(valueTypeReference, "valueTypeReference is null");
@SuppressWarnings("serial")
Type javaType = new TypeToken