001/* 002 * Copyright (C) 2012 Facebook, Inc. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); you may 005 * not use this file except in compliance with the License. You may obtain 006 * 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, WITHOUT 012 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 013 * License for the specific language governing permissions and limitations 014 * under the License. 015 */ 016package com.facebook.swift.codec.metadata; 017 018import com.google.common.base.Joiner; 019 020import javax.annotation.concurrent.Immutable; 021 022import java.lang.reflect.Method; 023import java.util.Arrays; 024import java.util.List; 025 026import static com.google.common.base.Preconditions.checkNotNull; 027 028@Immutable 029public class ThriftMethodInjection 030{ 031 private final Method method; 032 private final List<ThriftParameterInjection> parameters; 033 034 public ThriftMethodInjection(Method method, ThriftParameterInjection ... parameters) 035 { 036 this(method, Arrays.asList(parameters)); 037 } 038 039 public ThriftMethodInjection(Method method, List<ThriftParameterInjection> parameters) 040 { 041 checkNotNull(method, "method is null"); 042 checkNotNull(parameters, "parameters is null"); 043 044 this.method = method; 045 this.parameters = parameters; 046 } 047 048 public Method getMethod() 049 { 050 return method; 051 } 052 053 public List<ThriftParameterInjection> getParameters() 054 { 055 return parameters; 056 } 057 058 @Override 059 public String toString() 060 { 061 final StringBuilder sb = new StringBuilder(); 062 sb.append(method.getName()); 063 sb.append('('); 064 Joiner.on(", ").appendTo(sb, parameters); 065 sb.append(')'); 066 return sb.toString(); 067 } 068}