org.hisp.dhis.response.objects.ObjectsResponse Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dhis2-java-client Show documentation
Show all versions of dhis2-java-client Show documentation
DHIS 2 API client for Java.
package org.hisp.dhis.response.objects;
import static org.hisp.dhis.util.CollectionUtils.notEmpty;
import java.util.ArrayList;
import java.util.List;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hisp.dhis.response.BaseHttpResponse;
import org.hisp.dhis.response.Status;
import org.hisp.dhis.response.objects.internal.Response;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
@Setter
@NoArgsConstructor
public class ObjectsResponse
extends BaseHttpResponse
{
@JsonProperty
private Status status;
@JsonProperty
private List typeReports = new ArrayList<>();
@JsonProperty
private ObjectStatistics stats;
/**
* From DHIS 2.38.
*/
@JsonProperty
private Response response;
public ObjectsResponse( Status status, Integer httpStatusCode, ObjectStatistics stats )
{
this.status = status;
this.httpStatusCode = httpStatusCode;
this.stats = stats;
}
@JsonIgnore
public TypeReport getTypeReport()
{
List reports = getTypeReports();
return notEmpty( reports ) ? reports.get( 0 ) : new TypeReport();
}
private boolean hasResponse()
{
return response != null;
}
@Override
public String toString()
{
return new StringBuilder( "[" )
.append( "status: " ).append( status ).append( ", " )
.append( "httpStatusCode: " ).append( httpStatusCode ).append( ", " )
.append( "stats: " ).append( stats ).append( "," )
.append( "typeReport: " ).append( getTypeReport() ).append( "]" ).toString();
}
public Status getStatus()
{
return hasResponse() ? response.getStatus() : status;
}
public List getTypeReports()
{
return hasResponse() ? response.getTypeReports() : typeReports;
}
public ObjectStatistics getStats()
{
return hasResponse() ? response.getStats() : stats;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy