Commit 8b230436 authored by Trisha Gee's avatar Trisha Gee
Browse files

[appB] Examples for annotations

parent a4a22802
Loading
Loading
Loading
Loading
+32 −0
Changes for src/main/java/appB/AnnotationExamples.java: 32 added lines, 0 removed lines.
Original line number Diff line number Diff line
package appB;

import org.jetbrains.annotations.NotNull;

public class AnnotationExamples {
  private @NotNull String cannotBeNull = "some value";

  void cannotTakeNullParameter(@NotNull String str) {
    @NotNull String val;
    System.out.println(str.length());
  }

  @NotNull
  String cannotReturnNullValue() {
    return null;
  }

  // if you use @Override on a method that is not from Object, this will give a compiler error
  @Override
  public String toString() {
    return "AnnotationExamples{" +
           "cannotBeNull='" + cannotBeNull + '\'' +
           '}';
  }
}

@FunctionalInterface
interface IntToString {
  String convert(int value);
  // uncomment this to see a compiler error
//  void anotherAbstractMethod();
}
+8 −0
Changes for src/test/java/appB/TestMeTest.java: 8 added lines, 0 removed lines.
Original line number Diff line number Diff line
package appB;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

class TestMeTest {
@@ -15,4 +16,11 @@ class TestMeTest {
    // then
    Assertions.assertEquals(expectedMessage, testMe.getMessage());
  }

  @Test
  @Disabled("This test isn't finished")
  void thisTestIsForIgnoring() {
    Assertions.fail("Fails on purpose");
  }

}
 No newline at end of file