Android Open Source - RealtimeMessaging-Android Pair






From Project

Back to project page RealtimeMessaging-Android.

License

The source code is released under:

MIT License

If you think the Android project RealtimeMessaging-Android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/**
 * @fileoverview This file contains the implementation of a key value generic class
 *///  ww w  .j  a v a2s  .c  o m
package ibt.ortc.api;

/**
 * Key Value generic class
 *
 * @param <A> Key
 * @param <B> Value
 */
public class Pair<A, B> {
  /**
   * Key element
   */
    public A first;
  
  /**
   * Value element
   */
    public B second;

  /**
   * Creates a instance of a key value object
   * 
   * @param first Key element
   * @param second Value element
   */
  public Pair(A first, B second) {
    this.first = first;
    this.second = second;
  }

  /**
   * Gets the key element
   * @return Key element 
   */
  public A getFirst() {
    return first;
  }

  /**
   * Gets the value element
   * @return Value element 
   */
  public B getSecond() {
    return second;
  }

  /**
   * Sets the key element
   */
  public void setFirst(A v) {
    first = v;
  }

  /**
   * Sets the value element
   */
  public void setSecond(B v) {
    second = v;
  }

  /**
   * Gets a string representation of the object
   * 
   * @return String representation of the object
   */
    @Override
  public String toString() {
        // CAUSE: Prefer String.format to +
        return String.format("Pair[%s,%s]", first, second);
  }

  private static boolean equals(Object x, Object y) {
    return (x == null && y == null) || (x != null && x.equals(y));
  }

  /**
   * Compares the current object with another
   * 
   * @return boolean True if other object is equal to the current otherwise false 
   */
  @SuppressWarnings("rawtypes")
    @Override
  public boolean equals(Object other) {
    return other instanceof Pair && equals(first, ((Pair) other).first) && equals(second, ((Pair) other).second);
  }

  /**
   * Generates a hashcode based on the elements hashcodes
   * 
   * @return int the object hashcode 
   */
    @Override
  public int hashCode() {
        // CAUSE: If-Else Statements Should Use Braces
        if (first == null) {
      return (second == null) ? 0 : second.hashCode() + 1;
        } else if (second == null) {
      return first.hashCode() + 2;
        } else {
      return first.hashCode() * 17 + second.hashCode();
  }
    }

  public static <A, B> Pair<A, B> of(A a, B b) {
    return new Pair<A, B>(a, b);
  }
}




Java Source Code List

ibt.ortc.api.ApplicationTest.java
ibt.ortc.api.Authentication.java
ibt.ortc.api.Balancer.java
ibt.ortc.api.ChannelPermissions.java
ibt.ortc.api.InvalidBalancerServerException.java
ibt.ortc.api.OnDisablePresence.java
ibt.ortc.api.OnEnablePresence.java
ibt.ortc.api.OnPresence.java
ibt.ortc.api.OnRestWebserviceResponse.java
ibt.ortc.api.OrtcAuthenticationNotAuthorizedException.java
ibt.ortc.api.Ortc.java
ibt.ortc.api.Pair.java
ibt.ortc.api.Presence.java
ibt.ortc.api.RestWebservice.java
ibt.ortc.api.SecureWebConnections.java
ibt.ortc.api.Strings.java
ibt.ortc.extensibility.ChannelSubscription.java
ibt.ortc.extensibility.CharEscaper.java
ibt.ortc.extensibility.ConnectionProtocol.java
ibt.ortc.extensibility.DispatchedMessages.java
ibt.ortc.extensibility.EventEnum.java
ibt.ortc.extensibility.GcmOrtcBroadcastReceiver.java
ibt.ortc.extensibility.GcmOrtcIntentService.java
ibt.ortc.extensibility.GcmRegistration.java
ibt.ortc.extensibility.HeartbeatSender.java
ibt.ortc.extensibility.OnConnected.java
ibt.ortc.extensibility.OnDisconnected.java
ibt.ortc.extensibility.OnException.java
ibt.ortc.extensibility.OnMessageWithPayload.java
ibt.ortc.extensibility.OnMessage.java
ibt.ortc.extensibility.OnReconnected.java
ibt.ortc.extensibility.OnReconnecting.java
ibt.ortc.extensibility.OnSubscribed.java
ibt.ortc.extensibility.OnUnsubscribed.java
ibt.ortc.extensibility.OrtcClient.java
ibt.ortc.extensibility.OrtcFactory.java
ibt.ortc.extensibility.exception.OrtcAlreadyConnectedException.java
ibt.ortc.extensibility.exception.OrtcDoesNotHavePermissionException.java
ibt.ortc.extensibility.exception.OrtcEmptyFieldException.java
ibt.ortc.extensibility.exception.OrtcGcmException.java
ibt.ortc.extensibility.exception.OrtcInvalidCharactersException.java
ibt.ortc.extensibility.exception.OrtcMaxLengthException.java
ibt.ortc.extensibility.exception.OrtcNotConnectedException.java
ibt.ortc.extensibility.exception.OrtcNotSubscribedException.java
ibt.ortc.extensibility.exception.OrtcSubscribedException.java
ibt.ortc.ortclib.ApplicationTest.java
ibt.ortc.ortclib.MainActivity.java
ibt.ortc.ortclib.SettingsActivity.java
ibt.ortc.plugins.IbtRealtimeSJ.IbtRealtimeSJClient.java
ibt.ortc.plugins.IbtRealtimeSJ.IbtRealtimeSJFactory.java
ibt.ortc.plugins.IbtRealtimeSJ.OrtcMessage.java
ibt.ortc.plugins.IbtRealtimeSJ.OrtcOperation.java
ibt.ortc.plugins.IbtRealtimeSJ.OrtcServerErrorException.java
ibt.ortc.plugins.websocket.WebSocketConnection.java
ibt.ortc.plugins.websocket.WebSocketEventHandler.java
ibt.ortc.plugins.websocket.WebSocketException.java
ibt.ortc.plugins.websocket.WebSocketHandshake.java
ibt.ortc.plugins.websocket.WebSocketMessage.java
ibt.ortc.plugins.websocket.WebSocketReceiver.java
ibt.ortc.plugins.websocket.WebSocketSender.java
ibt.ortc.plugins.websocket.WebSocket.java