001/*-------------------------------------------------------------------------+ 002| | 003| Copyright (c) 2009-2018 CQSE GmbH | 004| | 005+-------------------------------------------------------------------------*/ 006package org.conqat.engine.service.shared.data; 007 008import java.io.Serializable; 009import java.util.Objects; 010 011import com.fasterxml.jackson.annotation.JsonCreator; 012import com.fasterxml.jackson.annotation.JsonProperty; 013import com.teamscale.commons.lang.ToStringHelpers; 014 015/** 016 * DTO containing all required information of the server concerning server 017 * limits 018 * 019 * <strong>This class is used for communication with IDE clients (via the 020 * {@link org.conqat.engine.service.shared.client.IdeServiceClient}), so special 021 * care has to be taken when changing its signature!</strong> 022 */ 023public final class PreCommitServerLimits implements Serializable { 024 025 private static final long serialVersionUID = 1; 026 027 /** The name of the JSON property name for {@link #timeLimitInSeconds}. */ 028 private static final String TIME_LIMIT_IN_SECONDS_PROPERTY = "timeLimitInSeconds"; 029 030 /** The name of the JSON property name for {@link #fileSizeLimitInBytes}. */ 031 private static final String FILE_SIZE_LIMIT_IN_BYTES_PROPERTY = "fileSizeLimitInBytes"; 032 033 /** The name of the JSON property name for {@link #fileCountLimit}. */ 034 private static final String FILE_COUNT_LIMIT_PROPERTY = "fileCountLimit"; 035 036 @JsonProperty(TIME_LIMIT_IN_SECONDS_PROPERTY) 037 private final int timeLimitInSeconds; 038 039 @JsonProperty(FILE_SIZE_LIMIT_IN_BYTES_PROPERTY) 040 private final long fileSizeLimitInBytes; 041 042 @JsonProperty(FILE_COUNT_LIMIT_PROPERTY) 043 private final int fileCountLimit; 044 045 @JsonCreator 046 public PreCommitServerLimits(@JsonProperty(FILE_COUNT_LIMIT_PROPERTY) int fileCountLimit, 047 @JsonProperty(FILE_SIZE_LIMIT_IN_BYTES_PROPERTY) long fileSizeLimitInBytes, 048 @JsonProperty(TIME_LIMIT_IN_SECONDS_PROPERTY) int timeLimitInSeconds) { 049 this.fileCountLimit = fileCountLimit; 050 this.fileSizeLimitInBytes = fileSizeLimitInBytes; 051 this.timeLimitInSeconds = timeLimitInSeconds; 052 } 053 054 public int getTimeLimitInSeconds() { 055 return timeLimitInSeconds; 056 } 057 058 public long getFileSizeLimitInBytes() { 059 return fileSizeLimitInBytes; 060 } 061 062 public int getFileCountLimit() { 063 return fileCountLimit; 064 } 065 066 @Override 067 public boolean equals(Object other) { 068 if (this == other) { 069 return true; 070 } 071 if (other == null) { 072 return false; 073 } 074 if (getClass() != other.getClass()) { 075 return false; 076 } 077 PreCommitServerLimits that = (PreCommitServerLimits) other; 078 return Objects.equals(timeLimitInSeconds, that.timeLimitInSeconds) 079 && Objects.equals(fileSizeLimitInBytes, that.fileSizeLimitInBytes) 080 && Objects.equals(fileCountLimit, that.fileCountLimit); 081 } 082 083 @Override 084 public int hashCode() { 085 return Objects.hash(timeLimitInSeconds, fileSizeLimitInBytes, fileCountLimit); 086 } 087 088 @Override 089 public String toString() { 090 return ToStringHelpers.toReflectiveStringHelper(this).toString(); 091 } 092}