Java Code Examples for com.facebook.internal.Validate#notNullOrEmpty()
The following examples show how to use
com.facebook.internal.Validate#notNullOrEmpty() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FacebookDialog.java From facebook-api-android-maven with Apache License 2.0 | 6 votes |
/** * Constructor. * * @param activity the Activity which is presenting the native Open Graph action publish dialog; * must not be null * @param action the Open Graph action to be published, which must contain a reference to at least one * Open Graph object with the property name specified by setPreviewPropertyName; the action * must have had its type specified via the {@link OpenGraphAction#setType(String)} method * @param actionType the type of the Open Graph action to be published, which should be the namespace-qualified * name of the action type (e.g., "myappnamespace:myactiontype"); this will override the type * of the action passed in. * @param previewPropertyName the name of a property on the Open Graph action that contains the * Open Graph object which will be displayed as a preview to the user */ @Deprecated public OpenGraphDialogBuilderBase(Activity activity, OpenGraphAction action, String actionType, String previewPropertyName) { super(activity); Validate.notNull(action, "action"); Validate.notNullOrEmpty(actionType, "actionType"); Validate.notNullOrEmpty(previewPropertyName, "previewPropertyName"); if (action.getProperty(previewPropertyName) == null) { throw new IllegalArgumentException( "A property named \"" + previewPropertyName + "\" was not found on the action. The name of " + "the preview property must match the name of an action property."); } String typeOnAction = action.getType(); if (!Utility.isNullOrEmpty(typeOnAction) && !typeOnAction.equals(actionType)) { throw new IllegalArgumentException("'actionType' must match the type of 'action' if it is specified. " + "Consider using OpenGraphDialogBuilderBase(Activity activity, OpenGraphAction action, " + "String previewPropertyName) instead."); } this.action = action; this.actionType = actionType; this.previewPropertyName = previewPropertyName; }
Example 2
Source File: FacebookDialog.java From FacebookImageShareIntent with MIT License | 6 votes |
/** * Constructor. * * @param activity the Activity which is presenting the native Open Graph action publish dialog; * must not be null * @param action the Open Graph action to be published, which must contain a reference to at least one * Open Graph object with the property name specified by setPreviewPropertyName; the action * must have had its type specified via the {@link OpenGraphAction#setType(String)} method * @param actionType the type of the Open Graph action to be published, which should be the namespace-qualified * name of the action type (e.g., "myappnamespace:myactiontype"); this will override the type * of the action passed in. * @param previewPropertyName the name of a property on the Open Graph action that contains the * Open Graph object which will be displayed as a preview to the user */ @Deprecated public OpenGraphDialogBuilderBase(Activity activity, OpenGraphAction action, String actionType, String previewPropertyName) { super(activity); Validate.notNull(action, "action"); Validate.notNullOrEmpty(actionType, "actionType"); Validate.notNullOrEmpty(previewPropertyName, "previewPropertyName"); if (action.getProperty(previewPropertyName) == null) { throw new IllegalArgumentException( "A property named \"" + previewPropertyName + "\" was not found on the action. The name of " + "the preview property must match the name of an action property."); } String typeOnAction = action.getType(); if (!Utility.isNullOrEmpty(typeOnAction) && !typeOnAction.equals(actionType)) { throw new IllegalArgumentException("'actionType' must match the type of 'action' if it is specified. " + "Consider using OpenGraphDialogBuilderBase(Activity activity, OpenGraphAction action, " + "String previewPropertyName) instead."); } this.action = action; this.actionType = actionType; this.previewPropertyName = previewPropertyName; }
Example 3
Source File: InsightsLogger.java From HypFacebook with BSD 2-Clause "Simplified" License | 6 votes |
/** * Constructor is private, newLogger() methods should be used to build an instance. */ private InsightsLogger(Context context, String clientToken, String applicationId, Session session) { Validate.notNull(context, "context"); // Always ensure the client token is present, even if not needed for this particular logging (because at // some point it will be required). Be harsh by throwing an exception because this is all too easy to miss // and things will work with authenticated sessions, but start failing with users that don't have // authenticated sessions. Validate.notNullOrEmpty(clientToken, "clientToken"); if (applicationId == null) { applicationId = Utility.getMetadataApplicationId(context); } this.context = context; this.clientToken = clientToken; this.applicationId = applicationId; this.specifiedSession = session; }
Example 4
Source File: FacebookDialog.java From facebook-api-android-maven with Apache License 2.0 | 6 votes |
/** * Constructor. * * @param activity the Activity which is presenting the native Open Graph action publish dialog; * must not be null * @param action the Open Graph action to be published, which must contain a reference to at least one * Open Graph object with the property name specified by setPreviewPropertyName; the action * must have had its type specified via the {@link OpenGraphAction#setType(String)} method * @param previewPropertyName the name of a property on the Open Graph action that contains the * Open Graph object which will be displayed as a preview to the user */ public OpenGraphDialogBuilderBase(Activity activity, OpenGraphAction action, String previewPropertyName) { super(activity); Validate.notNull(action, "action"); Validate.notNullOrEmpty(action.getType(), "action.getType()"); Validate.notNullOrEmpty(previewPropertyName, "previewPropertyName"); if (action.getProperty(previewPropertyName) == null) { throw new IllegalArgumentException( "A property named \"" + previewPropertyName + "\" was not found on the action. The name of " + "the preview property must match the name of an action property."); } this.action = action; this.actionType = action.getType(); this.previewPropertyName = previewPropertyName; }
Example 5
Source File: InsightsLogger.java From FacebookNewsfeedSample-Android with Apache License 2.0 | 6 votes |
/** * Constructor is private, newLogger() methods should be used to build an instance. */ private InsightsLogger(Context context, String clientToken, String applicationId, Session session) { Validate.notNull(context, "context"); // Always ensure the client token is present, even if not needed for this particular logging (because at // some point it will be required). Be harsh by throwing an exception because this is all too easy to miss // and things will work with authenticated sessions, but start failing with users that don't have // authenticated sessions. Validate.notNullOrEmpty(clientToken, "clientToken"); if (applicationId == null) { applicationId = Utility.getMetadataApplicationId(context); } this.context = context; this.clientToken = clientToken; this.applicationId = applicationId; this.specifiedSession = session; }
Example 6
Source File: FacebookDialog.java From Klyph with MIT License | 6 votes |
/** * Constructor. * @param activity the Activity which is presenting the native Open Graph action publish dialog; * must not be null * @param action the Open Graph action to be published, which must contain a reference to at least one * Open Graph object with the property name specified by setPreviewPropertyName; the action * must have had its type specified via the {@link OpenGraphAction#setType(String)} method * @param actionType the type of the Open Graph action to be published, which should be the namespace-qualified * name of the action type (e.g., "myappnamespace:myactiontype"); this will override the type * of the action passed in. * @param previewPropertyName the name of a property on the Open Graph action that contains the * Open Graph object which will be displayed as a preview to the user */ @Deprecated public OpenGraphActionDialogBuilder(Activity activity, OpenGraphAction action, String actionType, String previewPropertyName) { super(activity); Validate.notNull(action, "action"); Validate.notNullOrEmpty(actionType, "actionType"); Validate.notNullOrEmpty(previewPropertyName, "previewPropertyName"); if (action.getProperty(previewPropertyName) == null) { throw new IllegalArgumentException( "A property named \"" + previewPropertyName + "\" was not found on the action. The name of " + "the preview property must match the name of an action property."); } String typeOnAction = action.getType(); if (!Utility.isNullOrEmpty(typeOnAction) && !typeOnAction.equals(actionType)) { throw new IllegalArgumentException("'actionType' must match the type of 'action' if it is specified. " + "Consider using OpenGraphActionDialogBuilder(Activity activity, OpenGraphAction action, " + "String previewPropertyName) instead."); } this.action = action; this.actionType = actionType; this.previewPropertyName = previewPropertyName; }
Example 7
Source File: FacebookDialog.java From KlyphMessenger with MIT License | 6 votes |
/** * Constructor. * @param activity the Activity which is presenting the native Open Graph action publish dialog; * must not be null * @param action the Open Graph action to be published, which must contain a reference to at least one * Open Graph object with the property name specified by setPreviewPropertyName; the action * must have had its type specified via the {@link OpenGraphAction#setType(String)} method * @param actionType the type of the Open Graph action to be published, which should be the namespace-qualified * name of the action type (e.g., "myappnamespace:myactiontype"); this will override the type * of the action passed in. * @param previewPropertyName the name of a property on the Open Graph action that contains the * Open Graph object which will be displayed as a preview to the user */ @Deprecated public OpenGraphActionDialogBuilder(Activity activity, OpenGraphAction action, String actionType, String previewPropertyName) { super(activity); Validate.notNull(action, "action"); Validate.notNullOrEmpty(actionType, "actionType"); Validate.notNullOrEmpty(previewPropertyName, "previewPropertyName"); if (action.getProperty(previewPropertyName) == null) { throw new IllegalArgumentException( "A property named \"" + previewPropertyName + "\" was not found on the action. The name of " + "the preview property must match the name of an action property."); } String typeOnAction = action.getType(); if (!Utility.isNullOrEmpty(typeOnAction) && !typeOnAction.equals(actionType)) { throw new IllegalArgumentException("'actionType' must match the type of 'action' if it is specified. " + "Consider using OpenGraphActionDialogBuilder(Activity activity, OpenGraphAction action, " + "String previewPropertyName) instead."); } this.action = action; this.actionType = actionType; this.previewPropertyName = previewPropertyName; }
Example 8
Source File: InsightsLogger.java From aws-mobile-self-paced-labs-samples with Apache License 2.0 | 6 votes |
/** * Constructor is private, newLogger() methods should be used to build an instance. */ private InsightsLogger(Context context, String clientToken, String applicationId, Session session) { Validate.notNull(context, "context"); // Always ensure the client token is present, even if not needed for this particular logging (because at // some point it will be required). Be harsh by throwing an exception because this is all too easy to miss // and things will work with authenticated sessions, but start failing with users that don't have // authenticated sessions. Validate.notNullOrEmpty(clientToken, "clientToken"); if (applicationId == null) { applicationId = Utility.getMetadataApplicationId(context); } this.context = context; this.clientToken = clientToken; this.applicationId = applicationId; this.specifiedSession = session; }
Example 9
Source File: TestSession.java From Klyph with MIT License | 5 votes |
TestSession(Activity activity, List<String> permissions, TokenCachingStrategy tokenCachingStrategy, String sessionUniqueUserTag, Mode mode) { super(activity, TestSession.testApplicationId, tokenCachingStrategy); Validate.notNull(permissions, "permissions"); // Validate these as if they were arguments even though they are statics. Validate.notNullOrEmpty(testApplicationId, "testApplicationId"); Validate.notNullOrEmpty(testApplicationSecret, "testApplicationSecret"); this.sessionUniqueUserTag = sessionUniqueUserTag; this.mode = mode; this.requestedPermissions = permissions; }
Example 10
Source File: TestSession.java From HypFacebook with BSD 2-Clause "Simplified" License | 5 votes |
TestSession(Activity activity, List<String> permissions, TokenCachingStrategy tokenCachingStrategy, String sessionUniqueUserTag, Mode mode) { super(activity, TestSession.testApplicationId, tokenCachingStrategy); Validate.notNull(permissions, "permissions"); // Validate these as if they were arguments even though they are statics. Validate.notNullOrEmpty(testApplicationId, "testApplicationId"); Validate.notNullOrEmpty(testApplicationSecret, "testApplicationSecret"); this.sessionUniqueUserTag = sessionUniqueUserTag; this.mode = mode; this.requestedPermissions = permissions; }
Example 11
Source File: ValidateTests.java From FacebookImageShareIntent with MIT License | 5 votes |
@SmallTest public void testNotNullOrEmptyOnEmpty() { try { Validate.notNullOrEmpty("", "name"); fail("expected exception"); } catch (Exception e) { } }
Example 12
Source File: WebDialog.java From FacebookImageShareIntent with MIT License | 5 votes |
protected BuilderBase(Context context, String applicationId, String action, Bundle parameters) { if (applicationId == null) { applicationId = Utility.getMetadataApplicationId(context); } Validate.notNullOrEmpty(applicationId, "applicationId"); this.applicationId = applicationId; finishInit(context, action, parameters); }
Example 13
Source File: WebDialog.java From facebook-api-android-maven with Apache License 2.0 | 5 votes |
protected BuilderBase(Context context, String applicationId, String action, Bundle parameters) { if (applicationId == null) { applicationId = Utility.getMetadataApplicationId(context); } Validate.notNullOrEmpty(applicationId, "applicationId"); this.applicationId = applicationId; finishInit(context, action, parameters); }
Example 14
Source File: ImageRequest.java From FacebookNewsfeedSample-Android with Apache License 2.0 | 5 votes |
static URL getProfilePictureUrl( String userId, int width, int height) throws MalformedURLException { Validate.notNullOrEmpty(userId, "userId"); width = Math.max(width, UNSPECIFIED_DIMENSION); height = Math.max(height, UNSPECIFIED_DIMENSION); if (width == UNSPECIFIED_DIMENSION && height == UNSPECIFIED_DIMENSION) { throw new IllegalArgumentException("Either width or height must be greater than 0"); } Uri.Builder builder = new Uri.Builder().encodedPath(String.format(PROFILEPIC_URL_FORMAT, userId)); if (height != UNSPECIFIED_DIMENSION) { builder.appendQueryParameter(HEIGHT_PARAM, String.valueOf(height)); } if (width != UNSPECIFIED_DIMENSION) { builder.appendQueryParameter(WIDTH_PARAM, String.valueOf(width)); } builder.appendQueryParameter(MIGRATION_PARAM, MIGRATION_VALUE); return new URL(builder.toString()); }
Example 15
Source File: WebDialog.java From android-skeleton-project with MIT License | 5 votes |
protected BuilderBase(Context context, String applicationId, String action, Bundle parameters) { if (applicationId == null) { applicationId = Utility.getMetadataApplicationId(context); } Validate.notNullOrEmpty(applicationId, "applicationId"); this.applicationId = applicationId; finishInit(context, action, parameters); }
Example 16
Source File: ImageRequest.java From aws-mobile-self-paced-labs-samples with Apache License 2.0 | 5 votes |
static URL getProfilePictureUrl( String userId, int width, int height) throws MalformedURLException { Validate.notNullOrEmpty(userId, "userId"); width = Math.max(width, UNSPECIFIED_DIMENSION); height = Math.max(height, UNSPECIFIED_DIMENSION); if (width == UNSPECIFIED_DIMENSION && height == UNSPECIFIED_DIMENSION) { throw new IllegalArgumentException("Either width or height must be greater than 0"); } Uri.Builder builder = new Uri.Builder().encodedPath(String.format(PROFILEPIC_URL_FORMAT, userId)); if (height != UNSPECIFIED_DIMENSION) { builder.appendQueryParameter(HEIGHT_PARAM, String.valueOf(height)); } if (width != UNSPECIFIED_DIMENSION) { builder.appendQueryParameter(WIDTH_PARAM, String.valueOf(width)); } builder.appendQueryParameter(MIGRATION_PARAM, MIGRATION_VALUE); return new URL(builder.toString()); }
Example 17
Source File: WebDialog.java From barterli_android with Apache License 2.0 | 4 votes |
protected BuilderBase(Context context, String applicationId, String action, Bundle parameters) { Validate.notNullOrEmpty(applicationId, "applicationId"); this.applicationId = applicationId; finishInit(context, action, parameters); }
Example 18
Source File: WebDialog.java From FacebookNewsfeedSample-Android with Apache License 2.0 | 4 votes |
protected BuilderBase(Context context, String applicationId, String action, Bundle parameters) { Validate.notNullOrEmpty(applicationId, "applicationId"); this.applicationId = applicationId; finishInit(context, action, parameters); }
Example 19
Source File: WebDialog.java From aws-mobile-self-paced-labs-samples with Apache License 2.0 | 4 votes |
protected BuilderBase(Context context, String applicationId, String action, Bundle parameters) { Validate.notNullOrEmpty(applicationId, "applicationId"); this.applicationId = applicationId; finishInit(context, action, parameters); }
Example 20
Source File: WebDialog.java From HypFacebook with BSD 2-Clause "Simplified" License | 4 votes |
protected BuilderBase(Context context, String applicationId, String action, Bundle parameters) { Validate.notNullOrEmpty(applicationId, "applicationId"); this.applicationId = applicationId; finishInit(context, action, parameters); }