Check if the item is favorited
@param user to check
@param item to check
@return favorite state
430363
public static boolean isFavorite(@Nonnull User user, @Nonnull Item item) {
        FavoriteUserProperty fup = user.getProperty(FavoriteUserProperty.class);
        return fup != null && fup.isJobFavorite(item.getFullName());
    }
232991
@Override
    public Iterable<I> getUserItems(U u) {
        if (userItemPreferences.containsKey(u)) {
            return userItemPreferences.get(u).keySet();
        }
        return Collections.emptySet();
    }
1250501
def get_favorites(self, username):
        

        r = self._query_('/users/%s/favorite_anime' % username, 'GET')

        results = [Favorite(item) for item in r.json()]
        return results
1315121
protected List<I> rankItems(final Map<I, Double> userItems) {
        List<I> sortedItems = new ArrayList<>();
        if (userItems == null) {
            return sortedItems;
        }
        Map<Double, Set<I>> itemsByRank = new HashMap<>();
        for (Map.Entry<I, Double> e : userItems.entrySet()) {
            I item = e.getKey();
            double pref = e.getValue();
            if (Double.isNaN(pref)) {
                // we ignore any preference assigned as NaN
                continue;
            }
            Set<I> items = itemsByRank.get(pref);
            if (items == null) {
                items = new HashSet<>();
                itemsByRank.put(pref, items);
            }
            items.add(item);
        }
        List<Double> sortedScores = new ArrayList<>(itemsByRank.keySet());
        Collections.sort(sortedScores, Collections.reverseOrder());
        for (double pref : sortedScores) {
            List<I> sortedPrefItems = new ArrayList<>(itemsByRank.get(pref));
            // deterministic output when ties in preferences: sort by item id
            Collections.sort(sortedPrefItems, Collections.reverseOrder());
            for (I itemID : sortedPrefItems) {
                sortedItems.add(itemID);
            }
        }
        return sortedItems;
    }
514848
protected CmsListItem makeListItem(CmsUser user) {

        CmsListItem item = getList().newItem(user.getId().toString());
        item.set(LIST_COLUMN_LOGIN, user.getName());
        item.set(LIST_COLUMN_FULLNAME, user.getFullName());
        return item;

    }
1157080
function (item, state) {
                state.count = 0;
                state.sub = {};
                item.reset(state.sub);
            }
654316
function setState(state, item) {
  var anno = annoTree.treeItems.get(item.id);
  if (anno) {
    if (anno._state !== state) {
      // FIXME refresh from server
       anno.state = anno._state = state;
       anno.annotatedBy = window.senseBase.username;
       treeInterface.setAnnoState(anno);
       context.pubsub.item.save({ uri: anno.hasTarget, annotations: [anno]});
     }
  }
}
364174
@CheckForNull
    public static SCMDecisionHandler firstShouldPollVeto(@Nonnull Item item) {
        for (SCMDecisionHandler handler : all()) {
            if (!handler.shouldPoll(item)) {
                return handler;
            }
        }
        return null;
    }
296384
def toggle_favourite(self):
        """"""
        status = self.get_selected_status()
        assert status
        app, user = self.app, self.user
        if not app or not user:
            self.footer.draw_message("You must be logged in to favourite", Color.RED)
            return
        status_id = status['id']
        if status['favourited']:
            self.footer.draw_message("Undoing favourite status...", Color.YELLOW)
            api.unfavourite(app, user, status_id)
            self.footer.draw_message("✓ Status unfavourited", Color.GREEN)
        else:
            self.footer.draw_message("Favourite status...", Color.YELLOW)
            api.favourite(app, user, status_id)
            self.footer.draw_message("✓ Status favourited", Color.GREEN)
        status['favourited'] = not status['favourited']

        self.right.draw(status)
845579
public ItemState getItemState(String itemIdentifier, int state)
   {
      return index.get(new IDStateBasedKey(itemIdentifier, state));
   }
717820
def get_likes(self):
        
        from .users import User
        return self._session.fetch_items('likes.getList', User._get_user, count=100, type='post', owner_id=self.from_id, item_id=self.id)
1314487
@Override
    public <I> MatchResult<I> matchResult(I item) {
        StringDescription mismatch = new StringDescription();
        if (matches(item, mismatch)) {
            return new MatchResultSuccess<>(item, this);
        } else {
            return new MatchResultMismatch<>(item, this, mismatch.toString());
        }
    }
676561
public function isOwnedBy($item, $user = [])
    {
        if (!is_array($item)) {
            $item = $item->toArray();
        }

        if (empty($user)) {
            return false;
        }

        $itemUserId = $item[$this->config('column')];
        $userId = $user['id'];

        if ($itemUserId === $userId) {
            return true;
        }

        return false;
    }
1095601
private UserEntity ensureRolesFetched(final UserEntity user)
	{
		if (user != null)
			user.getRoles().stream().map(r -> r.getId()).collect(Collectors.toList());

		return user;
	}
528991
protected int poll(final Selector selector, final long tout, final Collection<zmq.poll.PollItem> items)
    {
        final int size = items.size();
        return zmq.ZMQ.poll(selector, items.toArray(new PollItem[size]), size, tout);
    }
923532
protected boolean checkValid() throws InvalidItemStateException
   {
      try
      {
         session.checkLive();
      }
      catch (RepositoryException e)
      {
         throw new InvalidItemStateException("This kind of operation is forbidden after a session.logout().", e);
      }

      if (data == null)
      {
         throw new InvalidItemStateException("Invalid item state. Item was removed or discarded.");
      }

      session.updateLastAccessTime();
      return true;
   }
414960
function(user) {
		if (typeof user !== "object" || !user.id) return;
		app.states.users[user.id] = user;
		return user;
	}