Example usage for java.util UUID equals

List of usage examples for java.util UUID equals

Introduction

In this page you can find the example usage for java.util UUID equals.

Prototype

public boolean equals(Object obj) 

Source Link

Document

Compares this object to the specified object.

Usage

From source file:com.haulmont.cuba.gui.components.filter.FilterDelegateImpl.java

protected FilterEntity getDefaultFilter(List<FilterEntity> filters) {
    Window window = ComponentsHelper.getWindow(filter);

    // First check if there is parameter with name equal to this filter component id, containing a filter code to apply
    Map<String, Object> params = filter.getFrame().getContext().getParams();
    String code = (String) params.get(filter.getId());
    if (!StringUtils.isBlank(code)) {
        for (FilterEntity filter : filters) {
            if (code.equals(filter.getCode()))
                return filter;
        }/*from   w w  w  .  j a  v  a 2 s .c o  m*/
    }

    // No 'filter' parameter found, load default filter
    SettingsImpl settings = new SettingsImpl(window.getId());

    String componentPath = ComponentsHelper.getFilterComponentPath(filter);
    String[] strings = ValuePathHelper.parse(componentPath);
    String name = ValuePathHelper.format((String[]) ArrayUtils.subarray(strings, 1, strings.length));

    Element e = settings.get(name).element("defaultFilter");
    if (e != null) {
        String defIdStr = e.attributeValue("id");
        Boolean applyDefault = Boolean.valueOf(e.attributeValue("applyDefault"));
        if (!StringUtils.isBlank(defIdStr)) {
            UUID defaultId = null;
            try {
                defaultId = UUID.fromString(defIdStr);
            } catch (IllegalArgumentException ex) {
                //
            }
            if (defaultId != null) {
                for (FilterEntity filter : filters) {
                    if (defaultId.equals(filter.getId())) {
                        filter.setIsDefault(true);
                        filter.setApplyDefault(applyDefault);
                        return filter;
                    }
                }
            }
        }
    }

    FilterEntity globalDefaultFilter = filters.stream()
            .filter(filterEntity -> Boolean.TRUE.equals(filterEntity.getGlobalDefault())).findAny()
            .orElse(null);
    return globalDefaultFilter;
}

From source file:org.midonet.cluster.LocalDataClientImpl.java

private Pair<String, PoolHealthMonitorConfig> buildPoolHealthMonitorMappings(final UUID vipId,
        final @Nonnull VipZkManager.VipConfig config, final boolean deleteVip)
        throws MappingStatusException, SerializationException, StateAccessException {
    UUID poolId = checkNotNull(config.poolId, "Pool ID is null.");
    PoolZkManager.PoolConfig poolConfig = poolZkManager.get(poolId);

    // Since we haven't deleted/updated this VIP in Zookeeper yet,
    // preparePoolHealthMonitorMappings() will get an outdated version of
    // this VIP when it fetches the Pool's vips. The ConfigGetter
    // intercepts the request for this VIP and returns the updated
    // VipConfig, or null if it's been deleted.
    ConfigGetter<UUID, VipZkManager.VipConfig> configGetter = new ConfigGetter<UUID, VipZkManager.VipConfig>() {
        @Override//from  w  w  w . ja v  a  2s  .c o m
        public VipZkManager.VipConfig get(UUID key) throws StateAccessException, SerializationException {
            if (key.equals(vipId)) {
                return deleteVip ? null : config;
            }
            return vipZkManager.get(key);
        }
    };

    return preparePoolHealthMonitorMappings(poolId, poolConfig, poolMemberZkManager, configGetter);
}

From source file:org.midonet.cluster.LocalDataClientImpl.java

private Pair<String, PoolHealthMonitorConfig> buildPoolHealthMonitorMappings(final UUID poolMemberId,
        final @Nonnull PoolMemberZkManager.PoolMemberConfig config, final boolean deletePoolMember)
        throws MappingStatusException, SerializationException, StateAccessException {
    UUID poolId = checkNotNull(config.poolId, "Pool ID is null.");
    PoolZkManager.PoolConfig poolConfig = poolZkManager.get(poolId);

    // Since we haven't deleted/updated this PoolMember in Zookeeper yet,
    // preparePoolHealthMonitorMappings() will get an outdated version of
    // this PoolMember when it fetches the Pool's members. The ConfigGetter
    // intercepts the request for this PoolMember and returns the updated
    // PoolMemberConfig, or null if it's been deleted.
    ConfigGetter<UUID, PoolMemberZkManager.PoolMemberConfig> configGetter = new ConfigGetter<UUID, PoolMemberZkManager.PoolMemberConfig>() {
        @Override/*from  ww  w . j a v a 2 s  .  co m*/
        public PoolMemberZkManager.PoolMemberConfig get(UUID key)
                throws StateAccessException, SerializationException {
            if (key.equals(poolMemberId)) {
                return deletePoolMember ? null : config;
            }
            return poolMemberZkManager.get(key);
        }
    };

    return preparePoolHealthMonitorMappings(poolId, poolConfig, configGetter, vipZkManager);
}

From source file:org.apache.bookkeeper.mledger.impl.ManagedLedgerImpl.java

private CompletableFuture<Void> completeLedgerInfoForOffloaded(long ledgerId, UUID uuid) {
    log.info("[{}] Completing metadata for offload of ledger {} with uuid {}", name, ledgerId, uuid);
    return transformLedgerInfo(ledgerId, (oldInfo) -> {
        UUID existingUuid = new UUID(oldInfo.getOffloadContext().getUidMsb(),
                oldInfo.getOffloadContext().getUidLsb());
        if (existingUuid.equals(uuid)) {
            LedgerInfo.Builder builder = oldInfo.toBuilder();
            builder.getOffloadContextBuilder().setTimestamp(clock.millis()).setComplete(true);

            String driverName = OffloadUtils.getOffloadDriverName(oldInfo,
                    config.getLedgerOffloader().getOffloadDriverName());
            Map<String, String> driverMetadata = OffloadUtils.getOffloadDriverMetadata(oldInfo,
                    config.getLedgerOffloader().getOffloadDriverMetadata());
            OffloadUtils.setOffloadDriverMetadata(builder, driverName, driverMetadata);
            return builder.build();
        } else {/*ww  w  . j  a  va2  s  .co m*/
            throw new OffloadConflict("Existing UUID(" + existingUuid + ") in metadata for offload"
                    + " of ledgerId " + ledgerId + " does not match the UUID(" + uuid
                    + ") for the offload we are trying to complete");
        }
    }).whenComplete((result, exception) -> {
        if (exception == null) {
            log.info("[{}] End Offload. ledger={}, uuid={}", name, ledgerId, uuid);
        } else {
            log.warn("[{}] Failed to complete offload of ledger {}, uuid {}", name, ledgerId, uuid, exception);
        }
    });
}

From source file:nodomain.freeyourgadget.gadgetbridge.service.devices.pebble.PebbleProtocol.java

private GBDeviceEvent[] decodeDatalog(ByteBuffer buf, short length) {
    boolean ack = true;
    byte command = buf.get();
    byte id = buf.get();
    GBDeviceEventDataLogging devEvtDataLogging = null;
    switch (command) {
    case DATALOG_TIMEOUT:
        LOG.info("DATALOG TIMEOUT. id=" + (id & 0xff) + " - ignoring");
        return null;
    case DATALOG_SENDDATA:
        buf.order(ByteOrder.LITTLE_ENDIAN);
        int items_left = buf.getInt();
        int crc = buf.getInt();
        DatalogSession datalogSession = mDatalogSessions.get(id);
        LOG.info("DATALOG SENDDATA. id=" + (id & 0xff) + ", items_left=" + items_left + ", total length="
                + (length - 10));//from   w  w  w  .j  a  va2 s.c om
        if (datalogSession != null) {
            LOG.info("DATALOG UUID=" + datalogSession.uuid + ", tag=" + datalogSession.tag
                    + datalogSession.getTaginfo() + ", itemSize=" + datalogSession.itemSize + ", itemType="
                    + datalogSession.itemType);
            if (!datalogSession.uuid.equals(UUID_ZERO) && datalogSession.getClass().equals(DatalogSession.class)
                    && mEnablePebbleKit) {
                devEvtDataLogging = datalogSession.handleMessageForPebbleKit(buf, length - 10);
                if (devEvtDataLogging == null) {
                    ack = false;
                }
            } else {
                ack = datalogSession.handleMessage(buf, length - 10);
            }
        }
        break;
    case DATALOG_OPENSESSION:
        UUID uuid = getUUID(buf);
        buf.order(ByteOrder.LITTLE_ENDIAN);
        int timestamp = buf.getInt();
        int log_tag = buf.getInt();
        byte item_type = buf.get();
        short item_size = buf.getShort();
        LOG.info("DATALOG OPENSESSION. id=" + (id & 0xff) + ", App UUID=" + uuid.toString() + ", log_tag="
                + log_tag + ", item_type=" + item_type + ", itemSize=" + item_size);
        if (!mDatalogSessions.containsKey(id)) {
            if (uuid.equals(UUID_ZERO) && log_tag == 81) {
                mDatalogSessions.put(id, new DatalogSessionHealthSteps(id, uuid, timestamp, log_tag, item_type,
                        item_size, getDevice()));
            } else if (uuid.equals(UUID_ZERO) && log_tag == 83) {
                mDatalogSessions.put(id, new DatalogSessionHealthSleep(id, uuid, timestamp, log_tag, item_type,
                        item_size, getDevice()));
            } else if (uuid.equals(UUID_ZERO) && log_tag == 84) {
                mDatalogSessions.put(id, new DatalogSessionHealthOverlayData(id, uuid, timestamp, log_tag,
                        item_type, item_size, getDevice()));
            } else if (uuid.equals(UUID_ZERO) && log_tag == 85) {
                mDatalogSessions.put(id, new DatalogSessionHealthHR(id, uuid, timestamp, log_tag, item_type,
                        item_size, getDevice()));
            } else {
                mDatalogSessions.put(id,
                        new DatalogSession(id, uuid, timestamp, log_tag, item_type, item_size));
            }
        }
        break;
    case DATALOG_CLOSE:
        LOG.info("DATALOG_CLOSE. id=" + (id & 0xff));
        datalogSession = mDatalogSessions.get(id);
        if (datalogSession != null) {
            if (!datalogSession.uuid.equals(UUID_ZERO) && datalogSession.getClass().equals(DatalogSession.class)
                    && mEnablePebbleKit) {
                GBDeviceEventDataLogging dataLogging = new GBDeviceEventDataLogging();
                dataLogging.command = GBDeviceEventDataLogging.COMMAND_FINISH_SESSION;
                dataLogging.appUUID = datalogSession.uuid;
                dataLogging.tag = datalogSession.tag;
                devEvtDataLogging = dataLogging;
            }
            mDatalogSessions.remove(id);
        }
        break;
    default:
        LOG.info("unknown DATALOG command: " + (command & 0xff));
        break;
    }
    GBDeviceEventSendBytes sendBytes = new GBDeviceEventSendBytes();
    if (ack) {
        LOG.info("sending ACK (0x85)");
        sendBytes.encodedBytes = encodeDatalog(id, DATALOG_ACK);
    } else {
        LOG.info("sending NACK (0x86)");
        sendBytes.encodedBytes = encodeDatalog(id, DATALOG_NACK);
    }
    // append ack/nack
    return new GBDeviceEvent[] { devEvtDataLogging, sendBytes };
}

From source file:org.cloudfoundry.client.lib.rest.CloudControllerClientImpl.java

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;//  w ww .  j  a  v a2 s.  com
    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;
}

From source file:org.apache.usergrid.persistence.cassandra.EntityManagerImpl.java

/**
 * Gets the specified entity./*from w ww .  j av a 2 s  .  co  m*/
 *
 * @param entityId the entity id
 * @param entityClass the entity class
 *
 * @return entity
 *
 * @throws Exception the exception
 */
public <A extends Entity> A getEntity(UUID entityId, Class<A> entityClass) throws Exception {

    Object entity_key = key(entityId);
    Map<String, Object> results = null;

    // if (entityType == null) {
    results = deserializeEntityProperties(
            cass.getAllColumns(cass.getApplicationKeyspace(applicationId), ENTITY_PROPERTIES, entity_key));
    // } else {
    // Set<String> columnNames = Schema.getPropertyNames(entityType);
    // results = getColumns(getApplicationKeyspace(applicationId),
    // EntityCF.PROPERTIES, entity_key, columnNames, se, be);
    // }

    if (results == null) {
        logger.warn("getEntity(): No properties found for entity {}, probably doesn't exist...", entityId);
        return null;
    }

    UUID id = uuid(results.get(PROPERTY_UUID));
    String type = string(results.get(PROPERTY_TYPE));

    if (!entityId.equals(id)) {

        logger.error("Expected entity id {}, found {}. Returning null entity",
                new Object[] { entityId, id, new Throwable() });
        return null;
    }

    A entity = EntityFactory.newEntity(id, type, entityClass);
    entity.setProperties(results);

    return entity;
}

From source file:com.wasteofplastic.acidisland.commands.IslandCmd.java

/**
 * Removes a player from a team run by teamleader
 * //from  w  w  w. j  a  v  a  2s.c  om
 * @param playerUUID
 * @param teamLeader
 */
public void removePlayerFromTeam(final UUID playerUUID, final UUID teamLeader) {
    // Remove player from the team
    plugin.getPlayers().removeMember(teamLeader, playerUUID);
    // If player is online
    // If player is not the leader of their own team
    if (!playerUUID.equals(teamLeader)) {
        plugin.getPlayers().setLeaveTeam(playerUUID);
        //plugin.getPlayers().setHomeLocation(player, null);
        plugin.getPlayers().clearHomeLocations(playerUUID);
        plugin.getPlayers().setIslandLocation(playerUUID, null);
        plugin.getPlayers().setTeamIslandLocation(playerUUID, null);
        runCommands(Settings.leaveCommands, playerUUID);
        // Fire event
        final IslandLeaveEvent event = new IslandLeaveEvent(plugin, playerUUID, teamLeader);
        plugin.getServer().getPluginManager().callEvent(event);
    } else {
        // Ex-Leaders keeps their island, but the rest of the team items are
        // removed
        plugin.getPlayers().setLeaveTeam(playerUUID);
    }

}

From source file:org.cloudfoundry.client.lib.rest.CloudControllerClientImpl.java

private List<CloudRoute> doGetRoutes(UUID domainGuid) {
    Map<String, Object> urlVars = new HashMap<String, Object>();
    String urlPath = "/v2";
    //      TODO: NOT implemented ATM:
    //      if (sessionSpace != null) {
    //         urlVars.put("space", sessionSpace.getMeta().getGuid());
    //         urlPath = urlPath + "/spaces/{space}";
    //      }/*from  ww w  .j a  v a2s.  com*/
    urlPath = urlPath + "/routes?inline-relations-depth=1";
    List<Map<String, Object>> allRoutes = getAllResources(urlPath, urlVars);
    List<CloudRoute> routes = new ArrayList<CloudRoute>();
    for (Map<String, Object> route : allRoutes) {
        //         TODO: move space_guid to path once implemented (see above):
        UUID space = CloudEntityResourceMapper.getEntityAttribute(route, "space_guid", UUID.class);
        UUID domain = CloudEntityResourceMapper.getEntityAttribute(route, "domain_guid", UUID.class);
        if (sessionSpace.getMeta().getGuid().equals(space) && domainGuid.equals(domain)) {
            //routes.add(CloudEntityResourceMapper.getEntityAttribute(route, "host", String.class));
            routes.add(resourceMapper.mapResource(route, CloudRoute.class));
        }
    }
    return routes;
}