Coverage Report - com.jcabi.github.Statuses
 
Classes in this File Line Coverage Branch Coverage Complexity
Statuses
N/A
N/A
1
Statuses$Smart
0%
0/13
0%
0/16
1
Statuses$Smart$AjcClosure1
0%
0/1
N/A
1
Statuses$Smart$AjcClosure11
0%
0/1
N/A
1
Statuses$Smart$AjcClosure3
0%
0/1
N/A
1
Statuses$Smart$AjcClosure5
0%
0/1
N/A
1
Statuses$Smart$AjcClosure7
0%
0/1
N/A
1
Statuses$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 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 status.
 43  
  *
 44  
  * <p>The status exposes all available properties through its
 45  
  * {@code json()} method. However, it is recommended to use its
 46  
  * "smart" decorator, which helps you to get access to all JSON properties,
 47  
  * for example:
 48  
  *
 49  
  * <pre> URL url = new Status.Smart(status).url();</pre>
 50  
  *
 51  
  * @author Marcin Cylke (marcin.cylke+github@gmail.com)
 52  
  * @version $Id$
 53  
  * @since 0.23
 54  
  * @see <a href="https://developer.github.com/v3/repos/statuses/">Repo statuses</a>
 55  
  */
 56  
 @Immutable
 57  
 public interface Statuses extends JsonReadable {
 58  
 
 59  
     /**
 60  
      * Associated commit.
 61  
      * @return Commit
 62  
      */
 63  
     @NotNull(message = "commit is never NULL")
 64  
     Commit commit();
 65  
 
 66  
     /**
 67  
      * Create new status.
 68  
      * @param status Add this status
 69  
      * @throws java.io.IOException If there is any I/O problem
 70  
      * @return The added status
 71  
      */
 72  
     Status create(
 73  
             @NotNull(message = "status can't be NULL") final Status status
 74  
     ) throws IOException;
 75  
 
 76  
     /**
 77  
      * List all statuses for a given ref.
 78  
      * @param ref It can be a SHA, a branch name, or a tag name.
 79  
      * @return List of statuses
 80  
      */
 81  
     @NotNull(message = "list of statuses is never NULL")
 82  
     Iterable<Statuses> list(
 83  
             @NotNull(message = "ref can't be NULL") final String ref
 84  
     );
 85  
 
 86  
     /**
 87  
      * Smart commit.
 88  
      */
 89  
     @Immutable
 90  0
     @ToString
 91  
     @Loggable(Loggable.DEBUG)
 92  0
     @EqualsAndHashCode(of = { "statuses", "jsn" })
 93  
     final class Smart implements Statuses {
 94  
         /**
 95  
          * Encapsulated status.
 96  
          */
 97  
         private final transient Statuses statuses;
 98  
         /**
 99  
          * SmartJson object for convenient JSON parsing.
 100  
          */
 101  
         private final transient SmartJson jsn;
 102  
         /**
 103  
          * Public ctor.
 104  
          * @param stats Status
 105  
          */
 106  
         public Smart(
 107  
                 @NotNull(message = "cmt can't be NULL") final Statuses stats
 108  0
         ) {
 109  0
             this.statuses = stats;
 110  0
             this.jsn = new SmartJson(this.statuses);
 111  0
         }
 112  
         /**
 113  
          * Get its message.
 114  
          * @return Message of commit
 115  
          * @throws java.io.IOException If there is any I/O problem
 116  
          */
 117  
         @NotNull(message = "message is never NULL")
 118  
         public String message() throws IOException {
 119  0
             return this.jsn.text("message");
 120  
         }
 121  
         /**
 122  
          * Get its URL.
 123  
          * @return URL of comment
 124  
          * @throws IOException If there is any I/O problem
 125  
          */
 126  
         @NotNull(message = "URL is never NULL")
 127  
         public URL url() throws IOException {
 128  0
             return new URL(this.jsn.text("url"));
 129  
         }
 130  
         @Override
 131  
         @NotNull(message = "commit is never NULL")
 132  
         public Commit commit() {
 133  0
             return this.statuses.commit();
 134  
         }
 135  
 
 136  
         @Override
 137  
         public Status create(
 138  
                 @NotNull(message = "status can't be NULL") final Status status
 139  
         ) throws IOException {
 140  0
             return this.statuses.create(status);
 141  
         }
 142  
 
 143  
         @Override
 144  
         public Iterable<Statuses> list(
 145  
                 @NotNull(message = "ref can't be NULL") final String ref
 146  
         ) {
 147  0
             return this.statuses.list(ref);
 148  
         }
 149  
 
 150  
         @Override
 151  
         @NotNull(message = "JSON is never NULL")
 152  
         public JsonObject json() throws IOException {
 153  0
             return this.statuses.json();
 154  
         }
 155  
     }
 156  
 }