Clover icon

Coverage Report

  1. Project Clover database Mon Nov 11 2024 20:42:03 GMT
  2. Package jalview.json.binding.biojs

File BioJSRepositoryPojo.java

 

Coverage histogram

../../../../img/srcFileCovDistChart7.png
29% of files have more coverage

Code metrics

2
21
9
1
113
75
11
0.52
2.33
9
1.22

Classes

Class Line # Actions
BioJSRepositoryPojo 34 21 11
0.687568.8%
 

Contributing tests

This file is covered by 59 tests. .

Source view

1    /*
2    * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3    * Copyright (C) $$Year-Rel$$ The Jalview Authors
4    *
5    * This file is part of Jalview.
6    *
7    * Jalview is free software: you can redistribute it and/or
8    * modify it under the terms of the GNU General Public License
9    * as published by the Free Software Foundation, either version 3
10    * of the License, or (at your option) any later version.
11    *
12    * Jalview is distributed in the hope that it will be useful, but
13    * WITHOUT ANY WARRANTY; without even the implied warranty
14    * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15    * PURPOSE. See the GNU General Public License for more details.
16    *
17    * You should have received a copy of the GNU General Public License
18    * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19    * The Jalview Authors are detailed in the 'AUTHORS' file.
20    */
21    package jalview.json.binding.biojs;
22   
23    import jalview.util.JSONUtils;
24   
25    import java.util.ArrayList;
26    import java.util.Collection;
27    import java.util.Iterator;
28    import java.util.List;
29    import java.util.Map;
30    import java.util.Objects;
31   
32    import org.json.simple.parser.ParseException;
33   
 
34    public class BioJSRepositoryPojo
35    {
36   
37    private String description;
38   
39    private String latestReleaseVersion;
40   
41    private Collection<BioJSReleasePojo> releases = new ArrayList<BioJSReleasePojo>();
42   
 
43  0 toggle public BioJSRepositoryPojo()
44    {
45    }
46   
 
47  76 toggle public BioJSRepositoryPojo(String jsonString)
48    {
49  76 try
50    {
51  76 parse(jsonString);
52    } catch (ParseException e)
53    {
54  0 e.printStackTrace();
55    }
56    }
57   
 
58  76 toggle @SuppressWarnings("unchecked")
59    private void parse(String jsonString) throws ParseException
60    {
61  76 Objects.requireNonNull(jsonString,
62    "Supplied jsonString must not be null");
63  76 Map<String, Object> JsonObj = (Map<String, Object>) JSONUtils
64    .parse(jsonString);
65  76 this.description = (String) JsonObj.get("description");
66  76 this.latestReleaseVersion = (String) JsonObj
67    .get("latestReleaseVersion");
68   
69  76 List<Object> repositoriesJsonArray = (List<Object>) JsonObj
70    .get("releases");
71  76 for (Iterator<Object> repoIter = repositoriesJsonArray
72  304 .iterator(); repoIter.hasNext();)
73    {
74  228 Map<String, Object> repoObj = (Map<String, Object>) repoIter.next();
75  228 BioJSReleasePojo repo = new BioJSReleasePojo();
76  228 repo.setType((String) repoObj.get("type"));
77  228 repo.setUrl((String) repoObj.get("url"));
78  228 repo.setVersion((String) repoObj.get("version"));
79  228 this.getReleases().add(repo);
80    }
81    }
82   
 
83  0 toggle public String getDescription()
84    {
85  0 return description;
86    }
87   
 
88  0 toggle public void setDescription(String description)
89    {
90  0 this.description = description;
91    }
92   
 
93  228 toggle public String getLatestReleaseVersion()
94    {
95  228 return latestReleaseVersion;
96    }
97   
 
98  0 toggle public void setLatestReleaseVersion(String latestReleaseVersion)
99    {
100  0 this.latestReleaseVersion = latestReleaseVersion;
101    }
102   
 
103  304 toggle public Collection<BioJSReleasePojo> getReleases()
104    {
105  304 return releases;
106    }
107   
 
108  0 toggle public void setReleases(Collection<BioJSReleasePojo> releases)
109    {
110  0 this.releases = releases;
111    }
112   
113    }