[ 
https://issues.apache.org/jira/browse/KNOX-2018?focusedWorklogId=317049&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-317049
 ]

ASF GitHub Bot logged work on KNOX-2018:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 23/Sep/19 23:59
            Start Date: 23/Sep/19 23:59
    Worklog Time Spent: 10m 
      Work Description: lmccay4 commented on pull request #151: KNOX-2018 - 
KnoxShellTable Filtering needs greaterThan and lessThan, equals methods
URL: https://github.com/apache/knox/pull/151#discussion_r327378717
 
 

 ##########
 File path: 
gateway-shell/src/main/java/org/apache/knox/gateway/shell/KnoxShellTable.java
 ##########
 @@ -654,5 +655,146 @@ public KnoxShellTable regex(String regex) {
       }
       return table;
     }
+
+    public KnoxShellTable filter(Predicate p) {
+        KnoxShellTable table = new KnoxShellTable();
+        table.headers.addAll(headers);
+        for (List<String> row : rows) {
+          if (p.test(row.get(index))) {
+            table.row();
+            row.forEach(value -> {
+              table.value(value);
+            });
+          }
+        }
+        return table;
+      }
+
+      public KnoxShellTable greaterThan(String comparator) {
+        Predicate<String> p = (s)->s.compareTo(comparator) > 0;
+
+        return filter(p);
+      }
+
+      public KnoxShellTable lessThan(String comparator) {
+          Predicate<String> p = (s)->s.compareTo(comparator) < 0;
+          return filter(p);
+        }
+
+      public KnoxShellTable lessThan(Integer comparator) {
+          Predicate<String> p = (s)->Integer.valueOf(s).compareTo(comparator) 
< 0;
+          return filter(p);
+        }
+
+      public KnoxShellTable greaterThan(Integer comparator) {
+          Predicate<String> p = (s)->Integer.valueOf(s).compareTo(comparator) 
> 0;
+          return filter(p);
+        }
+
+
+      public KnoxShellTable greaterThan(Double comparator) {
+        Predicate<String> p = (s)->Double.valueOf(s).compareTo(comparator) > 0;
+
+        return filter(p);
+      }
+
+      public KnoxShellTable lessThan(Double comparator) {
+          Predicate<String> p = (s)->Double.valueOf(s).compareTo(comparator) < 
0;
+
+          return filter(p);
+        }
+
+      public KnoxShellTable lessThan(Float comparator) {
+          Predicate<String> p = (s)->Float.valueOf(s).compareTo(comparator) < 
0;
+
+          return filter(p);
+        }
+
+      public KnoxShellTable greaterThan(Float comparator) {
+          Predicate<String> p = (s)->Float.valueOf(s).compareTo(comparator) > 
0;
+
+          return filter(p);
+        }
+
+      public KnoxShellTable equalTo(String comparator) {
+          Predicate<String> p = (s)->s.compareTo(comparator) == 0;
+
+          return filter(p);
+        }
+
+      public KnoxShellTable equalTo(Integer comparator) {
+          Predicate<String> p = (s)->Integer.valueOf(s).compareTo(comparator) 
== 0;
+
+          return filter(p);
+        }
+
+      public KnoxShellTable equalTo(Double comparator) {
+          Predicate<String> p = (s)->Double.valueOf(s).compareTo(comparator) 
== 0;
+
+          return filter(p);
+        }
+
+      public KnoxShellTable equalTo(Float comparator) {
+          Predicate<String> p = (s)->Float.valueOf(s).compareTo(comparator) == 
0;
+
+          return filter(p);
+        }
+
+      public KnoxShellTable equalToIgnoreCase(String comparator) {
+          Predicate<String> p = (s)->s.equalsIgnoreCase(comparator);
+
+          return filter(p);
+        }
+
+      public KnoxShellTable greaterThanOrEquals(String comparator) {
+          Predicate<String> p = (s)-> s.compareTo(comparator) > 0 || 
s.compareTo(comparator) == 0;
 
 Review comment:
   After spending a while looking at this I can't think of a way to do this 
that would decrease redundancy given the type-specific methods in use - making 
calls to greaterThan() and equalTo() would return actual table objects where 
booleans would be needed. Do you have any suggestions?
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 317049)
    Time Spent: 1h 20m  (was: 1h 10m)

> KnoxShellTable Filtering needs greaterThan and lessThan, equals Methods
> -----------------------------------------------------------------------
>
>                 Key: KNOX-2018
>                 URL: https://issues.apache.org/jira/browse/KNOX-2018
>             Project: Apache Knox
>          Issue Type: Improvement
>          Components: KnoxShell
>            Reporter: Larry McCay
>            Assignee: Ljmiv
>            Priority: Major
>              Labels: noob
>             Fix For: 1.4.0
>
>          Time Spent: 1h 20m
>  Remaining Estimate: 0h
>
> It would be useful to have greaterThan and lessThan filtering for 
> KnoxShellTable.
> Currently we have a regex match to filter matches.
> Some easier methods for greaterThan, lessThan, equals, equalsIgnoreCare, etc 
> would be very helpful as regex for those things may be possible but more 
> complicated than necessary.
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to