88import com .messagebird .exceptions .UnauthorizedException ;
99import com .messagebird .objects .ErrorReport ;
1010import com .messagebird .objects .PagedPaging ;
11- import org .apache .maven .artifact .versioning .ComparableVersion ;
1211
1312import java .io .File ;
1413import java .io .FileOutputStream ;
@@ -62,7 +61,7 @@ public class MessageBirdServiceImpl implements MessageBirdService {
6261 private static final String [] PROTOCOL_LISTS = new String []{"http://" , "https://" };
6362 private static final List <String > PROTOCOLS = Arrays .asList (PROTOCOL_LISTS );
6463
65- private static final ComparableVersion JAVA_VERSION = getJavaVersion ();
64+ private static final String JAVA_VERSION = getJavaVersion ();
6665
6766 // Indicates whether we've overridden HttpURLConnection's behaviour to
6867 // allow PATCH requests yet. Also see docs on allowPatchRequestsIfNeeded().
@@ -89,13 +88,9 @@ public MessageBirdServiceImpl(final String accessKey, final String serviceUrl) {
8988
9089 }
9190
92- private static ComparableVersion getJavaVersion () {
93- try {
94- String version = System .getProperty ("java.version" );
95- return new ComparableVersion (version );
96- } catch (IllegalArgumentException e ) {
97- return new ComparableVersion ("0.0" );
98- }
91+ private static String getJavaVersion () {
92+ String version = System .getProperty ("java.version" );
93+ return version != null ? version : "0.0" ;
9994 }
10095
10196 private String determineUserAgentString () {
@@ -113,7 +108,7 @@ public MessageBirdServiceImpl(final String accessKey) {
113108
114109 @ Override
115110 public <R > R request (String request , Class <R > clazz )
116- throws UnauthorizedException , GeneralException , NotFoundException {
111+ throws UnauthorizedException , GeneralException , NotFoundException {
117112 return getJsonData (request , null , "GET" , clazz );
118113 }
119114
@@ -142,7 +137,7 @@ public <R> R requestByID(String request, String id, Map<String, Object> params,
142137
143138 @ Override
144139 public <E > List <E > requestByIdAsList (String request , String id , Class <E > elementClass )
145- throws UnauthorizedException , GeneralException , NotFoundException {
140+ throws UnauthorizedException , GeneralException , NotFoundException {
146141 String path = "" ;
147142 if (id != null ) {
148143 path = "/" + id ;
@@ -276,8 +271,8 @@ public <T, P> T getJsonData(final String request, final P payload, final String
276271
277272 // Prevents mismatched exception when clazz is null
278273 return clazz == null
279- ? null
280- : this .readValue (mapper , body , clazz );
274+ ? null
275+ : this .readValue (mapper , body , clazz );
281276 } catch (IOException ioe ) {
282277 throw new GeneralException (ioe );
283278 }
@@ -290,8 +285,8 @@ public <T, P> T getJsonData(final String request, final P payload, final String
290285
291286 // todo: need to refactor for duplicated code.
292287 public <P , E > List <E > getJsonDataAsList (final String request ,
293- final P payload , final String requestType , final Map <String , String > headers , final Class <E > elementClass )
294- throws UnauthorizedException , GeneralException , NotFoundException {
288+ final P payload , final String requestType , final Map <String , String > headers , final Class <E > elementClass )
289+ throws UnauthorizedException , GeneralException , NotFoundException {
295290 if (request == null ) {
296291 throw new IllegalArgumentException (REQUEST_VALUE_MUST_BE_SPECIFIED );
297292 }
@@ -327,12 +322,12 @@ public <P, E> List<E> getJsonDataAsList(final String request,
327322 }
328323
329324 private <T > T readValue (ObjectMapper mapper , String content , Class <T > clazz )
330- throws JsonProcessingException {
325+ throws JsonProcessingException {
331326 return mapper .readValue (content , clazz );
332327 }
333328
334329 private <E > List <E > readValueAsList (ObjectMapper mapper , String content , final Class <E > elementClass )
335- throws JsonProcessingException {
330+ throws JsonProcessingException {
336331 return mapper .readValue (content , mapper .getTypeFactory ().constructCollectionType (List .class , elementClass ));
337332 }
338333
@@ -637,11 +632,7 @@ private void setAdditionalHeaders(HttpURLConnection connection, Map<String, Stri
637632 }
638633
639634 private DateFormat getDateFormat () {
640- ComparableVersion java6 = new ComparableVersion ("1.6" );
641- if (JAVA_VERSION .compareTo (java6 ) > 0 ) {
642- return new SimpleDateFormat ("yyyy-MM-dd'T'HH:mm:ssXXX" );
643- }
644- return new SimpleDateFormat ("yyyy-MM-dd'T'HH:mm:ssZZZ" );
635+ return new SimpleDateFormat ("yyyy-MM-dd'T'HH:mm:ssXXX" );
645636 }
646637
647638 /**
@@ -798,4 +789,4 @@ private String getPathVariables(final Map<String, Object> map) {
798789 }
799790 return bpath .toString ();
800791 }
801- }
792+ }
0 commit comments