private static boolean shouldIncludeSetter(Method method) { if (!method.getName().startsWith("set")) { return false; } // Exclude methods from Object.class if (method.getDeclaringClass().equals(Object.class)) { return false; } // Static methods if (Modifier.isStatic(method.getModifiers())) { return false; } // Has a return type if (!method.getReturnType().equals(Void.TYPE)) { return false; } // Methods without exactly one parameters if (method.getParameterTypes().length != 1) { return false; } // Excluded methods if (method.isAnnotationPresent(Exclude.class)) { return false; } return true; }
private static boolean shouldIncludeField(Field field) { // Exclude methods from Object.class if (field.getDeclaringClass().equals(Object.class)) { return false; } // Non-public fields if (!Modifier.isPublic(field.getModifiers())) { return false; } // Static fields if (Modifier.isStatic(field.getModifiers())) { return false; } // Transient fields if (Modifier.isTransient(field.getModifiers())) { return false; } // Excluded fields if (field.isAnnotationPresent(Exclude.class)) { return false; } return true; }
@Exclude public Map<String, Object> toMap() { HashMap<String, Object> result = new HashMap<>(); result.put("id", id); result.put("fullName",fullName); result.put("birthDate",birthDate); result.put("birthYear", birthYear); result.put("height",height); result.put("aboutMe",aboutMe); result.put("userLocation",userLocation); result.put("jobPosition",jobPosition); result.put("companyName",companyName); result.put("companyLocation",companyLocation); result.put("jobStartDate",jobStartDate); result.put("homeEmail",homeEmail); result.put("homePhone",homePhone); result.put("workEmail",workEmail); result.put("workPhone",workPhone); result.put("facebookName",facebookName); result.put("facebookLink",facebookLink); result.put("instaName",instaName); result.put("instaLink",instaLink); return result; }
@Exclude public Map<String, Object> toMap() { HashMap<String, Object> result = new HashMap<>(); result.put("uid", uid); result.put("author", author); result.put("title", title); result.put("body", body); result.put("image", image); result.put("starCount", starCount); result.put("stars", stars); result.put("authorImage", authorImage); result.put("authorName", authorName); result.put("authorJobTitle", authorJobTitle); result.put("aboutTheAuthor", aboutTheAuthor); result.put("timeStamp", ServerValue.TIMESTAMP); return result; }
@Exclude public Map<String, Object> toMap() { HashMap<String, Object> result = new HashMap<>(); result.put("id", id); result.put("uid", uid); result.put("author", author); result.put("title", title); result.put("body", body); result.put("price", price); result.put("date", date); result.put("picture", picture); result.put("status", status); result.put("category", category); result.put("starCount", starCount); result.put("stars", stars); return result; }
@Exclude // on map l'univers public Map<String, Object> toMap() { HashMap<String, Object> result = new HashMap<>(); result.put("Id", id); result.put("Name", name); ListIterator iterator = universeUserList.listIterator(); // on appel la fonction de mapping des contacts while(iterator.hasNext()){ Contact contact= (Contact)iterator.next(); HashMap<String,Object> contacthashed= contact.toMap(); iterator.previous(); iterator.set(contacthashed); iterator.next(); } result.put("UniverseUserList", universeUserList); // celle de mapping des MOI if (MOIList!=null){ MoiListtoMap(); } else MOIList = new ArrayList<MOI>(); result.put("MOIList", MOIList); return result; }
@Exclude public Map<String, Object> toMap() { HashMap<String, Object> result = new HashMap<>(); result.put("teamName", teamName); result.put("teamID", teamID); result.put("teamMembers", teamMembers); result.put("latitude", latitude); result.put("longitude", longitude); result.put("status", status); result.put("travelTime", travelTime); result.put("travelTime", travelTimeReadable); result.put("tokens", tokens); return result; }
@Exclude public Map<String, Object> toMap() { HashMap<String, Object> result = new HashMap<>(); result.put("currentTeam", currentTeam); result.put("userID", userID); result.put("currentRole", currentRole); result.put("currentStatus", currentStatus); result.put("email", email); result.put("phone", phone); result.put("token", token); result.put("latitude", latitude); result.put("longitude", longitude); result.put("firstName", firstName); result.put("lastName", lastName); return result; }
/** * Convert to a habit * @return the corresponding Habit object */ @Exclude public Habit getHabit() { HashSet<Integer> newSchedule = new HashSet<>(DateTimeConstants.DAYS_PER_WEEK); for(int i = 0; i < schedule.size(); i++) { if(schedule.get(i)) { newSchedule.add(i + 1); } } Habit habit = new Habit(); habit.setKey(key); habit.setUserId(userId); habit.setTitle(title); habit.setReason(reason); habit.setStartDate(new DateTime(startDate)); habit.setSchedule(newSchedule); habit.setCompletionRate(completionRate); if (completionRate != null) { habit.setStatus(HabitStatus.fromCompletionRate(completionRate)); } return habit; }
/** * Item cam be made if the user has all of the items * needed for the recipe, not considering the amount */ @Exclude public boolean canBeMade(List<StockItem> stock){ for (Map.Entry<String, Object> r : this.resources.entrySet()) { for (StockItem s : stock) { if (r.getKey().equals(s.getName())){ int amountMissing = Integer.parseInt(r.getValue().toString())-s.getAmount(); if (amountMissing > 0){ missingItems.put(s.getName(),amountMissing); } if(canBeMadeWithAvaibleStock && s.getAmount() == 0){ canBeMadeWithAvaibleStock = false; } break; } } } return this.canBeMadeWithAvaibleStock; }
@Exclude private Single<Integer> getCardCount(final String type) { return Single.defer(new Callable<SingleSource<? extends Integer>>() { @Override public SingleSource<? extends Integer> call() throws Exception { return new Single<Integer>() { @Override protected void subscribeActual(SingleObserver<? super Integer> observer) { int count = 0; for (String cardId : cardCount.keySet()) { if (getCards().get(cardId).getType().equals(type)) { count += cardCount.get(cardId); } } observer.onSuccess(count); } }; } }); }
private static boolean shouldIncludeGetter(Method method) { if (!method.getName().startsWith("get") && !method.getName().startsWith("is")) { return false; } // Exclude methods from Object.class if (method.getDeclaringClass().equals(Object.class)) { return false; } // Non-public methods if (!Modifier.isPublic(method.getModifiers())) { return false; } // Static methods if (Modifier.isStatic(method.getModifiers())) { return false; } // No return type if (method.getReturnType().equals(Void.TYPE)) { return false; } // Non-zero parameters if (method.getParameterTypes().length != 0) { return false; } // Excluded methods if (method.isAnnotationPresent(Exclude.class)) { return false; } return true; }
/** * transform this Object into a map * * @return the user map */ @Exclude public Map<String, Object> toMap() { HashMap<String, Object> result = new HashMap<>(); result.put("Id", id); result.put("Pseudo", pseudo); result.put("ContactList", ContactList); result.put("ProfilPicture", profilpicture); return result; }
/** * Convert to a habitKey event object * @return the habitKey event object */ @Exclude public HabitEvent getHabitEvent() { HabitEvent event = new HabitEvent(); event.setKey(key); event.setUserId(userId); event.setHabitKey(habitKey); event.setComment(comment); event.setPhotoUrl(photoUrl); event.setLatitude(latitude); event.setLongitude(longitude); event.setEventDate(new DateTime(eventDate)); return event; }
@Exclude public static Map<String, Object> toMap(final CheckIn checkIn) { final Map<String, Object> result = new HashMap<>(); result.put("email", checkIn.email); result.put("checkInMessage", checkIn.checkInMessage); result.put("timestamp", checkIn.timestamp == null ? ServerValue.TIMESTAMP : checkIn.timestamp); return result; }
/** * Similar to fetchChild, but iterates over the objects pointed to by query and invokes callback * with a List. * * @param query see fetchChild. * @param cls see fetchChild. * @param <T> see fetchChild. * @return see fetchChild. */ @Exclude public <T extends Model> Observable<List<T>> fetchChildren( final Query query, final Class<T> cls) { return observableForQuery(query, (final DataSnapshot dataSnapshot) -> { List<T> items = new ArrayList<>((int) dataSnapshot.getChildrenCount()); for (DataSnapshot itemSnapshot : dataSnapshot.getChildren()) { items.add(Model.fromSnapshot(itemSnapshot, cls, this)); } return items; }); }
@Exclude public Map<String, Object> toMap() { HashMap<String, Object> result = new HashMap<>(); result.put("cmico", cmico); result.put("cmname", cmname); result.put("cmcity", cmcity); result.put("cmdom", cmdom); result.put("cmfir", cmfir); result.put("cmakt", cmakt); return result; }
/** * {@inheritDoc} */ @Exclude @Override public <T> DatabaseReference getChildReference(final Class<T> childClass) { if (childClass == View.class) { return getDeck().getChildReference(View.class, getKey()); } return super.getChildReference(childClass); }
@Exclude @Override public boolean equals(Object obj) { if (obj instanceof CardDetails) { return ingameId.equals(((CardDetails) obj).getIngameId()); } else { return false; } }
@Exclude public List<String> getList() { String[] stringArray = this.value.split(","); List<String> items = new ArrayList<>(); Collections.addAll(items, stringArray); items.removeAll(Arrays.asList("", null)); //http://stackoverflow.com/questions/5520693/in-java-remove-empty-elements-from-a-list-of-strings if (items.size() == 1 && items.get(0).length() == 0) return new ArrayList<>(); return items; }
@Exclude public Map<String, Object> toMap() { HashMap<String, Object> result = new HashMap<>(); result.put("name", eventName); result.put("start", start); result.put("end", end); result.put("date",date); result.put("isReady", isReady); result.put("pendingUsers", pendingUsers); result.put("completedUsers", completedUsers); return result; }
@Exclude public String getFlavor(String locale) { if (flavor != null) { return flavor.get(locale); } else { return ""; } }
/** * Set the Firebase database reference for this instance (if they want to keep it). The only * legitimate usage is deserialization within Model. * * @param ref Database reference used to provide the snapshot this model has been parsed from. */ @Exclude @SuppressWarnings( /* TODO(dotdoom): redesign */ "PMD.EmptyMethodInAbstractClassShouldBeAbstract" ) protected void setReference(final DatabaseReference ref) { // This method can be overridden in child classes. }
/** * Get requested amount of cards for learning. * * @param limit maximum number of cards the query can return. * @return a Query that will fetch ScheduledCards. */ @Exclude public Query fetchCardsToRepeatWithLimitQuery(final int limit) { long time = (long) ServerClock.currentTimeMillis(); return getChildReference(ScheduledCard.class) .orderByChild("repeatAt") .endAt(time) .limitToFirst(limit); }
@Exclude public Map<String, Object> toMap() { HashMap<String, Object> result = new HashMap<>(); result.put("uid", uid); result.put("author", author); result.put("authorPhotoUrl", authorPhotoUrl); result.put("title", title); result.put("body", body); result.put("photoUrl", photoUrl); result.put("starCount", starCount); result.put("stars", stars); return result; }
@Exclude public boolean moveUser(String user){ if(pendingUsers.indexOf(user)!=-1) pendingUsers.remove(pendingUsers.indexOf(user)); if(completedUsers.indexOf(user)==-1) completedUsers.add(user); if(pendingUsers.isEmpty()) isReady = true; return isReady; }
@Exclude public String getDatsString() { long datsl = (long)dats.get("date"); String datss = datsl + ""; return datss; }
@Exclude public void setBackgroundGooglePhotosAlbum(String albumName, String albumId) { this.backgroundGooglePhotosAlbumName = albumName; this.backgroundGooglePhotosAlbumId = albumId; notifyPropertyChanged(BR.backgroundGooglePhotosAlbumName); notifyPropertyChanged(BR.backgroundGooglePhotosAlbumId); appSettings.mCallback.onSettingChanged(BACKGROUND_GOOGLE_ALBUM_ID, getGooglePhotosAlbumId()); appSettings.mCallback.onSettingChanged(BACKGROUND_GOOGLE_ALBUM_NAME, getGooglePhotosAlbumName()); }
@Exclude public Map<String, Object> toMap() { HashMap<String, Object> result = new HashMap<>(); result.put("idm", idm); result.put("iname", iname); result.put("rok", rok); result.put("dats", dats); return result; }
@Exclude public int getStrengthForPosition(String position) { int strength = 0; for (String cardId : getCards().keySet()) { CardDetails card = getCards().get(cardId); if (card.getPositions().contains(position)) { strength += card.getStrength() * cardCount.get(cardId); } } return strength; }
@Exclude public Map<String, Object> toMap() { HashMap<String, Object> result = new HashMap<>(); result.put("uid", uid); result.put("author", author); result.put("text", text); result.put("mid", mid); return result; }
@Exclude static void loadOptions(Widget widget) { if (widget.optionsMap != null) { for (Map.Entry pair : widget.optionsMap.entrySet()) { WidgetOption opt = (WidgetOption) pair.getValue(); opt.widgetRef = widget; opt.key = (String) pair.getKey(); } } }
@Exclude private DatabaseReference getFirebaseWidgetRef() { DatabaseReference widgetsRef = getFirebaseDashboardWidgetsRef(); // if the guid is empty, it's never been saved to firebase before if (this.guid == null) { this.guid = widgetsRef.push().getKey(); } return widgetsRef.child(this.guid); }
@Exclude public Map<String, Object> toMap() { HashMap<String, Object> result = new HashMap<>(); result.put("title", title); result.put("desc", desc); result.put("image", image); return result; }
@Exclude public Map<String, Object> toMap() { HashMap<String, Object> result = new HashMap<>(); result.put("type", type); result.put("position", position); result.put("optionsMap", getMappedOptions()); return result; }
/** * Remove the current deck from the database, including Cards, ScheduledCards, Views and access. * * @return FirebaseTaskAdapter for the delete operation. */ @Exclude public Completable deleteShared() { return new MultiWrite() .delete(this) .delete(this.getChildReference(ScheduledCard.class)) .delete(this.getChildReference(View.class)) .delete(this.getChildReference(DeckAccess.class).child(this.getUser().getKey())) .write(); }
/** End Parcelable Methods **/ @Exclude public void addToPendingGroup(String groupID, String groupName){ if(pendingGroups.get(groupID)==null) pendingGroups.put(groupID,groupName); }
@Exclude void initWidgetSettings(Context context) { // global widget properties initOption(WidgetSettingsFragment.WIDGET_HEIGHT, DEFAULT_WIDGET_HEIGHT); initOption(WidgetSettingsFragment.SCROLL_INTERVAL, DEFAULT_SCROLL_INTERVAL); // start widget specific properties getUIWidget(context).init(); }
@Exclude public void acceptGroup(String groupID,String groupName){ if(pendingGroups.get(groupID)!=null) { pendingGroups.remove(groupID); } if (acceptedGroups.get(groupID) == null) { acceptedGroups.put(groupID, groupName); } }
@Exclude public Map<String, Object> toMap() { HashMap<String, Object> result = new HashMap<>(); result.put("uid", uid); result.put("author", author); result.put("title", title); result.put("body", body); result.put("date", date); result.put("college", college); result.put("starCount", starCount); result.put("stars", stars); return result; }