/** * Converts a Throttle Condition DTO object into a Condition model object * * @param dto Throttle Condition DTO object * @return Derived Condition model object from DTO * @throws UnsupportedThrottleConditionTypeException */ public static Condition fromDTOToCondition(ThrottleConditionDTO dto) throws UnsupportedThrottleConditionTypeException { if (dto instanceof IPConditionDTO) { return fromDTOToIPCondition((IPConditionDTO) dto); } else if (dto instanceof HeaderConditionDTO) { return fromDTOToHeaderCondition((HeaderConditionDTO) dto); } else if (dto instanceof QueryParameterConditionDTO) { return fromDTOToQueryParameterCondition((QueryParameterConditionDTO) dto); } else if (dto instanceof JWTClaimsConditionDTO) { return fromDTOToJWTClaimsCondition((JWTClaimsConditionDTO) dto); } else { String msg = "Throttle Condition type " + dto.getClass().getName() + " is not supported"; log.error(msg); throw new UnsupportedThrottleConditionTypeException(msg); } }
/** * Converts a Throttle Condition model object into a DTO * * @param condition Throttle condition model object * @return Derived DTO object from the model object * @throws UnsupportedThrottleConditionTypeException */ public static ThrottleConditionDTO fromConditionToDTO(Condition condition) //................. throws UnsupportedThrottleConditionTypeException { if (condition instanceof IPCondition) { return fromIPConditionToDTO((IPCondition) condition); } else if (condition instanceof HeaderCondition) { return fromHeaderConditionToDTO((HeaderCondition) condition); } else if (condition instanceof QueryParameterCondition) { return fromQueryParameterConditionToDTO((QueryParameterCondition) condition); } else if (condition instanceof JWTClaimsCondition) { return fromJWTClaimsConditionToDTO((JWTClaimsCondition) condition); } else { String msg = "Throttle Condition type " + condition.getClass().getName() + " is not supported"; log.error(msg); throw new UnsupportedThrottleConditionTypeException(msg); } }