Package rocks.xmpp.im.roster.model
Enum DefinedState
- java.lang.Object
-
- java.lang.Enum<DefinedState>
-
- rocks.xmpp.im.roster.model.DefinedState
-
- All Implemented Interfaces:
Serializable
,Comparable<DefinedState>
,SubscriptionState
public enum DefinedState extends Enum<DefinedState> implements SubscriptionState
Represents the nine possible defined subscription states.Each state can transition to a new state depending on an in- or outbound presence subscription change.
- See Also:
Presence.Type
, RFC 6121, A.1. Defined States
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface rocks.xmpp.im.roster.model.SubscriptionState
SubscriptionState.Subscription
-
-
Enum Constant Summary
Enum Constants Enum Constant Description BOTH
User and contact are subscribed to each other (two-way); this is reflected in the user's roster by subscription='both'.FROM
Contact is subscribed to user (one-way); this is reflected in the user's roster by subscription='from'.FROM_PENDING_OUT
Contact is subscribed to user, and user has sent contact a subscription request but contact has not replied yet; this is reflected in the user's roster by subscription='from' and ask='subscribe'.NONE
Contact and user are not subscribed to each other, and neither has requested a subscription from the other; this is reflected in the user's roster by subscription='none'.NONE_PENDING_IN
Contact and user are not subscribed to each other, and contact has sent user a subscription request but user has not replied yet.NONE_PENDING_OUT
Contact and user are not subscribed to each other, and user has sent contact a subscription request but contact has not replied yet; this is reflected in the user's roster by subscription='none' and ask='subscribe'.NONE_PENDING_OUT_IN
Contact and user are not subscribed to each other, contact has sent user a subscription request but user has not replied yet, and user has sent contact a subscription request but contact has not replied yet; this is reflected in the user's roster by subscription='none' and ask='subscribe'.TO
User is subscribed to contact (one-way); this is reflected in the user's roster by subscription='to'.TO_PENDING_IN
User is subscribed to contact, and contact has sent user a subscription request but user has not replied yet; this is reflected in the user's roster by subscription='to'.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description SubscriptionState.Subscription
getSubscription()
Gets the primary subscription state.boolean
isPendingIn()
If the presence subscription is pending in from a user's perspective.boolean
isPendingOut()
If the presence subscription is pending out from a user's perspective.DefinedState
onInboundSubscriptionChange(Presence.Type type)
Transforms an existing subscription state into a new state, depending on an inbound presence subscription change.DefinedState
onOutboundSubscriptionChange(Presence.Type type)
Transforms an existing subscription state into a new state, depending on an outbound presence subscription change.static DefinedState
valueOf(String name)
Returns the enum constant of this type with the specified name.static DefinedState
valueOf(SubscriptionState subscriptionState)
Returns a defined subscription state from an existing subscription state, e.g. aRosterItem
.static DefinedState[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
NONE
public static final DefinedState NONE
Contact and user are not subscribed to each other, and neither has requested a subscription from the other; this is reflected in the user's roster by subscription='none'.
-
NONE_PENDING_OUT
public static final DefinedState NONE_PENDING_OUT
Contact and user are not subscribed to each other, and user has sent contact a subscription request but contact has not replied yet; this is reflected in the user's roster by subscription='none' and ask='subscribe'.
-
NONE_PENDING_IN
public static final DefinedState NONE_PENDING_IN
Contact and user are not subscribed to each other, and contact has sent user a subscription request but user has not replied yet. This state might or might not be reflected in the user's roster, as follows: if the user has created a roster item for the contact then the server MUST maintain that roster item and also note the existence of the inbound presence subscription request, whereas if the user has not created a roster item for the contact then the user's server MUST note the existence of the inbound presence subscription request but MUST NOT create a roster item for the contact (instead, the server MUST wait until the user has approved the subscription request before adding the contact to the user's roster).
-
NONE_PENDING_OUT_IN
public static final DefinedState NONE_PENDING_OUT_IN
Contact and user are not subscribed to each other, contact has sent user a subscription request but user has not replied yet, and user has sent contact a subscription request but contact has not replied yet; this is reflected in the user's roster by subscription='none' and ask='subscribe'.
-
TO
public static final DefinedState TO
User is subscribed to contact (one-way); this is reflected in the user's roster by subscription='to'.
-
TO_PENDING_IN
public static final DefinedState TO_PENDING_IN
User is subscribed to contact, and contact has sent user a subscription request but user has not replied yet; this is reflected in the user's roster by subscription='to'.
-
FROM
public static final DefinedState FROM
Contact is subscribed to user (one-way); this is reflected in the user's roster by subscription='from'.
-
FROM_PENDING_OUT
public static final DefinedState FROM_PENDING_OUT
Contact is subscribed to user, and user has sent contact a subscription request but contact has not replied yet; this is reflected in the user's roster by subscription='from' and ask='subscribe'.
-
BOTH
public static final DefinedState BOTH
User and contact are subscribed to each other (two-way); this is reflected in the user's roster by subscription='both'.
-
-
Method Detail
-
values
public static DefinedState[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (DefinedState c : DefinedState.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static DefinedState valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
valueOf
public static DefinedState valueOf(SubscriptionState subscriptionState)
Returns a defined subscription state from an existing subscription state, e.g. aRosterItem
.- Parameters:
subscriptionState
- The existing subscription state.- Returns:
- The defined subscription state. Never
null
.
-
getSubscription
public final SubscriptionState.Subscription getSubscription()
Description copied from interface:SubscriptionState
Gets the primary subscription state. It may be one ofSubscriptionState.Subscription.NONE
,SubscriptionState.Subscription.TO
,SubscriptionState.Subscription.FROM
orSubscriptionState.Subscription.BOTH
.- Specified by:
getSubscription
in interfaceSubscriptionState
- Returns:
- The primary subscription state.
-
isPendingOut
public final boolean isPendingOut()
Description copied from interface:SubscriptionState
If the presence subscription is pending out from a user's perspective. The user has sent contact a subscription request but contact has not replied yet.- Specified by:
isPendingOut
in interfaceSubscriptionState
- Returns:
- If the state is pending out.
-
isPendingIn
public final boolean isPendingIn()
Description copied from interface:SubscriptionState
If the presence subscription is pending in from a user's perspective. The contact has sent user a subscription request but user has not replied yet.- Specified by:
isPendingIn
in interfaceSubscriptionState
- Returns:
- If the state is pending in.
-
onOutboundSubscriptionChange
public final DefinedState onOutboundSubscriptionChange(Presence.Type type)
Transforms an existing subscription state into a new state, depending on an outbound presence subscription change.- Parameters:
type
- The presence subscription type.- Returns:
- The new subscription state.
- See Also:
- A.2. Server Processing of Outbound Presence Subscription Stanzas
-
onInboundSubscriptionChange
public final DefinedState onInboundSubscriptionChange(Presence.Type type)
Transforms an existing subscription state into a new state, depending on an inbound presence subscription change.- Parameters:
type
- The presence subscription type.- Returns:
- The new subscription state.
- See Also:
- A.3. Server Processing of Inbound Presence Subscription Stanzas
-
-