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

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

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

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

@@ -22,18 +22,10 @@
22 22
 
23 23
 package com.dmdirc.addons.calc;
24 24
 
25
-import lombok.Getter;
26
-import lombok.RequiredArgsConstructor;
27
-import lombok.ToString;
28
-
29 25
 /**
30 26
  * Describes a distinct piece of a mathematical formula, as tokenised by a
31 27
  * {@link Lexer}.
32 28
  */
33
-@Getter
34
-@ToString
35
-@RequiredArgsConstructor
36
-@SuppressWarnings("PMD.UnusedPrivateField")
37 29
 public class Token {
38 30
 
39 31
     /** The type of this token. */
@@ -42,4 +34,22 @@ public class Token {
42 34
     /** The content of this token, if any. */
43 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,13 +27,10 @@ import java.util.List;
27 27
 import java.util.regex.Matcher;
28 28
 import java.util.regex.Pattern;
29 29
 
30
-import lombok.Getter;
31
-
32 30
 /**
33 31
  * Describes the different types of possible token, their arities, precedence,
34 32
  * and the types of token that may follow them.
35 33
  */
36
-@SuppressWarnings("PMD.UnusedPrivateField")
37 34
 public enum TokenType {
38 35
 
39 36
     /** The start of an input string. */
@@ -151,14 +148,12 @@ public enum TokenType {
151 148
     /** The string representation of tokens that may follow this one. */
152 149
     private final String[] strfollows;
153 150
     /** The precedence of this token. */
154
-    @Getter
155 151
     private final int precedence;
156 152
     /** The list of tokens that may follow this one. */
157 153
     private List<TokenType> follows;
158 154
     /** The regular expression used to match this token. */
159 155
     private final Pattern regex;
160 156
     /** The arity of this token. */
161
-    @Getter
162 157
     private final TokenTypeArity arity;
163 158
 
164 159
     /**
@@ -177,6 +172,14 @@ public enum TokenType {
177 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 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,30 +25,36 @@ package com.dmdirc.addons.calc;
25 25
 import java.util.ArrayList;
26 26
 import java.util.List;
27 27
 
28
-import lombok.Getter;
29
-import lombok.RequiredArgsConstructor;
30
-import lombok.ToString;
31
-
32 28
 /**
33 29
  * Describes a tree of {@link Token}s.
34 30
  */
35
-@ToString
36
-@RequiredArgsConstructor
37
-@SuppressWarnings("PMD.UnusedPrivateField")
38 31
 public class TreeToken {
39 32
 
40 33
     /** The children of this node. */
41
-    @Getter
42 34
     private final List<TreeToken> children = new ArrayList<>();
43 35
 
44 36
     /** The token at the root of the tree. */
45
-    @Getter
46 37
     private final Token token;
47 38
 
48 39
     /** Whether or not this tree has been processed. */
49
-    @Getter
50 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 59
      * Adds the specified child to this tree.
54 60
      *
@@ -74,4 +80,11 @@ public class TreeToken {
74 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