Coverage Report - com.jcabi.github.Fork
 
Classes in this File Line Coverage Branch Coverage Complexity
Fork
N/A
N/A
1
Fork$Smart
79%
23/29
0%
0/20
1
Fork$Smart$AjcClosure1
100%
1/1
N/A
1
Fork$Smart$AjcClosure11
100%
1/1
N/A
1
Fork$Smart$AjcClosure13
100%
1/1
N/A
1
Fork$Smart$AjcClosure15
100%
1/1
N/A
1
Fork$Smart$AjcClosure17
100%
1/1
N/A
1
Fork$Smart$AjcClosure19
100%
1/1
N/A
1
Fork$Smart$AjcClosure21
100%
1/1
N/A
1
Fork$Smart$AjcClosure23
100%
1/1
N/A
1
Fork$Smart$AjcClosure25
100%
1/1
N/A
1
Fork$Smart$AjcClosure27
100%
1/1
N/A
1
Fork$Smart$AjcClosure29
100%
1/1
N/A
1
Fork$Smart$AjcClosure3
100%
1/1
N/A
1
Fork$Smart$AjcClosure31
100%
1/1
N/A
1
Fork$Smart$AjcClosure33
100%
1/1
N/A
1
Fork$Smart$AjcClosure35
100%
1/1
N/A
1
Fork$Smart$AjcClosure37
0%
0/1
N/A
1
Fork$Smart$AjcClosure39
0%
0/1
N/A
1
Fork$Smart$AjcClosure41
0%
0/1
N/A
1
Fork$Smart$AjcClosure5
100%
1/1
N/A
1
Fork$Smart$AjcClosure7
100%
1/1
N/A
1
Fork$Smart$AjcClosure9
100%
1/1
N/A
1
 
 1  2
 /**
 2  
  * Copyright (c) 2013-2017, jcabi.com
 3  
  * All rights reserved.
 4  
  *
 5  
  * Redistribution and use in source and binary forms, with or without
 6  
  * modification, are permitted provided that the following conditions
 7  
  * are met: 1) Redistributions of source code must retain the above
 8  
  * copyright notice, this list of conditions and the following
 9  
  * disclaimer. 2) Redistributions in binary form must reproduce the above
 10  
  * copyright notice, this list of conditions and the following
 11  
  * disclaimer in the documentation and/or other materials provided
 12  
  * with the distribution. 3) Neither the name of the jcabi.com nor
 13  
  * the names of its contributors may be used to endorse or promote
 14  
  * products derived from this software without specific prior written
 15  
  * permission.
 16  
  *
 17  
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 18  
  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
 19  
  * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 20  
  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
 21  
  * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 22  
  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 23  
  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 24  
  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 25  
  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 26  
  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 27  
  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 28  
  * OF THE POSSIBILITY OF SUCH DAMAGE.
 29  
  */
 30  
 package com.jcabi.github;
 31  
 
 32  
 import com.jcabi.aspects.Immutable;
 33  
 import com.jcabi.aspects.Loggable;
 34  
 import java.io.IOException;
 35  
 import java.net.URL;
 36  
 import javax.json.JsonObject;
 37  
 import lombok.EqualsAndHashCode;
 38  
 import lombok.ToString;
 39  
 
 40  
 /**
 41  
  * Github fork.
 42  
  *
 43  
  * @author Carlos Miranda (miranda.cma@gmail.com)
 44  
  * @version $Id: 3fe6b6fdf60cfde719c964891b1698ef0d8a3122 $
 45  
  * @since 0.8
 46  
  * @see <a href="http://developer.github.com/v3/repos/forks/">Forks API</a>
 47  
  */
 48  
 @Immutable
 49  
 @SuppressWarnings("PMD.TooManyMethods")
 50  
 public interface Fork extends JsonReadable, JsonPatchable {
 51  
     /**
 52  
      * Fork id.
 53  
      * @return Id
 54  
      */
 55  
     int number();
 56  
 
 57  
     /**
 58  
      * Smart Fork with extra features.
 59  
      */
 60  
     @Immutable
 61  0
     @ToString
 62  
     @Loggable(Loggable.DEBUG)
 63  0
     @EqualsAndHashCode(of = { "fork", "jsn" })
 64  
     final class Smart implements Fork {
 65  
         /**
 66  
          * Encapsulated Fork.
 67  
          */
 68  
         private final transient Fork fork;
 69  
         /**
 70  
          * SmartJson object for convenient JSON parsing.
 71  
          */
 72  
         private final transient SmartJson jsn;
 73  
         /**
 74  
          * Public ctor.
 75  
          * @param frk Fork
 76  
          */
 77  9
         public Smart(final Fork frk) {
 78  10
             this.fork = frk;
 79  10
             this.jsn = new SmartJson(frk);
 80  10
         }
 81  
 
 82  
         /**
 83  
          * Get its name.
 84  
          * @return Name of fork
 85  
          * @throws java.io.IOException If there is any I/O problem
 86  
          */
 87  
         public String name() throws IOException {
 88  4
             return this.jsn.text("name");
 89  
         }
 90  
 
 91  
         /**
 92  
          * Get its organization.
 93  
          * @return Organization
 94  
          * @throws java.io.IOException If there is any I/O problem
 95  
          */
 96  
         public String organization() throws IOException {
 97  2
             return this.jsn.text("organization");
 98  
         }
 99  
 
 100  
         /**
 101  
          * Get its URL.
 102  
          * @return URL of fork
 103  
          * @throws IOException If there is any I/O problem
 104  
          */
 105  
         public URL url() throws IOException {
 106  2
             return new URL(this.jsn.text("url"));
 107  
         }
 108  
 
 109  
         /**
 110  
          * Get its full name.
 111  
          * @return Full name of fork
 112  
          * @throws java.io.IOException If there is any I/O problem
 113  
          */
 114  
         public String fullName() throws IOException {
 115  2
             return this.jsn.text("full_name");
 116  
         }
 117  
 
 118  
         /**
 119  
          * Get its description.
 120  
          * @return Description of fork
 121  
          * @throws java.io.IOException If there is any I/O problem
 122  
          */
 123  
         public String description() throws IOException {
 124  2
             return this.jsn.text("description");
 125  
         }
 126  
 
 127  
         /**
 128  
          * Get its html url.
 129  
          * @return Html url of fork
 130  
          * @throws IOException If there is any I/O problem
 131  
          */
 132  
         public URL htmlUrl() throws IOException {
 133  2
             return new URL(this.jsn.text("html_url"));
 134  
         }
 135  
 
 136  
         /**
 137  
          * Get its clone url.
 138  
          * @return Clone url of fork
 139  
          * @throws IOException If there is any I/O problem
 140  
          */
 141  
         public URL cloneUrl() throws IOException {
 142  2
             return new URL(this.jsn.text("clone_url"));
 143  
         }
 144  
 
 145  
         /**
 146  
          * Get its git url.
 147  
          * @return Git url of fork
 148  
          * @throws IOException If there is any I/O problem
 149  
          */
 150  
         public String gitUrl() throws IOException {
 151  2
             return this.jsn.text("git_url");
 152  
         }
 153  
 
 154  
         /**
 155  
          * Get its ssh url.
 156  
          * @return Ssh url of fork
 157  
          * @throws IOException If there is any I/O problem
 158  
          */
 159  
         public String sshUrl() throws IOException {
 160  2
             return this.jsn.text("ssh_url");
 161  
         }
 162  
 
 163  
         /**
 164  
          * Get its svn url.
 165  
          * @return Svn url of fork
 166  
          * @throws IOException If there is any I/O problem
 167  
          */
 168  
         public URL svnUrl() throws IOException {
 169  2
             return new URL(this.jsn.text("svn_url"));
 170  
         }
 171  
 
 172  
         /**
 173  
          * Get its mirror url.
 174  
          * @return Mirror url of fork
 175  
          * @throws IOException If there is any I/O problem
 176  
          */
 177  
         public String mirrorUrl() throws IOException {
 178  2
             return this.jsn.text("mirror_url");
 179  
         }
 180  
 
 181  
         /**
 182  
          * Get its home page.
 183  
          * @return Url of home page of fork
 184  
          * @throws IOException If there is any I/O problem
 185  
          */
 186  
         public URL homeUrl() throws IOException {
 187  2
             return new URL(this.jsn.text("homepage"));
 188  
         }
 189  
 
 190  
         /**
 191  
          * Get its forks count.
 192  
          * @return Forks count of fork
 193  
          * @throws IOException If there is any I/O problem
 194  
          */
 195  
         public int forks() throws IOException {
 196  2
             return this.jsn.number("forks_count");
 197  
         }
 198  
 
 199  
         /**
 200  
          * Get its stargazers count.
 201  
          * @return Stargazers count of fork
 202  
          * @throws IOException If there is any I/O problem
 203  
          */
 204  
         public int stargazers() throws IOException {
 205  2
             return this.jsn.number("stargazers_count");
 206  
         }
 207  
 
 208  
         /**
 209  
          * Get its watchers count.
 210  
          * @return Watchers count of fork
 211  
          * @throws IOException If there is any I/O problem
 212  
          */
 213  
         public int watchers() throws IOException {
 214  2
             return this.jsn.number("watchers_count");
 215  
         }
 216  
 
 217  
         /**
 218  
          * Get its size.
 219  
          * @return Size of fork
 220  
          * @throws IOException If there is any I/O problem
 221  
          */
 222  
         public int size() throws IOException {
 223  2
             return this.jsn.number("size");
 224  
         }
 225  
 
 226  
         /**
 227  
          * Get its default branch.
 228  
          * @return Default branch
 229  
          * @throws java.io.IOException If there is any I/O problem
 230  
          */
 231  
         public String defaultBranch() throws IOException {
 232  2
             return this.jsn.text("default_branch");
 233  
         }
 234  
 
 235  
         /**
 236  
          * Get its open issues count.
 237  
          * @return Size of fork
 238  
          * @throws IOException If there is any I/O problem
 239  
          */
 240  
         public int openIssues() throws IOException {
 241  2
             return this.jsn.number("open_issues_count");
 242  
         }
 243  
 
 244  
         @Override
 245  
         public int number() {
 246  0
             return this.fork.number();
 247  
         }
 248  
 
 249  
         @Override
 250  
         public JsonObject json() throws IOException {
 251  0
             return this.fork.json();
 252  
         }
 253  
 
 254  
         @Override
 255  
         public void patch(final JsonObject json) throws IOException {
 256  0
             this.fork.patch(json);
 257  0
         }
 258  
     }
 259  
 }