io.quarkiverse.reactive.messaging.nats.jetstream.mapper.StreamStateMapperImpl Maven / Gradle / Ivy
package io.quarkiverse.reactive.messaging.nats.jetstream.mapper;
import io.nats.client.api.LostStreamData;
import io.nats.client.api.Subject;
import io.quarkiverse.reactive.messaging.nats.jetstream.client.api.LostStreamDataState;
import io.quarkiverse.reactive.messaging.nats.jetstream.client.api.StreamState;
import io.quarkiverse.reactive.messaging.nats.jetstream.client.api.SubjectState;
import jakarta.enterprise.context.ApplicationScoped;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.processing.Generated;
@Generated(
value = "org.mapstruct.ap.MappingProcessor",
date = "2024-11-08T12:52:16+0000",
comments = "version: 1.6.2, compiler: javac, environment: Java 17.0.13 (Eclipse Adoptium)"
)
@ApplicationScoped
public class StreamStateMapperImpl implements StreamStateMapper {
@Override
public StreamState of(io.nats.client.api.StreamState state) {
if ( state == null ) {
return null;
}
StreamState.StreamStateBuilder streamState = StreamState.builder();
streamState.messages( state.getMsgCount() );
streamState.bytes( state.getByteCount() );
streamState.consumers( state.getConsumerCount() );
streamState.subjects( state.getSubjectCount() );
streamState.deleted( state.getDeletedCount() );
streamState.subjectStates( subjectListToSubjectStateList( state.getSubjects() ) );
Map map = state.getSubjectMap();
if ( map != null ) {
streamState.subjectMessages( new LinkedHashMap( map ) );
}
List list1 = state.getDeleted();
if ( list1 != null ) {
streamState.deletedStreamSequences( new ArrayList( list1 ) );
}
streamState.firstSequence( state.getFirstSequence() );
streamState.lastSequence( state.getLastSequence() );
streamState.firstTime( state.getFirstTime() );
streamState.lastTime( state.getLastTime() );
streamState.lostStreamData( lostStreamDataToLostStreamDataState( state.getLostStreamData() ) );
return streamState.build();
}
protected SubjectState subjectToSubjectState(Subject subject) {
if ( subject == null ) {
return null;
}
SubjectState.SubjectStateBuilder subjectState = SubjectState.builder();
subjectState.name( subject.getName() );
subjectState.count( subject.getCount() );
return subjectState.build();
}
protected List subjectListToSubjectStateList(List list) {
if ( list == null ) {
return null;
}
List list1 = new ArrayList( list.size() );
for ( Subject subject : list ) {
list1.add( subjectToSubjectState( subject ) );
}
return list1;
}
protected LostStreamDataState lostStreamDataToLostStreamDataState(LostStreamData lostStreamData) {
if ( lostStreamData == null ) {
return null;
}
LostStreamDataState.LostStreamDataStateBuilder lostStreamDataState = LostStreamDataState.builder();
List list = lostStreamData.getMessages();
if ( list != null ) {
lostStreamDataState.messages( new ArrayList( list ) );
}
lostStreamDataState.bytes( lostStreamData.getBytes() );
return lostStreamDataState.build();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy