View Javadoc
1   /*
2   MagicNumber
3   ignoreNumbers = -2, -1, 0, 1, 2, 100
4   ignoreHashCodeMethod = true
5   ignoreFieldDeclaration = true
6   constantWaiverParentToken = ARRAY_INIT, ASSIGN, ELIST, EXPR
7   
8   */
9   
10  package com.puppycrawl.tools.checkstyle.checks.coding.magicnumber;
11  
12  import java.util.concurrent.Callable;
13  import java.util.function.BiFunction;
14  
15  public class InputMagicNumberIgnoreFieldDeclaration4 {
16      public final int radius = 10;
17      public final double area = 22 / 7.0 * radius * radius;
18      public final int a[] = {4, 5};
19  
20      public int x = 10;
21      public int y = 10 * 20;
22      public int[] z = {4, 5};
23  
24      private static final Callable<Void> SLEEP_FOR_A_DAY = () -> {
25          Thread.sleep(86400_000);
26          return null;
27      };
28      private static final BiFunction<Integer, Integer, Integer> ADD_AND_SQUARE = (a, b) -> {
29          int sum = a + b + 5; // violation ''5' is a magic number'
30          return sum * sum * 69;
31      };
32  
33      private static final Callable<Void> SLEEP_FOR_A_DAY_EXP = new Callable<Void>() {
34          @Override
35          public Void call() throws InterruptedException {
36              Thread.sleep(86400_000); // violation ''86400_000' is a magic number'
37              return null;
38          }
39      };
40  
41      private static final BiFunction<Integer, Integer, Integer>
42              ADD_AND_SQUARE_EXP = new BiFunction<Integer, Integer, Integer>() {
43          @Override
44          public Integer apply(Integer a, Integer b) {
45              int sum = a + b + 5; // violation ''5' is a magic number'
46              return sum * sum * 69; // violation ''69' is a magic number'
47          }
48      };
49  
50      private final Callable<Void> SLEEP_FOR_A_DAY_NS = () -> {
51          Thread.sleep(86400_000);
52          return null;
53      };
54      private final BiFunction<Integer, Integer, Integer> ADD_AND_SQUARE_NS = (a, b) -> {
55          int sum = a + b + 5; // violation ''5' is a magic number'
56          return sum * sum * 69;
57      };
58  
59      private final Callable<Void> SLEEP_FOR_A_DAY_EXP_NS = new Callable<Void>() {
60          @Override
61          public Void call() throws InterruptedException {
62              Thread.sleep(86400_000); // violation ''86400_000' is a magic number'
63              return null;
64          }
65      };
66  
67      private final BiFunction<Integer, Integer, Integer>
68              ADD_AND_SQUARE_EXP_NS = new BiFunction<Integer, Integer, Integer>() {
69          @Override
70          public Integer apply(Integer a, Integer b) {
71              int sum = a + b + 5; // violation ''5' is a magic number'
72              return sum * sum * 69; // violation ''69' is a magic number'
73          }
74      };
75  
76  }