InMatch { public boolean match(Object left, Object[] rights) { for (Object right : rights) { if (right instanceof String) { String r = (String) right; if (r.startsWith("\"") && r.endsWith("\"")) { right = r.substring(1, r.length() - 1); } } if (Objects.equals(left, right)) { return true; } } return false; }  boolean match(Object left, Object[] rights);  }
@Test public void testIn() { Assert.assertTrue(new InMatch().match("a", new Object[] { "\"a\"", "\"b\"" })); Assert.assertFalse(new InMatch().match("c", new Object[] { "\"a\"", "\"b\"" })); Assert.assertTrue( new InMatch().match(RequestType.RPC, new Object[] { RequestType.HTTP, RequestType.DATABASE, RequestType.RPC })); Assert.assertFalse( new InMatch().match(RequestType.gRPC, new Object[] { RequestType.HTTP, RequestType.DATABASE, RequestType.RPC } )); Assert.assertTrue(new InMatch().match(1, new Object[] { 1, 2, 3 })); Assert.assertFalse(new InMatch().match(4, new Object[] { 1, 2, 3 })); Assert.assertTrue(new InMatch().match(1.0D, new Object[] { 1.0D, 2.0D, 3.0D })); Assert.assertFalse(new InMatch().match(4.0D, new Object[] { 1.0D, 2.0D, 3.0D })); }