2 * Copyright (c) 2017 Pantheon Technologies s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.cluster.access.client;
10 import org.hamcrest.BaseMatcher;
11 import org.hamcrest.Description;
12 import org.opendaylight.controller.cluster.access.concepts.Request;
15 * Matcher checks, whether matched {@link ConnectionEntry} tracks provided {@link Request}.
17 final class ConnectionEntryMatcher extends BaseMatcher<ConnectionEntry> {
19 private final Request<?, ?> request;
22 * Creates a matcher that matches if the examined {@link ConnectionEntry} contains specified request.
24 * @param request request
27 public static ConnectionEntryMatcher entryWithRequest(final Request<?, ?> request) {
28 return new ConnectionEntryMatcher(request);
31 private ConnectionEntryMatcher(final Request<?, ?> request) {
32 this.request = request;
36 public boolean matches(final Object item) {
37 if (!(item instanceof ConnectionEntry)) {
40 final ConnectionEntry entry = (ConnectionEntry) item;
41 return this.request.equals(entry.getRequest());
45 public void describeMismatch(final Object item, final Description description) {
46 final ConnectionEntry entry = (ConnectionEntry) item;
47 super.describeMismatch(entry.getRequest(), description);
51 public void describeTo(final Description description) {
52 description.appendValue(request);