2 * Copyright 2011 Google Inc.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package com.google.ipc.invalidation.external.client.types;
19 import com.google.ipc.invalidation.util.Preconditions;
21 import java.util.Arrays;
24 * An identifier for application clients in an application-defined way. I.e., a client name in an
25 * application naming scheme. This is not interpreted by the invalidation system - however, it is
26 * used opaquely to squelch invalidations for the cient causing an update, e.g., if a client C
27 * whose app client id is C.appClientId changes object X and the backend store informs the backend
28 * invalidation sytsem that X was modified by X.appClientId, the invalidation to C can then be
29 * squelched by the invalidation system.
32 public final class ApplicationClientId {
34 /** The opaque id of the client application. */
35 private final byte[] clientName;
38 * Creates an application client id for the given {@code clientName} (does not make a copy of the
41 public static ApplicationClientId newInstance(byte[] appClientId) {
42 return new ApplicationClientId(appClientId);
45 /** Creates an application id for the given {@code clientName}. */
46 private ApplicationClientId(byte[] clientName) {
47 this.clientName = Preconditions.checkNotNull(clientName, "clientName");
50 public byte[] getClientName() {
55 public boolean equals(Object object) {
60 if (!(object instanceof ApplicationClientId)) {
64 final ApplicationClientId other = (ApplicationClientId) object;
65 return Arrays.equals(clientName, other.clientName);
69 public int hashCode() {
70 return Arrays.hashCode(clientName);
74 public String toString() {
75 return "AppClientId: <, " + BytesFormatter.toString(clientName) + ">";