提交 78b2239b 编写于 作者: W Woonduk Kang

[#noissue] Cleanup DataType mapper

上级 5354905c
......@@ -22,6 +22,7 @@ import com.navercorp.pinpoint.common.buffer.Buffer;
import com.navercorp.pinpoint.common.buffer.FixedBuffer;
import com.navercorp.pinpoint.common.profiler.encoding.BitFieldUtils;
import com.navercorp.pinpoint.common.util.BytesUtils;
import com.navercorp.pinpoint.common.util.DataType;
import com.navercorp.pinpoint.common.util.IntBooleanIntBooleanValue;
import com.navercorp.pinpoint.common.util.IntStringStringValue;
import com.navercorp.pinpoint.common.util.IntStringValue;
......@@ -132,16 +133,19 @@ public class AnnotationTranscoder {
return CODE_BOOLEAN_FALSE;
} else if (o instanceof byte[]) {
return CODE_BYTEARRAY;
} else if (o instanceof IntStringValue) {
return CODE_INT_STRING;
} else if (o instanceof IntStringStringValue) {
return CODE_INT_STRING_STRING;
} else if (o instanceof StringStringValue) {
return CODE_STRING_STRING;
} else if (o instanceof LongIntIntByteByteStringValue) {
return CODE_LONG_INT_INT_BYTE_BYTE_STRING;
} else if (o instanceof IntBooleanIntBooleanValue) {
return CODE_INT_BOOLEAN_INT_BOOLEAN;
}
if (o instanceof DataType) {
if (o instanceof IntStringValue) {
return CODE_INT_STRING;
} else if (o instanceof IntStringStringValue) {
return CODE_INT_STRING_STRING;
} else if (o instanceof StringStringValue) {
return CODE_STRING_STRING;
} else if (o instanceof LongIntIntByteByteStringValue) {
return CODE_LONG_INT_INT_BYTE_BYTE_STRING;
} else if (o instanceof IntBooleanIntBooleanValue) {
return CODE_INT_BOOLEAN_INT_BOOLEAN;
}
}
return CODE_TOSTRING;
}
......
package com.navercorp.pinpoint.common.util;
/**
* maker interface
*/
public interface DataType {
}
......@@ -19,7 +19,7 @@ package com.navercorp.pinpoint.common.util;
/**
* @author jaehong.kim
*/
public class IntBooleanIntBooleanValue {
public class IntBooleanIntBooleanValue implements DataType {
private final int intValue1;
private final boolean booleanValue1;
private final int intValue2;
......
......@@ -19,7 +19,7 @@ package com.navercorp.pinpoint.common.util;
/**
* @author emeroad
*/
public class IntStringStringValue {
public class IntStringStringValue implements DataType {
private final int intValue;
private final String stringValue1;
private final String stringValue2;
......
......@@ -19,7 +19,7 @@ package com.navercorp.pinpoint.common.util;
/**
* @author emeroad
*/
public class IntStringValue {
public class IntStringValue implements DataType {
private final int intValue;
private final String stringValue;
......
......@@ -19,7 +19,7 @@ package com.navercorp.pinpoint.common.util;
/**
* @author jaehong.kim
*/
public class LongIntIntByteByteStringValue {
public class LongIntIntByteByteStringValue implements DataType {
private final long longValue;
private final int intValue1;
private final int intValue2;
......
......@@ -19,7 +19,7 @@ package com.navercorp.pinpoint.common.util;
/**
* @author Roy Kim
*/
public class StringStringValue {
public class StringStringValue implements DataType {
private final String stringValue1;
private final String stringValue2;
......
......@@ -18,6 +18,7 @@ package com.navercorp.pinpoint.profiler.context.grpc;
import com.google.protobuf.ByteString;
import com.google.protobuf.StringValue;
import com.navercorp.pinpoint.common.util.DataType;
import com.navercorp.pinpoint.common.util.IntBooleanIntBooleanValue;
import com.navercorp.pinpoint.common.util.IntStringStringValue;
import com.navercorp.pinpoint.common.util.IntStringValue;
......@@ -89,45 +90,44 @@ public class GrpcAnnotationValueMapper {
return builder.build();
}
if (value instanceof IntStringValue) {
final IntStringValue v = (IntStringValue) value;
PIntStringValue pIntStringValue = newIntStringValue(v);
if (value instanceof DataType) {
if (value instanceof IntStringValue) {
final IntStringValue v = (IntStringValue) value;
PIntStringValue pIntStringValue = newIntStringValue(v);
PAnnotationValue.Builder builder = getAnnotationBuilder();
builder.setIntStringValue(pIntStringValue);
PAnnotationValue.Builder builder = getAnnotationBuilder();
builder.setIntStringValue(pIntStringValue);
return builder.build();
}
if (value instanceof StringStringValue) {
final StringStringValue v = (StringStringValue) value;
PStringStringValue pStringStringValue = newStringStringValue(v);
return builder.build();
} else if (value instanceof StringStringValue) {
final StringStringValue v = (StringStringValue) value;
PStringStringValue pStringStringValue = newStringStringValue(v);
PAnnotationValue.Builder builder = getAnnotationBuilder();
builder.setStringStringValue(pStringStringValue);
return builder.build();
}
if (value instanceof IntStringStringValue) {
final IntStringStringValue v = (IntStringStringValue) value;
final PIntStringStringValue pIntStringStringValue = newIntStringStringValue(v);
PAnnotationValue.Builder builder = getAnnotationBuilder();
builder.setIntStringStringValue(pIntStringStringValue);
return builder.build();
}
if (value instanceof LongIntIntByteByteStringValue) {
final LongIntIntByteByteStringValue v = (LongIntIntByteByteStringValue) value;
final PLongIntIntByteByteStringValue pValue = newLongIntIntByteByteStringValue(v);
PAnnotationValue.Builder builder = getAnnotationBuilder();
builder.setStringStringValue(pStringStringValue);
return builder.build();
} else if (value instanceof IntStringStringValue) {
final IntStringStringValue v = (IntStringStringValue) value;
final PIntStringStringValue pIntStringStringValue = newIntStringStringValue(v);
PAnnotationValue.Builder builder = getAnnotationBuilder();
builder.setIntStringStringValue(pIntStringStringValue);
return builder.build();
} else if (value instanceof LongIntIntByteByteStringValue) {
final LongIntIntByteByteStringValue v = (LongIntIntByteByteStringValue) value;
final PLongIntIntByteByteStringValue pValue = newLongIntIntByteByteStringValue(v);
PAnnotationValue.Builder builder = getAnnotationBuilder();
builder.setLongIntIntByteByteStringValue(pValue);
return builder.build();
}
if (value instanceof IntBooleanIntBooleanValue) {
final IntBooleanIntBooleanValue v = (IntBooleanIntBooleanValue) value;
final PIntBooleanIntBooleanValue pValue = newIntBooleanIntBooleanValue(v);
PAnnotationValue.Builder builder = getAnnotationBuilder();
builder.setIntBooleanIntBooleanValue(pValue);
return builder.build();
PAnnotationValue.Builder builder = getAnnotationBuilder();
builder.setLongIntIntByteByteStringValue(pValue);
return builder.build();
} else if (value instanceof IntBooleanIntBooleanValue) {
final IntBooleanIntBooleanValue v = (IntBooleanIntBooleanValue) value;
final PIntBooleanIntBooleanValue pValue = newIntBooleanIntBooleanValue(v);
PAnnotationValue.Builder builder = getAnnotationBuilder();
builder.setIntBooleanIntBooleanValue(pValue);
return builder.build();
}
}
if (value instanceof TBase) {
throw new IllegalArgumentException("TBase not supported. Class:" + value.getClass());
}
......
......@@ -16,6 +16,7 @@
package com.navercorp.pinpoint.profiler.context.thrift;
import com.navercorp.pinpoint.common.util.DataType;
import com.navercorp.pinpoint.common.util.IntBooleanIntBooleanValue;
import com.navercorp.pinpoint.common.util.IntStringStringValue;
import com.navercorp.pinpoint.common.util.IntStringValue;
......@@ -63,56 +64,54 @@ public class AnnotationValueThriftMapper {
if (value instanceof byte[]) {
return TAnnotationValue.binaryValue((byte[]) value);
}
if (value instanceof IntStringValue) {
final IntStringValue v = (IntStringValue) value;
final TIntStringValue tIntStringValue = new TIntStringValue(v.getIntValue());
if (v.getStringValue() != null) {
tIntStringValue.setStringValue(v.getStringValue());
}
return TAnnotationValue.intStringValue(tIntStringValue);
}
if (value instanceof StringStringValue) {
final StringStringValue v = (StringStringValue) value;
final TStringStringValue tStringStringValue = new TStringStringValue(v.getStringValue1());
if (v.getStringValue2() != null) {
tStringStringValue.setStringValue2(v.getStringValue2());
if (value instanceof DataType) {
if (value instanceof IntStringValue) {
final IntStringValue v = (IntStringValue) value;
final TIntStringValue tIntStringValue = new TIntStringValue(v.getIntValue());
if (v.getStringValue() != null) {
tIntStringValue.setStringValue(v.getStringValue());
}
return TAnnotationValue.intStringValue(tIntStringValue);
} else if (value instanceof StringStringValue) {
final StringStringValue v = (StringStringValue) value;
final TStringStringValue tStringStringValue = new TStringStringValue(v.getStringValue1());
if (v.getStringValue2() != null) {
tStringStringValue.setStringValue2(v.getStringValue2());
}
return TAnnotationValue.stringStringValue(tStringStringValue);
} else if (value instanceof IntStringStringValue) {
final IntStringStringValue v = (IntStringStringValue) value;
final TIntStringStringValue tIntStringStringValue = new TIntStringStringValue(v.getIntValue());
if (v.getStringValue1() != null) {
tIntStringStringValue.setStringValue1(v.getStringValue1());
}
if (v.getStringValue2() != null) {
tIntStringStringValue.setStringValue2(v.getStringValue2());
}
return TAnnotationValue.intStringStringValue(tIntStringStringValue);
} else if (value instanceof LongIntIntByteByteStringValue) {
final LongIntIntByteByteStringValue v = (LongIntIntByteByteStringValue) value;
final TLongIntIntByteByteStringValue tvalue = new TLongIntIntByteByteStringValue(v.getLongValue(), v.getIntValue1());
if (v.getIntValue2() != -1) {
tvalue.setIntValue2(v.getIntValue2());
}
if (v.getByteValue1() != -1) {
tvalue.setByteValue1(v.getByteValue1());
}
if (v.getByteValue2() != -1) {
tvalue.setByteValue2(v.getByteValue2());
}
if (v.getStringValue() != null) {
tvalue.setStringValue(v.getStringValue());
}
return TAnnotationValue.longIntIntByteByteStringValue(tvalue);
} else if (value instanceof IntBooleanIntBooleanValue) {
final IntBooleanIntBooleanValue v = (IntBooleanIntBooleanValue) value;
final TIntBooleanIntBooleanValue tvalue = new TIntBooleanIntBooleanValue(v.getIntValue1(), v.isBooleanValue1(), v.getIntValue2(), v.isBooleanValue2());
return TAnnotationValue.intBooleanIntBooleanValue(tvalue);
}
return TAnnotationValue.stringStringValue(tStringStringValue);
}
if (value instanceof IntStringStringValue) {
final IntStringStringValue v = (IntStringStringValue) value;
final TIntStringStringValue tIntStringStringValue = new TIntStringStringValue(v.getIntValue());
if (v.getStringValue1() != null) {
tIntStringStringValue.setStringValue1(v.getStringValue1());
}
if (v.getStringValue2() != null) {
tIntStringStringValue.setStringValue2(v.getStringValue2());
}
return TAnnotationValue.intStringStringValue(tIntStringStringValue);
}
if (value instanceof LongIntIntByteByteStringValue) {
final LongIntIntByteByteStringValue v = (LongIntIntByteByteStringValue) value;
final TLongIntIntByteByteStringValue tvalue = new TLongIntIntByteByteStringValue(v.getLongValue(), v.getIntValue1());
if (v.getIntValue2() != -1) {
tvalue.setIntValue2(v.getIntValue2());
}
if (v.getByteValue1() != -1) {
tvalue.setByteValue1(v.getByteValue1());
}
if (v.getByteValue2() != -1) {
tvalue.setByteValue2(v.getByteValue2());
}
if (v.getStringValue() != null) {
tvalue.setStringValue(v.getStringValue());
}
return TAnnotationValue.longIntIntByteByteStringValue(tvalue);
}
if (value instanceof IntBooleanIntBooleanValue) {
final IntBooleanIntBooleanValue v = (IntBooleanIntBooleanValue) value;
final TIntBooleanIntBooleanValue tvalue = new TIntBooleanIntBooleanValue(v.getIntValue1(), v.isBooleanValue1(), v.getIntValue2(), v.isBooleanValue2());
return TAnnotationValue.intBooleanIntBooleanValue(tvalue);
}
if (value instanceof TBase) {
throw new IllegalArgumentException("TBase not supported. Class:" + value.getClass());
}
......
......@@ -17,6 +17,7 @@
package com.navercorp.pinpoint.profiler.util;
import com.navercorp.pinpoint.common.util.DataType;
import com.navercorp.pinpoint.common.util.IntBooleanIntBooleanValue;
import com.navercorp.pinpoint.common.util.IntStringStringValue;
import com.navercorp.pinpoint.common.util.IntStringValue;
......@@ -59,17 +60,21 @@ public final class AnnotationValueMapper {
return value;
} else if (value instanceof byte[]) {
return value;
} else if (value instanceof IntStringValue) {
return value;
} else if (value instanceof IntStringStringValue) {
return value;
} else if (value instanceof LongIntIntByteByteStringValue) {
return value;
} else if (value instanceof IntBooleanIntBooleanValue) {
return value;
} else if (value instanceof StringStringValue) {
return value;
} else if (value instanceof TBase) {
}
if (value instanceof DataType) {
if (value instanceof IntStringValue) {
return value;
} else if (value instanceof IntStringStringValue) {
return value;
} else if (value instanceof LongIntIntByteByteStringValue) {
return value;
} else if (value instanceof IntBooleanIntBooleanValue) {
return value;
} else if (value instanceof StringStringValue) {
return value;
}
}
if (value instanceof TBase) {
throw new IllegalArgumentException("TBase not supported. Class:" + value.getClass());
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册