Browse Source

remove lombok from calc plugin

Change-Id: I85fd893a4e45f7676081af8948f039d9ee5dea77
Reviewed-on: http://gerrit.dmdirc.com/2995
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Chris Smith <chris@dmdirc.com>
tags/0.8
Greg Holmes 10 years ago
parent
commit
dcf3ba8581

+ 4
- 3
src/com/dmdirc/addons/calc/Evaluator.java View File

22
 
22
 
23
 package com.dmdirc.addons.calc;
23
 package com.dmdirc.addons.calc;
24
 
24
 
25
-import lombok.RequiredArgsConstructor;
26
-
27
 /**
25
 /**
28
  * A simple evaluator which just requests that the {@link TreeToken} evaluates
26
  * A simple evaluator which just requests that the {@link TreeToken} evaluates
29
  * itself.
27
  * itself.
30
  */
28
  */
31
-@RequiredArgsConstructor
32
 public class Evaluator {
29
 public class Evaluator {
33
 
30
 
34
     /** The token to be evaluated. */
31
     /** The token to be evaluated. */
35
     private final TreeToken node;
32
     private final TreeToken node;
36
 
33
 
34
+    public Evaluator(final TreeToken node) {
35
+        this.node = node;
36
+    }
37
+
37
     /**
38
     /**
38
      * Evaluates the token and returns the numeric result.
39
      * Evaluates the token and returns the numeric result.
39
      *
40
      *

+ 4
- 3
src/com/dmdirc/addons/calc/Parser.java View File

29
 import java.util.Comparator;
29
 import java.util.Comparator;
30
 import java.util.List;
30
 import java.util.List;
31
 
31
 
32
-import lombok.RequiredArgsConstructor;
33
-
34
 /**
32
 /**
35
  * The parser takes the output from a {@link Lexer} and applies precdence rules
33
  * The parser takes the output from a {@link Lexer} and applies precdence rules
36
  * to build the tokens into a tree.
34
  * to build the tokens into a tree.
37
  */
35
  */
38
-@RequiredArgsConstructor
39
 public class Parser {
36
 public class Parser {
40
 
37
 
41
     /** A list of token types sorted by their precendece. */
38
     /** A list of token types sorted by their precendece. */
51
                 new TokenTypePrecedenceComparator());
48
                 new TokenTypePrecedenceComparator());
52
     }
49
     }
53
 
50
 
51
+    public Parser(final Lexer lexer) {
52
+        this.lexer = lexer;
53
+    }
54
+
54
     /**
55
     /**
55
      * Parses the output of this parser's lexer, and returns a {@link TreeToken}
56
      * Parses the output of this parser's lexer, and returns a {@link TreeToken}
56
      * representing the parsed formula.
57
      * representing the parsed formula.

+ 18
- 8
src/com/dmdirc/addons/calc/Token.java View File

22
 
22
 
23
 package com.dmdirc.addons.calc;
23
 package com.dmdirc.addons.calc;
24
 
24
 
25
-import lombok.Getter;
26
-import lombok.RequiredArgsConstructor;
27
-import lombok.ToString;
28
-
29
 /**
25
 /**
30
  * Describes a distinct piece of a mathematical formula, as tokenised by a
26
  * Describes a distinct piece of a mathematical formula, as tokenised by a
31
  * {@link Lexer}.
27
  * {@link Lexer}.
32
  */
28
  */
33
-@Getter
34
-@ToString
35
-@RequiredArgsConstructor
36
-@SuppressWarnings("PMD.UnusedPrivateField")
37
 public class Token {
29
 public class Token {
38
 
30
 
39
     /** The type of this token. */
31
     /** The type of this token. */
42
     /** The content of this token, if any. */
34
     /** The content of this token, if any. */
43
     private final String content;
35
     private final String content;
44
 
36
 
37
+    public Token(final TokenType type, final String content) {
38
+        this.type = type;
39
+        this.content = content;
40
+    }
41
+
42
+    public TokenType getType() {
43
+        return type;
44
+    }
45
+
46
+    public String getContent() {
47
+        return content;
48
+    }
49
+
50
+    @Override
51
+    public String toString() {
52
+        return "Token{" + "type=" + type + ", content=" + content + '}';
53
+    }
54
+
45
 }
55
 }

+ 8
- 5
src/com/dmdirc/addons/calc/TokenType.java View File

27
 import java.util.regex.Matcher;
27
 import java.util.regex.Matcher;
28
 import java.util.regex.Pattern;
28
 import java.util.regex.Pattern;
29
 
29
 
30
-import lombok.Getter;
31
-
32
 /**
30
 /**
33
  * Describes the different types of possible token, their arities, precedence,
31
  * Describes the different types of possible token, their arities, precedence,
34
  * and the types of token that may follow them.
32
  * and the types of token that may follow them.
35
  */
33
  */
36
-@SuppressWarnings("PMD.UnusedPrivateField")
37
 public enum TokenType {
34
 public enum TokenType {
38
 
35
 
39
     /** The start of an input string. */
36
     /** The start of an input string. */
151
     /** The string representation of tokens that may follow this one. */
148
     /** The string representation of tokens that may follow this one. */
152
     private final String[] strfollows;
149
     private final String[] strfollows;
153
     /** The precedence of this token. */
150
     /** The precedence of this token. */
154
-    @Getter
155
     private final int precedence;
151
     private final int precedence;
156
     /** The list of tokens that may follow this one. */
152
     /** The list of tokens that may follow this one. */
157
     private List<TokenType> follows;
153
     private List<TokenType> follows;
158
     /** The regular expression used to match this token. */
154
     /** The regular expression used to match this token. */
159
     private final Pattern regex;
155
     private final Pattern regex;
160
     /** The arity of this token. */
156
     /** The arity of this token. */
161
-    @Getter
162
     private final TokenTypeArity arity;
157
     private final TokenTypeArity arity;
163
 
158
 
164
     /**
159
     /**
177
         this.regex = Pattern.compile(regex);
172
         this.regex = Pattern.compile(regex);
178
     }
173
     }
179
 
174
 
175
+    public int getPrecedence() {
176
+        return precedence;
177
+    }
178
+
179
+    public TokenTypeArity getArity() {
180
+        return arity;
181
+    }
182
+
180
     /**
183
     /**
181
      * Retrieves a list of token types that may follow this one.
184
      * Retrieves a list of token types that may follow this one.
182
      *
185
      *

+ 23
- 10
src/com/dmdirc/addons/calc/TreeToken.java View File

25
 import java.util.ArrayList;
25
 import java.util.ArrayList;
26
 import java.util.List;
26
 import java.util.List;
27
 
27
 
28
-import lombok.Getter;
29
-import lombok.RequiredArgsConstructor;
30
-import lombok.ToString;
31
-
32
 /**
28
 /**
33
  * Describes a tree of {@link Token}s.
29
  * Describes a tree of {@link Token}s.
34
  */
30
  */
35
-@ToString
36
-@RequiredArgsConstructor
37
-@SuppressWarnings("PMD.UnusedPrivateField")
38
 public class TreeToken {
31
 public class TreeToken {
39
 
32
 
40
     /** The children of this node. */
33
     /** The children of this node. */
41
-    @Getter
42
     private final List<TreeToken> children = new ArrayList<>();
34
     private final List<TreeToken> children = new ArrayList<>();
43
 
35
 
44
     /** The token at the root of the tree. */
36
     /** The token at the root of the tree. */
45
-    @Getter
46
     private final Token token;
37
     private final Token token;
47
 
38
 
48
     /** Whether or not this tree has been processed. */
39
     /** Whether or not this tree has been processed. */
49
-    @Getter
50
     private boolean processed = false;
40
     private boolean processed = false;
51
 
41
 
42
+    public TreeToken(final Token token) {
43
+        this.token = token;
44
+    }
45
+
46
+    public List<TreeToken> getChildren() {
47
+        return children;
48
+    }
49
+
50
+    public Token getToken() {
51
+        return token;
52
+    }
53
+
54
+    public boolean isProcessed() {
55
+        return processed;
56
+    }
57
+
52
     /**
58
     /**
53
      * Adds the specified child to this tree.
59
      * Adds the specified child to this tree.
54
      *
60
      *
74
         return token.getType().evaluate(this);
80
         return token.getType().evaluate(this);
75
     }
81
     }
76
 
82
 
83
+    @Override
84
+    public String toString() {
85
+        return "TreeToken{" + "children=" + children
86
+                + ", token=" + token
87
+                + ", processed=" + processed + '}';
88
+    }
89
+
77
 }
90
 }

Loading…
Cancel
Save