package com.nhn.pinpoint.collector.mapper.thrift;

import org.springframework.stereotype.Component;

import com.nhn.pinpoint.common.ServiceType;
import com.nhn.pinpoint.common.bo.AgentInfoBo;
import com.nhn.pinpoint.thrift.dto.TAgentInfo;

/**
 * @author hyungil.jeong
 */
@Component
public class AgentInfoBoMapper implements ThriftBoMapper<AgentInfoBo, TAgentInfo> {

    @Override
    public AgentInfoBo map(TAgentInfo thriftObject) {
        final String hostName = thriftObject.getHostname();
        final String ip = thriftObject.getIp();
        final String ports = thriftObject.getPorts();
        final String agentId = thriftObject.getAgentId();
        final String applicationName = thriftObject.getApplicationName();
        final ServiceType serviceType = ServiceType.findServiceType(thriftObject.getServiceType());
        final int pid = thriftObject.getPid();
        final String version = thriftObject.getVersion();
        final long startTime = thriftObject.getStartTimestamp();
        final long endTimeStamp = thriftObject.getEndTimestamp();
        final int endStatus = thriftObject.getEndStatus();
        return new AgentInfoBo.Builder().hostName(hostName).ip(ip).ports(ports).agentId(agentId).applicationName(applicationName).serviceType(serviceType)
                .pid(pid).version(version).startTime(startTime).endTimeStamp(endTimeStamp).endStatus(endStatus).build();
    }

}

@@ -50,60 +50,8 @@
 %0D%0A%0D%0A
-import org.springframework.stereotype.Component;%0D%0A%0D%0A
 impo
@@ -186,16 +186,66 @@
 ntInfo;%0D
+%0Aimport org.springframework.stereotype.Component;%0D
 %0A%0D%0A/**%0D%0A
@@ -1144,24 +1144,26 @@
 tus();%0D%0A
+%0D%0A
         
 return n
@@ -1158,14 +1158,37 @@
     
-return
+AgentInfoBo.Builder builder =
  new
@@ -1209,16 +1209,34 @@
 uilder()
+;%0D%0A        builder
 .hostNam
@@ -1250,45 +1250,117 @@
 ame)
-.ip(ip).ports(ports).agentId(agentId)
+;%0D%0A        builder.ip(ip);%0D%0A        builder.ports(ports);%0D%0A        builder.agentId(agentId);%0D%0A        builder
 .app
@@ -1388,16 +1388,34 @@
 ionName)
+;%0D%0A        builder
 .service
@@ -1431,16 +1431,17 @@
 iceType)
+;
 %0D%0A      
@@ -1446,42 +1446,77 @@
     
-        .pid(pid).version(version)
+builder.pid(pid);%0D%0A        builder.version(version);%0D%0A        builder
 .sta
@@ -1532,16 +1532,34 @@
 artTime)
+;%0D%0A        builder
 .endTime
@@ -1577,16 +1577,34 @@
 meStamp)
+;%0D%0A        builder
 .endStat
@@ -1616,16 +1616,43 @@
 dStatus)
+;%0D%0A%0D%0A        return builder
 .build()

remove chain api