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/16
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-2015, 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 javax.validation.constraints.NotNull;
 38  
 import lombok.EqualsAndHashCode;
 39  
 import lombok.ToString;
 40  
 
 41  
 /**
 42  
  * Github fork.
 43  
  *
 44  
  * @author Carlos Miranda (miranda.cma@gmail.com)
 45  
  * @version $Id$
 46  
  * @since 0.8
 47  
  * @see <a href="http://developer.github.com/v3/repos/forks/">Forks API</a>
 48  
  */
 49  
 @Immutable
 50  
 @SuppressWarnings("PMD.TooManyMethods")
 51  
 public interface Fork extends JsonReadable, JsonPatchable {
 52  
     /**
 53  
      * Fork id.
 54  
      * @return Id
 55  
      */
 56  
     int number();
 57  
 
 58  
     /**
 59  
      * Smart Fork with extra features.
 60  
      */
 61  
     @Immutable
 62  0
     @ToString
 63  
     @Loggable(Loggable.DEBUG)
 64  0
     @EqualsAndHashCode(of = { "fork", "jsn" })
 65  
     final class Smart implements Fork {
 66  
         /**
 67  
          * Encapsulated Fork.
 68  
          */
 69  
         private final transient Fork fork;
 70  
         /**
 71  
          * SmartJson object for convenient JSON parsing.
 72  
          */
 73  
         private final transient SmartJson jsn;
 74  
         /**
 75  
          * Public ctor.
 76  
          * @param frk Fork
 77  
          */
 78  10
         public Smart(@NotNull(message = "fork can't be NULL") final Fork frk) {
 79  10
             this.fork = frk;
 80  10
             this.jsn = new SmartJson(frk);
 81  10
         }
 82  
 
 83  
         /**
 84  
          * Get its name.
 85  
          * @return Name of fork
 86  
          * @throws java.io.IOException If there is any I/O problem
 87  
          */
 88  
         @NotNull(message = "name is never NULL")
 89  
         public String name() throws IOException {
 90  4
             return this.jsn.text("name");
 91  
         }
 92  
 
 93  
         /**
 94  
          * Get its organization.
 95  
          * @return Organization
 96  
          * @throws java.io.IOException If there is any I/O problem
 97  
          */
 98  
         @NotNull(message = "organization is never NULL")
 99  
         public String organization() throws IOException {
 100  2
             return this.jsn.text("organization");
 101  
         }
 102  
 
 103  
         /**
 104  
          * Get its URL.
 105  
          * @return URL of fork
 106  
          * @throws IOException If there is any I/O problem
 107  
          */
 108  
         @NotNull(message = "url is never NULL")
 109  
         public URL url() throws IOException {
 110  2
             return new URL(this.jsn.text("url"));
 111  
         }
 112  
 
 113  
         /**
 114  
          * Get its full name.
 115  
          * @return Full name of fork
 116  
          * @throws java.io.IOException If there is any I/O problem
 117  
          */
 118  
         @NotNull(message = "full_name is never NULL")
 119  
         public String fullName() throws IOException {
 120  2
             return this.jsn.text("full_name");
 121  
         }
 122  
 
 123  
         /**
 124  
          * Get its description.
 125  
          * @return Description of fork
 126  
          * @throws java.io.IOException If there is any I/O problem
 127  
          */
 128  
         @NotNull(message = "description is never NULL")
 129  
         public String description() throws IOException {
 130  2
             return this.jsn.text("description");
 131  
         }
 132  
 
 133  
         /**
 134  
          * Get its html url.
 135  
          * @return Html url of fork
 136  
          * @throws IOException If there is any I/O problem
 137  
          */
 138  
         @NotNull(message = "html url is never NULL")
 139  
         public URL htmlUrl() throws IOException {
 140  2
             return new URL(this.jsn.text("html_url"));
 141  
         }
 142  
 
 143  
         /**
 144  
          * Get its clone url.
 145  
          * @return Clone url of fork
 146  
          * @throws IOException If there is any I/O problem
 147  
          */
 148  
         @NotNull(message = "clone url is never NULL")
 149  
         public URL cloneUrl() throws IOException {
 150  2
             return new URL(this.jsn.text("clone_url"));
 151  
         }
 152  
 
 153  
         /**
 154  
          * Get its git url.
 155  
          * @return Git url of fork
 156  
          * @throws IOException If there is any I/O problem
 157  
          */
 158  
         @NotNull(message = "git url is never NULL")
 159  
         public String gitUrl() throws IOException {
 160  2
             return this.jsn.text("git_url");
 161  
         }
 162  
 
 163  
         /**
 164  
          * Get its ssh url.
 165  
          * @return Ssh url of fork
 166  
          * @throws IOException If there is any I/O problem
 167  
          */
 168  
         @NotNull(message = "ssh url is never NULL")
 169  
         public String sshUrl() throws IOException {
 170  2
             return this.jsn.text("ssh_url");
 171  
         }
 172  
 
 173  
         /**
 174  
          * Get its svn url.
 175  
          * @return Svn url of fork
 176  
          * @throws IOException If there is any I/O problem
 177  
          */
 178  
         @NotNull(message = "svn url is never NULL")
 179  
         public URL svnUrl() throws IOException {
 180  2
             return new URL(this.jsn.text("svn_url"));
 181  
         }
 182  
 
 183  
         /**
 184  
          * Get its mirror url.
 185  
          * @return Mirror url of fork
 186  
          * @throws IOException If there is any I/O problem
 187  
          */
 188  
         @NotNull(message = "mirror url is never NULL")
 189  
         public String mirrorUrl() throws IOException {
 190  2
             return this.jsn.text("mirror_url");
 191  
         }
 192  
 
 193  
         /**
 194  
          * Get its home page.
 195  
          * @return Url of home page of fork
 196  
          * @throws IOException If there is any I/O problem
 197  
          */
 198  
         @NotNull(message = "homepage url is never NULL")
 199  
         public URL homeUrl() throws IOException {
 200  2
             return new URL(this.jsn.text("homepage"));
 201  
         }
 202  
 
 203  
         /**
 204  
          * Get its forks count.
 205  
          * @return Forks count of fork
 206  
          * @throws IOException If there is any I/O problem
 207  
          */
 208  
         public int forks() throws IOException {
 209  2
             return this.jsn.number("forks_count");
 210  
         }
 211  
 
 212  
         /**
 213  
          * Get its stargazers count.
 214  
          * @return Stargazers count of fork
 215  
          * @throws IOException If there is any I/O problem
 216  
          */
 217  
         public int stargazers() throws IOException {
 218  2
             return this.jsn.number("stargazers_count");
 219  
         }
 220  
 
 221  
         /**
 222  
          * Get its watchers count.
 223  
          * @return Watchers count of fork
 224  
          * @throws IOException If there is any I/O problem
 225  
          */
 226  
         public int watchers() throws IOException {
 227  2
             return this.jsn.number("watchers_count");
 228  
         }
 229  
 
 230  
         /**
 231  
          * Get its size.
 232  
          * @return Size of fork
 233  
          * @throws IOException If there is any I/O problem
 234  
          */
 235  
         public int size() throws IOException {
 236  2
             return this.jsn.number("size");
 237  
         }
 238  
 
 239  
         /**
 240  
          * Get its default branch.
 241  
          * @return Default branch
 242  
          * @throws java.io.IOException If there is any I/O problem
 243  
          */
 244  
         @NotNull(message = "default branch is never NULL")
 245  
         public String defaultBranch() throws IOException {
 246  2
             return this.jsn.text("default_branch");
 247  
         }
 248  
 
 249  
         /**
 250  
          * Get its open issues count.
 251  
          * @return Size of fork
 252  
          * @throws IOException If there is any I/O problem
 253  
          */
 254  
         public int openIssues() throws IOException {
 255  2
             return this.jsn.number("open_issues_count");
 256  
         }
 257  
 
 258  
         @Override
 259  
         public int number() {
 260  0
             return this.fork.number();
 261  
         }
 262  
 
 263  
         @Override
 264  
         @NotNull(message = "JSON is never NULL")
 265  
         public JsonObject json() throws IOException {
 266  0
             return this.fork.json();
 267  
         }
 268  
 
 269  
         @Override
 270  
         public void patch(
 271  
             @NotNull(message = "JSON is never NULL")final JsonObject json)
 272  
             throws IOException {
 273  0
             this.fork.patch(json);
 274  0
         }
 275  
     }
 276  
 }