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

[#noissue] Cleanup DataType mapper

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