com.arextest.web.model.mapper.LogsMapperImpl Maven / Gradle / Ivy
package com.arextest.web.model.mapper;
import com.arextest.web.model.contract.contracts.QueryLogsRequestType;
import com.arextest.web.model.contract.contracts.common.LogsType;
import com.arextest.web.model.dao.mongodb.LogsCollection;
import com.arextest.web.model.dto.LogsDto;
import com.arextest.web.model.params.QueryLogsParam;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Generated;
@Generated(
value = "org.mapstruct.ap.MappingProcessor",
date = "2024-09-25T05:48:00+0000",
comments = "version: 1.5.5.Final, compiler: javac, environment: Java 11.0.24 (Eclipse Adoptium)"
)
public class LogsMapperImpl implements LogsMapper {
@Override
public LogsDto dtoFromDao(LogsCollection dao) {
if ( dao == null ) {
return null;
}
LogsDto logsDto = new LogsDto();
logsDto.setId( dao.getId() );
logsDto.setLevel( dao.getLevel() );
logsDto.setLoggerName( dao.getLoggerName() );
logsDto.setMessage( dao.getMessage() );
logsDto.setThreadId( dao.getThreadId() );
logsDto.setThreadName( dao.getThreadName() );
logsDto.setThreadPriority( dao.getThreadPriority() );
logsDto.setMillis( dao.getMillis() );
Map map = dao.getContextMap();
if ( map != null ) {
logsDto.setContextMap( new LinkedHashMap( map ) );
}
logsDto.setSource( unitToUnitDto( dao.getSource() ) );
logsDto.setThrown( thrownToThrownDto( dao.getThrown() ) );
return logsDto;
}
@Override
public LogsType contractFromDto(LogsDto dto) {
if ( dto == null ) {
return null;
}
LogsType logsType = new LogsType();
logsType.setId( dto.getId() );
logsType.setLevel( dto.getLevel() );
logsType.setLoggerName( dto.getLoggerName() );
logsType.setMessage( dto.getMessage() );
logsType.setThreadId( dto.getThreadId() );
logsType.setThreadName( dto.getThreadName() );
logsType.setThreadPriority( dto.getThreadPriority() );
logsType.setMillis( dto.getMillis() );
Map map = dto.getContextMap();
if ( map != null ) {
logsType.setContextMap( new LinkedHashMap( map ) );
}
logsType.setSource( unitDtoToUnitType( dto.getSource() ) );
logsType.setThrown( thrownDtoToThrownType( dto.getThrown() ) );
return logsType;
}
@Override
public QueryLogsParam fromRequest(QueryLogsRequestType request) {
if ( request == null ) {
return null;
}
QueryLogsParam queryLogsParam = new QueryLogsParam();
queryLogsParam.setPageSize( request.getPageSize() );
queryLogsParam.setPreviousId( request.getPreviousId() );
queryLogsParam.setLevel( request.getLevel() );
queryLogsParam.setStartTime( request.getStartTime() );
queryLogsParam.setEndTime( request.getEndTime() );
Map map = request.getTags();
if ( map != null ) {
queryLogsParam.setTags( new LinkedHashMap( map ) );
}
return queryLogsParam;
}
protected LogsDto.UnitDto unitToUnitDto(LogsCollection.Unit unit) {
if ( unit == null ) {
return null;
}
LogsDto.UnitDto unitDto = new LogsDto.UnitDto();
unitDto.setClassName( unit.getClassName() );
unitDto.setMethodName( unit.getMethodName() );
unitDto.setFileName( unit.getFileName() );
unitDto.setLineNumber( unit.getLineNumber() );
return unitDto;
}
protected List unitListToUnitDtoList(List list) {
if ( list == null ) {
return null;
}
List list1 = new ArrayList( list.size() );
for ( LogsCollection.Unit unit : list ) {
list1.add( unitToUnitDto( unit ) );
}
return list1;
}
protected LogsDto.ThrownDto thrownToThrownDto(LogsCollection.Thrown thrown) {
if ( thrown == null ) {
return null;
}
LogsDto.ThrownDto thrownDto = new LogsDto.ThrownDto();
thrownDto.setType( thrown.getType() );
thrownDto.setMessage( thrown.getMessage() );
thrownDto.setStackTrace( unitListToUnitDtoList( thrown.getStackTrace() ) );
return thrownDto;
}
protected LogsType.UnitType unitDtoToUnitType(LogsDto.UnitDto unitDto) {
if ( unitDto == null ) {
return null;
}
LogsType.UnitType unitType = new LogsType.UnitType();
unitType.setClassName( unitDto.getClassName() );
unitType.setMethodName( unitDto.getMethodName() );
unitType.setFileName( unitDto.getFileName() );
unitType.setLineNumber( unitDto.getLineNumber() );
return unitType;
}
protected List unitDtoListToUnitTypeList(List list) {
if ( list == null ) {
return null;
}
List list1 = new ArrayList( list.size() );
for ( LogsDto.UnitDto unitDto : list ) {
list1.add( unitDtoToUnitType( unitDto ) );
}
return list1;
}
protected LogsType.ThrownType thrownDtoToThrownType(LogsDto.ThrownDto thrownDto) {
if ( thrownDto == null ) {
return null;
}
LogsType.ThrownType thrownType = new LogsType.ThrownType();
thrownType.setType( thrownDto.getType() );
thrownType.setMessage( thrownDto.getMessage() );
thrownType.setStackTrace( unitDtoListToUnitTypeList( thrownDto.getStackTrace() ) );
return thrownType;
}
}