Coverage Report - com.jcabi.github.Repo
 
Classes in this File Line Coverage Branch Coverage Complexity
Repo
N/A
N/A
1
Repo$Smart
24%
8/33
0%
0/16
1
Repo$Smart$AjcClosure1
100%
1/1
N/A
1
Repo$Smart$AjcClosure11
0%
0/1
N/A
1
Repo$Smart$AjcClosure13
0%
0/1
N/A
1
Repo$Smart$AjcClosure15
0%
0/1
N/A
1
Repo$Smart$AjcClosure17
0%
0/1
N/A
1
Repo$Smart$AjcClosure19
0%
0/1
N/A
1
Repo$Smart$AjcClosure21
0%
0/1
N/A
1
Repo$Smart$AjcClosure23
0%
0/1
N/A
1
Repo$Smart$AjcClosure25
0%
0/1
N/A
1
Repo$Smart$AjcClosure27
0%
0/1
N/A
1
Repo$Smart$AjcClosure29
0%
0/1
N/A
1
Repo$Smart$AjcClosure3
100%
1/1
N/A
1
Repo$Smart$AjcClosure31
0%
0/1
N/A
1
Repo$Smart$AjcClosure33
0%
0/1
N/A
1
Repo$Smart$AjcClosure35
0%
0/1
N/A
1
Repo$Smart$AjcClosure37
0%
0/1
N/A
1
Repo$Smart$AjcClosure39
0%
0/1
N/A
1
Repo$Smart$AjcClosure41
0%
0/1
N/A
1
Repo$Smart$AjcClosure43
0%
0/1
N/A
1
Repo$Smart$AjcClosure45
100%
1/1
N/A
1
Repo$Smart$AjcClosure47
0%
0/1
N/A
1
Repo$Smart$AjcClosure5
0%
0/1
N/A
1
Repo$Smart$AjcClosure7
0%
0/1
N/A
1
Repo$Smart$AjcClosure9
0%
0/1
N/A
1
 
 1  0
 /**
 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 javax.json.JsonObject;
 36  
 import javax.json.JsonValue;
 37  
 import javax.validation.constraints.NotNull;
 38  
 import lombok.EqualsAndHashCode;
 39  
 import lombok.ToString;
 40  
 
 41  
 /**
 42  
  * Github repository.
 43  
  * @author Yegor Bugayenko (yegor@tpc2.com)
 44  
  * @version $Id$
 45  
  * @since 0.1
 46  
  */
 47  
 @Immutable
 48  
 @SuppressWarnings("PMD.TooManyMethods")
 49  
 public interface Repo extends JsonReadable, JsonPatchable, Comparable<Repo> {
 50  
 
 51  
     /**
 52  
      * Get its owner.
 53  
      * @return Github
 54  
      */
 55  
     @NotNull(message = "github is never NULL")
 56  
     Github github();
 57  
 
 58  
     /**
 59  
      * Get its coordinates.
 60  
      * @return Coordinates
 61  
      */
 62  
     @NotNull(message = "coordinates is never NULL")
 63  
     Coordinates coordinates();
 64  
 
 65  
     /**
 66  
      * Iterate issues.
 67  
      * @return Issues
 68  
      */
 69  
     @NotNull(message = "iterator of issues is never NULL")
 70  
     Issues issues();
 71  
 
 72  
     /**
 73  
      * Iterate milestones.
 74  
      * @return Milestones
 75  
      * @since 0.7
 76  
      */
 77  
     @NotNull(message = "iterator of milestones is never NULL")
 78  
     Milestones milestones();
 79  
 
 80  
     /**
 81  
      * Pull requests.
 82  
      * @return Pulls
 83  
      */
 84  
     @NotNull(message = "iterator of pull requests is never NULL")
 85  
     Pulls pulls();
 86  
 
 87  
     /**
 88  
      * Hooks.
 89  
      * @return Hooks
 90  
      * @since 0.8
 91  
      */
 92  
     @NotNull(message = "hooks are never NULL")
 93  
     Hooks hooks();
 94  
 
 95  
     /**
 96  
      * Get all issue events for the repository.
 97  
      * @return Issue events
 98  
      * @see <a href="http://developer.github.com/v3/issues/events/#list-events-for-a-repository">List Events for a Repository</a>
 99  
      */
 100  
     @NotNull(message = "events are never NULL")
 101  
     IssueEvents issueEvents();
 102  
 
 103  
     /**
 104  
      * Get all labels of the repo.
 105  
      * @return Labels
 106  
      * @see <a href="http://developer.github.com/v3/issues/labels/">Labels API</a>
 107  
      */
 108  
     @NotNull(message = "labels are never NULL")
 109  
     Labels labels();
 110  
 
 111  
     /**
 112  
      * Get all available assignees to which issues may be assigned.
 113  
      * @return Assignees
 114  
      * @see <a href="http://developer.github.com/v3/issues/assignees/">Assignees API</a>
 115  
      */
 116  
     @NotNull(message = "assignees are never NULL")
 117  
     Assignees assignees();
 118  
 
 119  
     /**
 120  
      * Get all releases of the repo.
 121  
      * @return Releases
 122  
      * @see <a href="http://developer.github.com/v3/repos/releases/">Releases API</a>
 123  
      */
 124  
     @NotNull(message = "releases are never NULL")
 125  
     Releases releases();
 126  
 
 127  
     /**
 128  
      * Get all deploy keys of the repo.
 129  
      * @return DeployKeys
 130  
      * @see <a href="http://developer.github.com/v3/repos/keys/">Deploy Keys API</a>
 131  
      */
 132  
     @NotNull(message = "deploy keys are never NULL")
 133  
     DeployKeys keys();
 134  
 
 135  
     /**
 136  
      * Get all forks of the repo.
 137  
      * @return Forks
 138  
      * @see <a href="http://developer.github.com/v3/repos/forks/">Forks API</a>
 139  
      */
 140  
     @NotNull(message = "Forks are never NULL")
 141  
     Forks forks();
 142  
 
 143  
     /**
 144  
      * Get repository's commits.
 145  
      * @return Commits
 146  
      * @see <a href="http://developer.github.com/v3/repos/commits/">Commits API</a>
 147  
      */
 148  
     @NotNull(message = "RepoCommits are never NULL")
 149  
     RepoCommits commits();
 150  
 
 151  
     /**
 152  
      * Get all contents of the repo.
 153  
      * @return Contents
 154  
      * @see <a href="http://developer.github.com/v3/repos/contents/">Contents API</a>
 155  
      */
 156  
     @NotNull(message = "Contents are never NULL")
 157  
     Contents contents();
 158  
 
 159  
     /**
 160  
      * Gel all collaborators.
 161  
      * @return Collaborators
 162  
      * @see <a href="http://developer.github.com/v3/repos/collaborators/">Collaborators API</a>
 163  
      */
 164  
     @NotNull(message = "Collaborators is never NULL")
 165  
     Collaborators collaborators();
 166  
 
 167  
     /**
 168  
      * Get the Git API entry point.
 169  
      * @return Collaborators
 170  
      * @see <a href="http://developer.github.com/v3/git/">Git Data API</a>
 171  
      */
 172  
     @NotNull(message = "Git is never NULL")
 173  
     Git git();
 174  
 
 175  
     /**
 176  
      * Get Starring API.
 177  
      * @return Stars
 178  
      * @see <a href="https://developer.github.com/v3/activity/starring/">Starring API</a>
 179  
      * @since 0.15
 180  
      */
 181  
     @NotNull(message = "Stars is never NULL")
 182  
     Stars stars();
 183  
 
 184  
     /**
 185  
      * Get Notifications API.
 186  
      * @return Stars
 187  
      * @see <a href="https://developer.github.com/v3/activity/notifications/">Notifications API</a>
 188  
      * @since 0.15
 189  
      */
 190  
     @NotNull(message = "Notifications is never NULL")
 191  
     Notifications notifications();
 192  
 
 193  
     /**
 194  
      * Get languages for the specified repository.
 195  
      * @return Languages
 196  
      * @throws IOException If there is any I/O problem
 197  
      * @see <a href="https://developer.github.com/v3/repos/#list-languages">List languages</a>
 198  
      * @since 0.15
 199  
      */
 200  
     @NotNull(message = "Notifications is never NULL")
 201  
     Iterable<Language> languages() throws IOException;
 202  
 
 203  
     /**
 204  
      * Smart Repo with extra features.
 205  
      */
 206  0
     @Immutable
 207  0
     @ToString
 208  
     @Loggable(Loggable.DEBUG)
 209  0
     @EqualsAndHashCode(of = { "repo", "jsn" })
 210  
     final class Smart implements Repo {
 211  
         /**
 212  
          * Encapsulated Repo.
 213  
          */
 214  
         private final transient Repo repo;
 215  
         /**
 216  
          * SmartJson object for convenient JSON parsing.
 217  
          */
 218  
         private final transient SmartJson jsn;
 219  
         /**
 220  
          * Public ctor.
 221  
          * @param rep Repo
 222  
          */
 223  
         public Smart(
 224  
             @NotNull(message = "rep can't be NULL") final Repo rep
 225  5
         ) {
 226  5
             this.repo = rep;
 227  5
             this.jsn = new SmartJson(rep);
 228  5
         }
 229  
         /**
 230  
          * Get its description.
 231  
          * @return Description
 232  
          * @throws IOException If there is any I/O problem
 233  
          */
 234  
         @NotNull(message = "description is never NULL")
 235  
         public String description() throws IOException {
 236  6
             return this.jsn.text("description");
 237  
         }
 238  
         /**
 239  
          * Is it private?.
 240  
          * @return TRUE if it's private
 241  
          * @throws IOException If there is any I/O problem
 242  
          */
 243  
         public boolean isPrivate() throws IOException {
 244  4
             return JsonValue.TRUE.equals(this.json().get("private"));
 245  
         }
 246  
         @Override
 247  
         @NotNull(message = "github is never NULL")
 248  
         public Github github() {
 249  0
             return this.repo.github();
 250  
         }
 251  
         @Override
 252  
         @NotNull(message = "coordinates is never NULL")
 253  
         public Coordinates coordinates() {
 254  0
             return this.repo.coordinates();
 255  
         }
 256  
         @Override
 257  
         @NotNull(message = "issues is never NULL")
 258  
         public Issues issues() {
 259  0
             return this.repo.issues();
 260  
         }
 261  
         @Override
 262  
         @NotNull(message = "milestones is never NULL")
 263  
         public Milestones milestones() {
 264  0
             return this.repo.milestones();
 265  
         }
 266  
         @Override
 267  
         @NotNull(message = "pulls is never NULL")
 268  
         public Pulls pulls() {
 269  0
             return this.repo.pulls();
 270  
         }
 271  
 
 272  
         @Override
 273  
         @NotNull(message = "hooks is never NULL")
 274  
         public Hooks hooks() {
 275  0
             return this.repo.hooks();
 276  
         }
 277  
         @Override
 278  
         @NotNull(message = "events are never NULL")
 279  
         public IssueEvents issueEvents() {
 280  0
             return this.repo.issueEvents();
 281  
         }
 282  
         @Override
 283  
         @NotNull(message = "labels is never NULL")
 284  
         public Labels labels() {
 285  0
             return this.repo.labels();
 286  
         }
 287  
         @Override
 288  
         @NotNull(message = "assignees is never NULL")
 289  
         public Assignees assignees() {
 290  0
             return this.repo.assignees();
 291  
         }
 292  
         @Override
 293  
         @NotNull(message = "releases is never NULL")
 294  
         public Releases releases() {
 295  0
             return this.repo.releases();
 296  
         }
 297  
         @Override
 298  
         @NotNull(message = "keys is never NULL")
 299  
         public DeployKeys keys() {
 300  0
             return this.repo.keys();
 301  
         }
 302  
         @Override
 303  
         @NotNull(message = "forks is never NULL")
 304  
         public Forks forks() {
 305  0
             return this.repo.forks();
 306  
         }
 307  
         @Override
 308  
         @NotNull(message = "contents is never NULL")
 309  
         public Contents contents() {
 310  0
             return this.repo.contents();
 311  
         }
 312  
         @Override
 313  
         @NotNull(message = "collaborators is never NULL")
 314  
         public Collaborators collaborators() {
 315  0
             return this.repo.collaborators();
 316  
         }
 317  
         @Override
 318  
         @NotNull(message = "git is never NULL")
 319  
         public Git git() {
 320  0
             return this.repo.git();
 321  
         }
 322  
         @Override
 323  
         @NotNull(message = "stars is never NULL")
 324  
         public Stars stars() {
 325  0
             return this.repo.stars();
 326  
         }
 327  
         @Override
 328  
         @NotNull(message = "notifications is never NULL")
 329  
         public Notifications notifications() {
 330  0
             return this.repo.notifications();
 331  
         }
 332  
         @Override
 333  
         @NotNull(message = "languages is never NULL")
 334  
         public Iterable<Language> languages() throws IOException {
 335  0
             return this.repo.languages();
 336  
         }
 337  
         @Override
 338  
         public void patch(
 339  
             @NotNull(message = "json can't be NULL") final JsonObject json
 340  
         ) throws IOException {
 341  0
             this.repo.patch(json);
 342  0
         }
 343  
         @Override
 344  
         @NotNull(message = "commits is never NULL")
 345  
         public RepoCommits commits() {
 346  0
             return this.repo.commits();
 347  
         }
 348  
         @Override
 349  
         @NotNull(message = "JSON is never NULL")
 350  
         public JsonObject json() throws IOException {
 351  4
             return this.repo.json();
 352  
         }
 353  
 
 354  
         @Override
 355  
         public int compareTo(final Repo repos) {
 356  0
             return this.repo.compareTo(repos);
 357  
         }
 358  
     }
 359  
 
 360  
 }