Java Code Examples for java.util.UUID.equals()

The following are Jave code examples for showing how to use equals() of the java.util.UUID class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: cf-java-client-sap   File: CloudControllerClientImpl.java   View Source Code Vote up 6 votes
private UUID getRouteGuid(String host, UUID domainGuid) {
    Map<String, Object> urlVars = new HashMap<String, Object>();
    String urlPath = "/v2";
    urlPath = urlPath + "/routes?inline-relations-depth=0&q=host:{host}";
    urlVars.put("host", host);
    List<Map<String, Object>> allRoutes = getAllResources(urlPath, urlVars);
    UUID routeGuid = null;
    for (Map<String, Object> route : allRoutes) {
        UUID routeSpace = CloudEntityResourceMapper.getEntityAttribute(route, "space_guid", UUID.class);
        UUID routeDomain = CloudEntityResourceMapper.getEntityAttribute(route, "domain_guid", UUID.class);
        if (sessionSpace.getMeta().getGuid().equals(routeSpace) && domainGuid.equals(routeDomain)) {
            routeGuid = CloudEntityResourceMapper.getMeta(route).getGuid();
        }
    }
    return routeGuid;
}
 
Example 2
Project: Lagerta   File: LeadPlanner.java   View Source Code Vote up 6 votes
private boolean isTxAvailableToCommitOnOwnNode(TxInfo txInfo, Lazy<UUID, Set<Object>> availableTxsPerNode) {
    Set<Object> sameNodeScope = availableTxsPerNode.get(txInfo.consumerId());

    if (sameNodeScope.containsAll(txInfo.scope())) {
        return true;
    }
    for (Map.Entry<UUID, Set<Object>> entry : availableTxsPerNode) {
        UUID nodeId = entry.getKey();
        Set<Object> nodeScope = entry.getValue();

        if (!nodeId.equals(txInfo.consumerId()) && !Collections.disjoint(nodeScope, txInfo.scope())) {
            return false;
        }
    }
    return true;
}
 
Example 3
Project: RPGInventory   File: MyPetManager.java   View Source Code Vote up 6 votes
private static void syncPlayer(MyPetPlayer mpPlayer) {
    Slot petSlot = getMyPetSlot();
    if (mpPlayer.isOnline() && mpPlayer.hasMyPet()) {
        Player player = mpPlayer.getPlayer();

        if (!InventoryManager.playerIsLoaded(player)) {
            return;
        }

        Inventory inventory = InventoryManager.get(player).getInventory();
        ItemStack currentPet = inventory.getItem(petSlot.getSlotId());
        if (isMyPetItem(currentPet)) {
            MyPet pet = mpPlayer.getMyPet();
            UUID petUUID = UUID.fromString(ItemUtils.getTag(currentPet, MYPET_TAG));
            if (petUUID.equals(pet.getUUID())) {
                return;
            }
        } else {
            inventory.setItem(petSlot.getSlotId(), petSlot.getCup());
        }

        MyPetApi.getMyPetManager().deactivateMyPet(mpPlayer, false);
    }
}
 
Example 4
Project: RPGInventory   File: MyPetManager.java   View Source Code Vote up 6 votes
@EventHandler(ignoreCancelled = true)
public void onMyPetRemove(MyPetRemoveEvent event) {
    Player player = event.getOwner().getPlayer();
    if (!InventoryManager.playerIsLoaded(player)) {
        return;
    }

    Inventory inventory = InventoryManager.get(player).getInventory();
    Slot petSlot = getMyPetSlot();
    ItemStack currentPetItem = inventory.getItem(petSlot.getSlotId());

    if (isMyPetItem(currentPetItem)) {
        UUID petUUID = UUID.fromString(ItemUtils.getTag(currentPetItem, MYPET_TAG));
        if (petUUID.equals(event.getMyPet().getUUID())) {
            inventory.setItem(petSlot.getSlotId(), petSlot.getCup());
        }
    }
}
 
Example 5
Project: scorekeeperfrontend   File: EntrantTree.java   View Source Code Vote up 6 votes
@Override
public void event(MT type, Object o)
{
	switch (type)
	{
		case CHALLENGE_CHANGED:
		case ENTRANT_CHANGED:
			UUID challengeid = ChallengeGUI.state.getCurrentChallengeId();
			Collection<UUID> exclude;
			Collection<Entrant> reg;
			if (!challengeid.equals(IdGenerator.nullid))
			{
				reg = Database.d.getEntrantsByEvent(ChallengeGUI.state.getCurrentEventId());
				exclude = Database.d.getCarIdsByChallenge(challengeid);
			}
			else
			{
				reg = new Vector<Entrant>();
				exclude = new Vector<UUID>();
			}

			makeTree(reg, exclude);
			break;
	}
}
 
Example 6
Project: RPGInventory   File: MyPetManager.java   View Source Code Vote up 6 votes
@EventHandler(ignoreCancelled = true)
public void onMyPetCall(MyPetCallEvent event) {
    Player player = event.getOwner().getPlayer();
    if (!InventoryManager.playerIsLoaded(player)) {
        return;
    }

    Inventory inventory = InventoryManager.get(player).getInventory();
    ItemStack currentPet = inventory.getItem(getMyPetSlot().getSlotId());
    boolean keepPet = true;

    if (!isMyPetItem(currentPet)) {
        keepPet = false;
    } else {
        UUID petUUID = UUID.fromString(ItemUtils.getTag(currentPet, MYPET_TAG));
        if (!petUUID.equals(event.getMyPet().getUUID())) {
            keepPet = false;
        }
    }

    if (!keepPet) {
        event.setCancelled(true);
        MyPetApi.getMyPetManager().deactivateMyPet(event.getOwner(), true);
    }
}
 
Example 7
Project: ClaimChunk   File: PlayerMovementHandler.java   View Source Code Vote up 5 votes
private void showTitle(Player player, Chunk newChunk) {
	UUID newOwner = ClaimChunk.getInstance().getChunkHandler().getOwner(newChunk.getWorld(), newChunk.getX(), newChunk.getZ());
	if (!newOwner.equals(player.getUniqueId())) {
		PlayerHandler nh = ClaimChunk.getInstance().getPlayerHandler();
		String newName = (nh.hasChunkName(newOwner)) ? nh.getChunkName(newOwner) : nh.getUsername(newOwner);
		if (newName != null) {
			String text = Utils.getMsg("chunkOwner").replaceAll(Pattern.quote("%%PLAYER%%"), newName);
			Utils.toPlayer(player, Config.getColor("infoColor"), text);
		}
	} else {
		Utils.toPlayer(player, Config.getColor("infoColor"), Utils.getMsg("chunkSelf"));
	}
}
 
Example 8
Project: factcast   File: InMemFactStore.java   View Source Code Vote up 5 votes
@Override
public OptionalLong serialOf(UUID l) {
    // hilariously inefficient
    for (Map.Entry<Long, Fact> e : store.entrySet()) {
        if (l.equals(e.getValue().id())) {
            return OptionalLong.of(e.getKey().longValue());
        }
    }
    return OptionalLong.empty();
}
 
Example 9
Project: ZentrelaRPG   File: DropManager.java   View Source Code Vote up 5 votes
@EventHandler
public void pickupItemEvent(PlayerPickupItemEvent event) {
    UUID iuuid = event.getItem().getUniqueId();
    if (itemMapTime.containsKey(iuuid)) {
        if (System.currentTimeMillis() - itemMapTime.get(iuuid) < 10000) {
            UUID owneruuid = itemMapOwner.get(iuuid);
            Player owner = plugin.getServer().getPlayer(owneruuid);
            PlayerDataRPG pdo = plugin.getPD(owner);
            PlayerDataRPG pd = plugin.getPD(event.getPlayer());
            if (owneruuid == null || owneruuid.equals(event.getPlayer().getUniqueId()) || (pdo != null && pd != null && pd.party != null && pd.party != pdo.party && pd.party.isLootshareActive())) {
                itemMapTime.remove(iuuid);
                itemMapOwner.remove(iuuid);
                return; // all good
            } else {
                event.setCancelled(true);
                if (plugin.getPD(event.getPlayer()) != null && plugin.getPD(event.getPlayer()).getOption(SakiOption.ITEM_PROTECT)) {
                    if (playerMapMessaged.containsKey(event.getPlayer().getUniqueId()) && System.currentTimeMillis() - playerMapMessaged.get(event.getPlayer().getUniqueId()) < 5000) {
                        // dont spam msg
                    } else {
                        event.getPlayer().sendMessage(ChatColor.RED + " You can't pick up this item yet because of item protection!");
                        event.getPlayer().sendMessage(ChatColor.RED + " Monster drops are only lootable by the highest damage dealer for 10 seconds.");
                        event.getPlayer().sendMessage(ChatColor.RED + " Skill-related items are only lootable by the creator of the item for 10 seconds.");
                        playerMapMessaged.put(event.getPlayer().getUniqueId(), System.currentTimeMillis());
                    }
                }
            }
        } else {
            itemMapTime.remove(iuuid);
            itemMapOwner.remove(iuuid);
        }
    }
}
 
Example 10
Project: NemesisSystem   File: NemesisRegistry.java   View Source Code Vote up 5 votes
@Override
public NemesisEntry getById(UUID id) {
	if (id == null) {
		return null;
	}
	for (NemesisEntry nemesis : nemeses) {
		if (id.equals(nemesis.getId())) {
			return nemesis;
		}
	}
	return null;
}
 
Example 11
Project: bluewatcher   File: WatchCtrlService.java   View Source Code Vote up 5 votes
@Override
public boolean knowsCharacteristic(BluetoothGattCharacteristic characteristic) {
	for (UUID uuid : getKnownCharacteristics()) {
		if (uuid.equals(characteristic.getUuid()))
			return true;
	}
	return false;
}
 
Example 12
Project: react-native-blue-manager   File: Peripheral.java   View Source Code Vote up 5 votes
private BluetoothGattCharacteristic findWritableCharacteristic(BluetoothGattService service, UUID characteristicUUID, int writeType) {
	try {
		BluetoothGattCharacteristic characteristic = null;

		// get write property
		int writeProperty = BluetoothGattCharacteristic.PROPERTY_WRITE;
		if (writeType == BluetoothGattCharacteristic.WRITE_TYPE_NO_RESPONSE) {
			writeProperty = BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE;
		}

		List<BluetoothGattCharacteristic> characteristics = service.getCharacteristics();
		for (BluetoothGattCharacteristic c : characteristics) {
			if ((c.getProperties() & writeProperty) != 0 && characteristicUUID.equals(c.getUuid())) {
				characteristic = c;
				break;
			}
		}

		// As a last resort, try and find ANY characteristic with this UUID, even if it doesn't have the correct properties
		if (characteristic == null) {
			characteristic = service.getCharacteristic(characteristicUUID);
		}

		return characteristic;
	}catch (Exception e) {
		Log.e(LOG_TAG, "Error on findWritableCharacteristic", e);
		return null;
	}
}
 
Example 13
Project: uniquecrops   File: TileFeroxia.java   View Source Code Vote up 5 votes
public boolean setOwner(UUID owner) {
	
	if ((this.owner != null && !this.owner.equals(owner)) || (owner != null && !owner.equals(this.owner))) {
		
		this.owner = owner;
		if (worldObj != null && !worldObj.isRemote)
			markDirty();
	}
	return true;
}
 
Example 14
Project: PlusGram   File: PsshAtomUtil.java   View Source Code Vote up 5 votes
/**
 * Parses the scheme specific data from a PSSH atom. Version 0 and 1 PSSH atoms are supported.
 * <p>
 * The scheme specific data is only parsed if the data is a valid PSSH atom matching the given
 * UUID, or if the data is a valid PSSH atom of any type in the case that the passed UUID is null.
 *
 * @param atom The atom to parse.
 * @param uuid The required UUID of the PSSH atom, or null to accept any UUID.
 * @return The parsed scheme specific data. Null if the input is not a valid PSSH atom, or if the
 *     PSSH atom has an unsupported version, or if the PSSH atom does not match the passed UUID.
 */
public static byte[] parseSchemeSpecificData(byte[] atom, UUID uuid) {
  Pair<UUID, byte[]> parsedAtom = parsePsshAtom(atom);
  if (parsedAtom == null) {
    return null;
  }
  if (uuid != null && !uuid.equals(parsedAtom.first)) {
    Log.w(TAG, "UUID mismatch. Expected: " + uuid + ", got: " + parsedAtom.first + ".");
    return null;
  }
  return parsedAtom.second;
}
 
Example 15
Project: FactionsXL   File: Faction.java   View Source Code Vote up 5 votes
/**
 * @return
 * a Set of all members that are not mod or admin as OfflinePlayers
 */
public Collection<OfflinePlayer> getNonPrivilegedMembers() {
    HashSet<OfflinePlayer> players = new HashSet<>();
    for (UUID member : members.getUniqueIds()) {
        if (!mods.contains(member) && !member.equals(admin)) {
            players.add(Bukkit.getOfflinePlayer(member));
        }
    }
    return players;
}
 
Example 16
Project: Backmemed   File: World.java   View Source Code Vote up 5 votes
@Nullable
public EntityPlayer getPlayerEntityByUUID(UUID uuid)
{
    for (int i = 0; i < this.playerEntities.size(); ++i)
    {
        EntityPlayer entityplayer = (EntityPlayer)this.playerEntities.get(i);

        if (uuid.equals(entityplayer.getUniqueID()))
        {
            return entityplayer;
        }
    }

    return null;
}
 
Example 17
Project: AndroidMuseumBleManager   File: ScanFilterCompat.java   View Source Code Vote up 5 votes
private boolean matchesServiceUuid(UUID uuid, UUID mask, UUID data) {
    if (mask == null) {
        return uuid.equals(data);
    }
    if ((uuid.getLeastSignificantBits() & mask.getLeastSignificantBits()) !=
            (data.getLeastSignificantBits() & mask.getLeastSignificantBits())) {
        return false;
    }
    return ((uuid.getMostSignificantBits() & mask.getMostSignificantBits()) ==
            (data.getMostSignificantBits() & mask.getMostSignificantBits()));
}
 
Example 18
Project: scorekeeperfrontend   File: SQLDataInterface.java   View Source Code Vote up 4 votes
@Override
public Dialins loadDialins(UUID eventid)
{
    String sql = "SELECT c.classcode,c.indexcode,c.useclsmult,r.* "
            + "FROM runs AS r JOIN cars AS c ON c.carid=r.carid WHERE r.eventid=? ORDER BY r.carid,r.course";

    try
    {
        Event e      = executeSelect("select * from events where eventid=?", newList(eventid), Event.class.getConstructor(ResultSet.class)).get(0);
        ResultSet rs = executeSelect(sql, newList(eventid));

        Dialins ret         = new Dialins();
        UUID currentid      = IdGenerator.nullid;
        String classcode    = "";
        String indexcode    = "";
        boolean useclsmult  = false;
        double index        = 1.0;
        double bestraw[]    = new double[2];
        double bestnet[]    = new double[2];

        // 1. load all runs
        // 2. calculate best raw/net/sum for each carid
        // 3. set personal dialin
        while (rs.next())
        {
            Run r = new Run(rs);
            double net = 999.999;

            if (!currentid.equals(r.getCarId()))  // next car, process previous
            {
                ret.setEntrant(currentid, classcode, bestraw[0]+bestraw[1], bestnet[0]+bestnet[1], index);
                currentid = r.getCarId();
                bestraw[0] = bestraw[1] = bestnet[0] = bestnet[1] = 999.999;
            }

            classcode    = rs.getString("classcode");
            indexcode    = rs.getString("indexcode");
            useclsmult   = rs.getBoolean("useclsmult");
            index        = getClassData().getEffectiveIndex(classcode, indexcode, useclsmult);

            if (r.isOK()) // we ignore non-OK runs
            {
                int idx = r.course() - 1;
                if (r.raw < bestraw[idx])
                    bestraw[idx] = r.raw;

                net = (r.getRaw() + (e.getConePenalty() * r.getCones()) + (e.getGatePenalty() * r.getGates())) * index;
                if (net < bestnet[idx])
                    bestnet[idx] = net;
            }
        }

        // 4. order and set class dialins
        ret.finalizedialins();
        closeLeftOvers();
        return ret;
    }
    catch (Exception ioe)
    {
        logError("loadDialins", ioe);
        return null;
    }
}
 
Example 19
Project: minecraft-territorialdealings   File: TerritoryHandler.java   View Source Code Vote up 4 votes
public static void disbandFaction(World world, UUID factionID, Entity dropEntity) 
{
	if (world == null) { return; }
	if (factionID == null) { return; }
	
	_FactionSaveData faction = saveData.getFactionMap().get(factionID);
	
	if (faction == null) 
	{ 
		// Not a known faction, hm?
		Main.console("Warning: Someone tried to disband a faction that doesn't seem to exist. ID: " + factionID);
		return; 
	}
	
	// Disband this faction, kick all members out, tell them about it and scatter their valuables at the feet of the entity specified
	Main.console("Disbanding faction " + faction.getName() + " (ID " + factionID + ")...");
	
	// Step 1, kick all members out and tell them about it
	Main.sendMessageToFactionMembers(world, factionID, "Disbanding faction " + faction.getName() + "!");
	
	Iterator<Entry<UUID, _PlayerSaveData>> playerIt = saveData.getPlayerMapIterator();
	Entry<UUID, _PlayerSaveData> playerData;
	
	while (playerIt.hasNext())
	{
		playerData = playerIt.next();
		
		if (factionID.equals(playerData.getValue().getLeadership()))
		{
			// Oh hello, leader.
			Main.console("...removing leader " + playerData.getKey() + "...");
			
			playerData.getValue().setLeadership(null);
		}
		
		if (playerData.getValue().getMemberList().contains(factionID))
		{
			// Hello, member.
			Main.console("...removing member " + playerData.getKey() + "...");
			playerData.getValue().getMemberList().remove(factionID);
		}
	}
	
	Main.console("...removing the faction itself...");
	
	// Step 2, begone with the faction
	saveData.getFactionMap().remove(factionID);
	
	// Step 3, scattering valuables
	if (faction.getValuables() <= 0)
	{
		Main.console("...no VALUABLES to scatter. Done removing faction.");
		return;
	}
	
	Main.console("...scattering " + faction.getValuables() + " VALUABLES...");
	
	if (dropEntity == null)
	{
		// We have no entity to drop this at. Now what?
		// TODO
	}
	else
	{
		// We have an entity. Dropping a new (set of) payment order(s) at their feet
		// TODO
	}
	
	Main.console("...done disbanding faction.");
}
 
Example 20
Project: Exoplayer2Radio   File: DrmInitData.java   View Source Code Vote up 2 votes
/**
 * Returns whether this initialization data applies to the specified scheme.
 *
 * @param schemeUuid The scheme {@link UUID}.
 * @return Whether this initialization data applies to the specified scheme.
 */
public boolean matches(UUID schemeUuid) {
  return C.UUID_NIL.equals(uuid) || schemeUuid.equals(uuid);
}