Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*******************************************************************************
* Copyright 2012 Apigee Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
package org.usergrid.mq;
import static org.apache.commons.collections.IteratorUtils.asEnumeration;
import static org.apache.commons.collections.MapUtils.getBooleanValue;
import static org.apache.commons.collections.MapUtils.getByteValue;
import static org.apache.commons.collections.MapUtils.getDoubleValue;
import static org.apache.commons.collections.MapUtils.getFloatValue;
import static org.apache.commons.collections.MapUtils.getIntValue;
import static org.apache.commons.collections.MapUtils.getLongValue;
import static org.apache.commons.collections.MapUtils.getShortValue;
import static org.apache.commons.collections.MapUtils.getString;
import static org.usergrid.utils.ClassUtils.cast;
import static org.usergrid.utils.ConversionUtils.bytes;
import static org.usergrid.utils.ConversionUtils.coerceMap;
import static org.usergrid.utils.ConversionUtils.getInt;
import static org.usergrid.utils.ConversionUtils.uuid;
import static org.usergrid.utils.MapUtils.hashMap;
import static org.usergrid.utils.UUIDUtils.getTimestampInMillis;
import static org.usergrid.utils.UUIDUtils.isTimeBased;
import static org.usergrid.utils.UUIDUtils.newTimeUUID;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.TreeMap;
import java.util.UUID;
import javax.xml.bind.annotation.XmlRootElement;
import org.codehaus.jackson.annotate.JsonAnyGetter;
import org.codehaus.jackson.annotate.JsonAnySetter;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.usergrid.utils.UUIDUtils;
import com.fasterxml.uuid.UUIDComparator;
@XmlRootElement
public class Message {
public static final String MESSAGE_CORRELATION_ID = "correlation_id";
public static final String MESSAGE_DESTINATION = "destination";
public static final String MESSAGE_ID = "uuid";
public static final String MESSAGE_REPLY_TO = "reply_to";
public static final String MESSAGE_TIMESTAMP = "timestamp";
public static final String MESSAGE_TYPE = "type";
public static final String MESSAGE_CATEGORY = "category";
public static final String MESSAGE_INDEXED = "indexed";
public static final String MESSAGE_PERSISTENT = "persistent";
@SuppressWarnings("rawtypes")
public static final Map MESSAGE_PROPERTIES = hashMap(
MESSAGE_CORRELATION_ID, (Class) String.class)
.map(MESSAGE_DESTINATION, String.class).map(MESSAGE_ID, UUID.class)
.map(MESSAGE_REPLY_TO, String.class)
.map(MESSAGE_TIMESTAMP, Long.class).map(MESSAGE_TYPE, String.class)
.map(MESSAGE_CATEGORY, String.class)
.map(MESSAGE_INDEXED, Boolean.class)
.map(MESSAGE_PERSISTENT, Boolean.class);
public static int compare(Message m1, Message m2) {
if ((m1 == null) && (m2 == null)) {
return 0;
} else if (m1 == null) {
return -1;
} else if (m2 == null) {
return 1;
}
return UUIDComparator.staticCompare(m1.getUuid(), m2.getUuid());
}
public static List fromList(List