HistoryKey implements Serializable { public boolean matches(HistoryKey pKey) { return mBean.apply(pKey.mBean); } HistoryKey(JmxReadRequest pJmxRequest);   HistoryKey(JmxWriteRequest pJmxReq);   HistoryKey(JmxExecRequest pJmxReq);  HistoryKey(String pMBean, String pOperation, String pTarget);  HistoryKey(String pMBean, String pAttribute, String pPath, String pTarget); boolean isMBeanPattern(); boolean matches(HistoryKey pKey); @Override @SuppressWarnings("PMD.IfStmtsMustUseBraces") boolean equals(Object o); @Override int hashCode(); @Override String toString();  }
@Test public void matches() throws MalformedObjectNameException { HistoryKey key = new HistoryKey("test:type=*","bla",null,null); assertTrue(key.isMBeanPattern()); JmxReadRequest req2 = new JmxRequestBuilder(READ,"test:type=hello") .attribute("bla") .build(); JmxReadRequest req3 = new JmxRequestBuilder(READ,"test:name=hello") .attribute("bla") .build(); HistoryKey key2 = new HistoryKey(req2); assertFalse(key2.isMBeanPattern()); HistoryKey key3 = new HistoryKey(req3); assertFalse(key3.isMBeanPattern()); assertTrue(key.matches(key2)); assertFalse(key.matches(key3)); }