1055b4925fb282a029e6058b2d670f4a416df205bTor Norbye/* 2055b4925fb282a029e6058b2d670f4a416df205bTor Norbye * Copyright (C) 2015 The Android Open Source Project 3055b4925fb282a029e6058b2d670f4a416df205bTor Norbye * 4055b4925fb282a029e6058b2d670f4a416df205bTor Norbye * Licensed under the Apache License, Version 2.0 (the "License"); 5055b4925fb282a029e6058b2d670f4a416df205bTor Norbye * you may not use this file except in compliance with the License. 6055b4925fb282a029e6058b2d670f4a416df205bTor Norbye * You may obtain a copy of the License at 7055b4925fb282a029e6058b2d670f4a416df205bTor Norbye * 8055b4925fb282a029e6058b2d670f4a416df205bTor Norbye * http://www.apache.org/licenses/LICENSE-2.0 9055b4925fb282a029e6058b2d670f4a416df205bTor Norbye * 10055b4925fb282a029e6058b2d670f4a416df205bTor Norbye * Unless required by applicable law or agreed to in writing, software 11055b4925fb282a029e6058b2d670f4a416df205bTor Norbye * distributed under the License is distributed on an "AS IS" BASIS, 12055b4925fb282a029e6058b2d670f4a416df205bTor Norbye * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13055b4925fb282a029e6058b2d670f4a416df205bTor Norbye * See the License for the specific language governing permissions and 14055b4925fb282a029e6058b2d670f4a416df205bTor Norbye * limitations under the License. 15055b4925fb282a029e6058b2d670f4a416df205bTor Norbye */ 16055b4925fb282a029e6058b2d670f4a416df205bTor Norbyepackage android.support.annotation; 17055b4925fb282a029e6058b2d670f4a416df205bTor Norbye 18bf4b77f1b6bfa3ccf6c4fc8c89f1a1fb563b7a65Aurimas Liutikasimport static java.lang.annotation.ElementType.METHOD; 19bf4b77f1b6bfa3ccf6c4fc8c89f1a1fb563b7a65Aurimas Liutikasimport static java.lang.annotation.RetentionPolicy.CLASS; 20bf4b77f1b6bfa3ccf6c4fc8c89f1a1fb563b7a65Aurimas Liutikas 21c8d78f1623ec828ad2e0bce452e45d207f029d08Tor Norbyeimport java.lang.annotation.Documented; 22055b4925fb282a029e6058b2d670f4a416df205bTor Norbyeimport java.lang.annotation.Retention; 23055b4925fb282a029e6058b2d670f4a416df205bTor Norbyeimport java.lang.annotation.Target; 24055b4925fb282a029e6058b2d670f4a416df205bTor Norbye 25055b4925fb282a029e6058b2d670f4a416df205bTor Norbye/** 26055b4925fb282a029e6058b2d670f4a416df205bTor Norbye * Denotes that the annotated method returns a result that it typically is 27055b4925fb282a029e6058b2d670f4a416df205bTor Norbye * an error to ignore. This is usually used for methods that have no side effect, 28055b4925fb282a029e6058b2d670f4a416df205bTor Norbye * so calling it without actually looking at the result usually means the developer 29055b4925fb282a029e6058b2d670f4a416df205bTor Norbye * has misunderstood what the method does. 30055b4925fb282a029e6058b2d670f4a416df205bTor Norbye * <p> 31055b4925fb282a029e6058b2d670f4a416df205bTor Norbye * Example: 32055b4925fb282a029e6058b2d670f4a416df205bTor Norbye * <pre>{@code 33385cccb8927b54284505b0bfdadb95e157cbdfd2Neil Fuller * public @CheckResult String trim(String s) { return s.trim(); } 34055b4925fb282a029e6058b2d670f4a416df205bTor Norbye * ... 35055b4925fb282a029e6058b2d670f4a416df205bTor Norbye * s.trim(); // this is probably an error 36055b4925fb282a029e6058b2d670f4a416df205bTor Norbye * s = s.trim(); // ok 37055b4925fb282a029e6058b2d670f4a416df205bTor Norbye * }</pre> 38055b4925fb282a029e6058b2d670f4a416df205bTor Norbye */ 39c8d78f1623ec828ad2e0bce452e45d207f029d08Tor Norbye@Documented 40055b4925fb282a029e6058b2d670f4a416df205bTor Norbye@Retention(CLASS) 41055b4925fb282a029e6058b2d670f4a416df205bTor Norbye@Target({METHOD}) 42055b4925fb282a029e6058b2d670f4a416df205bTor Norbyepublic @interface CheckResult { 43055b4925fb282a029e6058b2d670f4a416df205bTor Norbye /** Defines the name of the suggested method to use instead, if applicable (using 44055b4925fb282a029e6058b2d670f4a416df205bTor Norbye * the same signature format as javadoc.) If there is more than one possibility, 45055b4925fb282a029e6058b2d670f4a416df205bTor Norbye * list them all separated by commas. 46055b4925fb282a029e6058b2d670f4a416df205bTor Norbye * <p> 47055b4925fb282a029e6058b2d670f4a416df205bTor Norbye * For example, ProcessBuilder has a method named {@code redirectErrorStream()} 48055b4925fb282a029e6058b2d670f4a416df205bTor Norbye * which sounds like it might redirect the error stream. It does not. It's just 49055b4925fb282a029e6058b2d670f4a416df205bTor Norbye * a getter which returns whether the process builder will redirect the error stream, 50055b4925fb282a029e6058b2d670f4a416df205bTor Norbye * and to actually set it, you must call {@code redirectErrorStream(boolean)}. 51055b4925fb282a029e6058b2d670f4a416df205bTor Norbye * In that case, the method should be defined like this: 52055b4925fb282a029e6058b2d670f4a416df205bTor Norbye * <pre> 53055b4925fb282a029e6058b2d670f4a416df205bTor Norbye * @CheckResult(suggest="#redirectErrorStream(boolean)") 54055b4925fb282a029e6058b2d670f4a416df205bTor Norbye * public boolean redirectErrorStream() { ... } 55055b4925fb282a029e6058b2d670f4a416df205bTor Norbye * </pre> 56055b4925fb282a029e6058b2d670f4a416df205bTor Norbye */ 57055b4925fb282a029e6058b2d670f4a416df205bTor Norbye String suggest() default ""; 58055b4925fb282a029e6058b2d670f4a416df205bTor Norbye}