1 /* 2 * Copyright (c) 2022 Uber Technologies, Inc. 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a copy 5 * of this software and associated documentation files (the "Software"), to deal 6 * in the Software without restriction, including without limitation the rights 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 * copies of the Software, and to permit persons to whom the Software is 9 * furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice shall be included in 12 * all copies or substantial portions of the Software. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 * THE SOFTWARE. 21 */ 22 23 package com.uber.nullaway.fixserialization.adapters; 24 25 import com.sun.tools.javac.code.Symbol; 26 import com.uber.nullaway.fixserialization.out.ErrorInfo; 27 28 /** 29 * Adapter for serialization service to provide its output according to the requested serialization 30 * version. Outputs are currently produced in TSV format and columns in these files may change 31 * future releases. Subclasses of this interface are used to maintain backward compatibility and 32 * produce the exact output of previous NullAway versions. 33 */ 34 public interface SerializationAdapter { 35 36 /** 37 * Latest version number. If version is not defined by the user, NullAway will use the 38 * corresponding adapter to this version in its serialization. 39 */ 40 int LATEST_VERSION = 3; 41 42 /** 43 * Returns header of "errors.tsv" which contains all serialized {@link ErrorInfo} reported by 44 * NullAway. 45 * 46 * @return Header of "errors.tsv". 47 */ getErrorsOutputFileHeader()48 String getErrorsOutputFileHeader(); 49 50 /** 51 * Serializes contents of the given {@link ErrorInfo} according to the defined header into a 52 * string with each field separated by a tab. 53 * 54 * @param errorInfo Given errorInfo to serialize. 55 * @return String representation of the given {@link ErrorInfo}. The returned string should be 56 * ready to get appended to a tsv file as a row. 57 */ serializeError(ErrorInfo errorInfo)58 String serializeError(ErrorInfo errorInfo); 59 60 /** 61 * Returns the associated version number with this adapter. 62 * 63 * @return Supporting serialization version number. 64 */ getSerializationVersion()65 int getSerializationVersion(); 66 67 /** 68 * Serializes the signature of the given {@link Symbol.MethodSymbol} to a string. 69 * 70 * @param methodSymbol The method symbol to serialize. 71 * @return The serialized method symbol. 72 */ serializeMethodSignature(Symbol.MethodSymbol methodSymbol)73 String serializeMethodSignature(Symbol.MethodSymbol methodSymbol); 74 } 75