Commit 561ff5aa4ddc9f1aef1657cae3d924e1038c0a5d
- Diff rendering mode:
- inline
- side by side
spring-social-core/src/main/java/org/springframework/social/facebook/PostId.java
(1 / 2)
|   | |||
| 24 | 24 | * @author Ales Justin | |
| 25 | 25 | */ | |
| 26 | 26 | @JsonIgnoreProperties(ignoreUnknown=true) | |
| 27 | public class PostId | ||
| 28 | { | ||
| 27 | public class PostId { | ||
| 29 | 28 | @JsonProperty | |
| 30 | 29 | String id; | |
| 31 | 30 |
spring-social-core/src/main/java/org/springframework/social/facebook/Privacy.java
(157 / 0)
|   | |||
| 1 | /* | ||
| 2 | * Copyright 2010 the original author or authors. | ||
| 3 | * | ||
| 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 | ||
| 7 | * | ||
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | * | ||
| 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. | ||
| 15 | */ | ||
| 16 | package org.springframework.social.facebook; | ||
| 17 | |||
| 18 | import java.util.HashMap; | ||
| 19 | import java.util.Map; | ||
| 20 | import java.util.Set; | ||
| 21 | |||
| 22 | import org.springframework.util.Assert; | ||
| 23 | import org.springframework.util.StringUtils; | ||
| 24 | |||
| 25 | /** | ||
| 26 | * Model class containing privacy attribute. | ||
| 27 | * | ||
| 28 | * @author Ales Justin | ||
| 29 | */ | ||
| 30 | public class Privacy { | ||
| 31 | /** | ||
| 32 | * The privacy type. | ||
| 33 | */ | ||
| 34 | public enum Type { | ||
| 35 | EVERYONE, | ||
| 36 | CUSTOM, | ||
| 37 | ALL_FRIENDS, | ||
| 38 | NETWORKS_FRIENDS, | ||
| 39 | FRIENDS_OF_FRIENDS | ||
| 40 | } | ||
| 41 | |||
| 42 | /** | ||
| 43 | * Custom privacy type. | ||
| 44 | */ | ||
| 45 | public enum CustomType { | ||
| 46 | EVERYONE, | ||
| 47 | NETWORKS_FRIENDS, | ||
| 48 | FRIENDS_OF_FRIENDS, | ||
| 49 | ALL_FRIENDS, | ||
| 50 | SOME_FRIENDS, | ||
| 51 | SELF, | ||
| 52 | NO_FRIENDS | ||
| 53 | } | ||
| 54 | |||
| 55 | String description; | ||
| 56 | Type value; | ||
| 57 | CustomType friends; | ||
| 58 | Set<String> networks; | ||
| 59 | Set<String> allow; | ||
| 60 | Set<String> deny; | ||
| 61 | |||
| 62 | /** | ||
| 63 | * View this instance as json map object. | ||
| 64 | * | ||
| 65 | * @return the map view | ||
| 66 | */ | ||
| 67 | public Map<String, String> toMap() { | ||
| 68 | Assert.notNull(value, "'value' must not be null"); | ||
| 69 | |||
| 70 | Map<String, String> map = new HashMap<String, String>(); | ||
| 71 | if (description != null) | ||
| 72 | map.put("description", description); | ||
| 73 | |||
| 74 | map.put("value", value.name()); | ||
| 75 | |||
| 76 | if (value == Type.CUSTOM) { | ||
| 77 | Assert.notNull(friends, "'friends' must not be null"); | ||
| 78 | map.put("friends", friends.name()); | ||
| 79 | } | ||
| 80 | |||
| 81 | if (networks != null && networks.size() > 0) { | ||
| 82 | map.put("networks", StringUtils.collectionToCommaDelimitedString(networks)); | ||
| 83 | } | ||
| 84 | |||
| 85 | if (friends == CustomType.SOME_FRIENDS) { | ||
| 86 | Assert.notEmpty(allow); | ||
| 87 | map.put("allow", StringUtils.collectionToCommaDelimitedString(allow)); | ||
| 88 | if (deny != null && deny.size() > 0) { | ||
| 89 | map.put("deny", StringUtils.collectionToCommaDelimitedString(deny)); | ||
| 90 | } | ||
| 91 | } | ||
| 92 | |||
| 93 | return map; | ||
| 94 | } | ||
| 95 | |||
| 96 | public Privacy() { | ||
| 97 | } | ||
| 98 | |||
| 99 | public Privacy(Type value) { | ||
| 100 | Assert.notNull(value, "'value' must not be null"); | ||
| 101 | this.value = value; | ||
| 102 | } | ||
| 103 | |||
| 104 | /** | ||
| 105 | * Set descripotion. | ||
| 106 | * | ||
| 107 | * @param description the description | ||
| 108 | */ | ||
| 109 | public void setDescription(String description) { | ||
| 110 | this.description = description; | ||
| 111 | } | ||
| 112 | |||
| 113 | /** | ||
| 114 | * Set value. | ||
| 115 | * | ||
| 116 | * @param value the value | ||
| 117 | */ | ||
| 118 | public void setValue(Type value) { | ||
| 119 | this.value = value; | ||
| 120 | } | ||
| 121 | |||
| 122 | /** | ||
| 123 | * Set friends. | ||
| 124 | * | ||
| 125 | * @param friends the friends | ||
| 126 | */ | ||
| 127 | public void setFriends(CustomType friends) { | ||
| 128 | this.friends = friends; | ||
| 129 | } | ||
| 130 | |||
| 131 | /** | ||
| 132 | * Set networks. | ||
| 133 | * | ||
| 134 | * @param networks the networks | ||
| 135 | */ | ||
| 136 | public void setNetworks(Set<String> networks) { | ||
| 137 | this.networks = networks; | ||
| 138 | } | ||
| 139 | |||
| 140 | /** | ||
| 141 | * Set allow. | ||
| 142 | * | ||
| 143 | * @param allow the allow | ||
| 144 | */ | ||
| 145 | public void setAllow(Set<String> allow) { | ||
| 146 | this.allow = allow; | ||
| 147 | } | ||
| 148 | |||
| 149 | /** | ||
| 150 | * Set deny. | ||
| 151 | * | ||
| 152 | * @param deny deny | ||
| 153 | */ | ||
| 154 | public void setDeny(Set<String> deny) { | ||
| 155 | this.deny = deny; | ||
| 156 | } | ||
| 157 | } |
Comments
Add your comment
Please log in to comment



Add a new comment:
Login or create an account to post a comment