001// Copyright (c) FIRST and other WPILib contributors.
002// Open Source Software; you can modify and/or share it under the terms of
003// the WPILib BSD license file in the root directory of this project.
004
005package org.wpilib.annotation;
006
007import java.lang.annotation.ElementType;
008import java.lang.annotation.Retention;
009import java.lang.annotation.RetentionPolicy;
010import java.lang.annotation.Target;
011
012/**
013 * Marks a method as returning a value that must be used. The WPILib compiler plugin will check for
014 * uses of methods with this annotation and report a compiler error if the value is unused. Marking
015 * a class or interface as {@code @NoDiscard} will act as if any method that returns that type or
016 * any subclass or implementor of that type has been marked with {@code @NoDiscard}.
017 */
018@Target({ElementType.METHOD, ElementType.TYPE})
019@Retention(RetentionPolicy.CLASS) // needs to be stored in the class for use by libraries
020public @interface NoDiscard {
021  /**
022   * An error message to display if the return value is not used.
023   *
024   * @return The error message.
025   */
026  String value() default "";
027}